lkml.org 
[lkml]   [2010]   [Dec]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v7] kptr_restrict for hiding kernel pointers
From
Date
On Wed, 2010-12-22 at 21:03 -0500, Dan Rosenberg wrote:
> Add the %pK printk format specifier and
> the /proc/sys/kernel/kptr_restrict sysctl.

Another trivial style comment:

> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
[]
> + case 'K':
> + /*
> + * %pK cannot be used in IRQ context because its test
> + * for CAP_SYSLOG would be meaningless.
> + */
> + if (in_irq() || in_serving_softirq() || in_nmi()) {
> + if (spec.field_width == -1)
> + spec.field_width = 2 * sizeof(void *);
> + return string(buf, end, "pK-error", spec);
> + }
> +
> + else if ((kptr_restrict == 0) ||
> + (kptr_restrict == 1 &&
> + has_capability_noaudit(current, CAP_SYSLOG)))
> + break;
> +

---
> + if (spec.field_width == -1) {
> + spec.field_width = 2 * sizeof(void *);
> + spec.flags |= ZEROPAD;
> + }
> + return number(buf, end, 0, spec);

It'd be slightly smaller code to use:

ptr = 0;
break;

and delete the if block and return number.

> }
> spec.flags |= SMALL;
> if (spec.field_width == -1) {




\
 
 \ /
  Last update: 2010-12-23 05:13    [from the cache]
©2003-2011 Jasper Spaans