Re: [PATCH] use %pK for /proc/kallsyms and /proc/modules

From: Kees Cook
Date: Wed Jan 26 2011 - 19:29:25 EST


On Wed, Jan 26, 2011 at 04:15:09PM -0800, Joe Perches wrote:
> On Tue, 2011-01-25 at 10:10 -0800, Kees Cook wrote:
> > Note that when compiling with -Wformat, these harmless warnings will
> > be emitted, and can be ignored:
> > warning: '0' flag used with â%pâ gnu_printf format
>
> > diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
> []
> > @@ -477,11 +477,11 @@ static int s_show(struct seq_file *m, void *p)
> > */
> > type = iter->exported ? toupper(iter->type) :
> > tolower(iter->type);
> > - seq_printf(m, "%0*lx %c %s\t[%s]\n",
> > + seq_printf(m, "%0*pK %c %s\t[%s]\n",
> > (int)(2 * sizeof(void *)),
> > iter->value, type, iter->name, iter->module_name);
>
> You can change this to
>
> seq_printf(m, "%pK %c %s\t[%s]\n",
> iter->value, type, iter->name, iter->module_name);
>
> as that's the normal size.
>
> Presto. No warnings. Same output.

Ah-ha! I was comparing against POSIX %p, which doesn't zeropad. The
kernel's %p does, so that's perfect! Yay, no warnings. Thanks! I'll send an
updated patch.

--
Kees Cook
Ubuntu Security Team
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/