Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 24 Oct 2017 21:25:20 +0200
From: Rasmus Villemoes <>
To: "Tobin C. Harding" <>
Cc:,  "Jason A. Donenfeld" <>,  Theodore Ts'o <>,  Linus Torvalds <>,  Kees Cook <>,  Paolo Bonzini <>,  Tycho Andersen <>,  "Roberts\, William C" <>,  Tejun Heo <>,  Jordan Glover <>,  Greg KH <>,  Petr Mladek <>,  Joe Perches <>,  Ian Campbell <>,  Sergey Senozhatsky <>,  Catalin Marinas <>,  Will Deacon <>,  Steven Rostedt <>,  Chris Fries <>
Subject: Re: [PATCH v7] printk: hash addresses printed with %p

On Tue, Oct 24 2017, "Tobin C. Harding" <> wrote:

> +
> +/* Maps a pointer to a 32 bit unique identifier. */
> +static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
> +{
> +	unsigned int hashval;
> +
> +	if (static_branch_unlikely(&no_ptr_secret))
> +		return "(pointer value)";

Eh, you probably meant to call

  string(buf, end, "(pointer value)", some-appropriate-spec)

otherwise this will either crash very soon (when the following output
wants to overwrite that '(' in .rodata), or at the very least cause a
completely bogus eventual return value (if the "(pointer value)" string
happens to have an address > end, so that we don't actually attempt any
more printing).

Whether the given spec is suitable as some-appropriate-spec or one
should just use a fixed one I don't know.

The rest are just random thoughts/ramblings/questions, feel free to ignore.

Can one do some qemu magic to test the no_ptr_secret code path?

> +
> +#ifdef CONFIG_64BIT
> +	hashval = (unsigned int)siphash_1u64((u64)ptr, &ptr_secret);
> +#else
> +	hashval = (unsigned int)siphash_1u32((u32)ptr, &ptr_secret);
> +#endif
> +
> +	spec.field_width = 2 * sizeof(unsigned int);
> +	spec.flags = SMALL;
> +	spec.base = 16;
> +
> +	return number(buf, end, hashval, spec);
> +}

Maybe include SPECIAL in flags? I know that this is just meant to be
mostly-unique identifier and its not really a number, but it's still
weird to see a string of hex digits not preceded by 0x. Also, maybe use
.precision to get zero-padding instead of spaces?

I haven't followed the discussion too closely, but has it been
considered to exempt NULL from hashing?


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.