Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 18 Oct 2017 02:59:17 +0200
From: "Jason A. Donenfeld" <>
To: "Tobin C. Harding" <>
	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 <>, Dave Weinstein <>, 
	Daniel Micay <>, Djalal Harouni <>, 
	LKML <>
Subject: Re: [PATCH v3] printk: hash addresses printed with %p

Hi Tobin,

You submitted v3 without replying to my v2 comments. I'll give a
condensed version of those here for convenience.

> diff --git a/include/linux/siphash.h b/include/linux/siphash.h
> +unsigned long siphash_1ulong(const unsigned long a, const siphash_key_t *key);

Don't add this function here. It's not the right signature anyway.
> +unsigned long siphash_1ulong(const unsigned long first, const siphash_key_t *key)
> +{

Likewise, remove this.

> +/* Maps a pointer to a 32 bit unique identifier. */
> +static char *ptr_to_id(char *buf, char *end, void *ptr, struct printf_spec spec)
> +{
> +       static siphash_key_t ptr_secret __read_mostly;
> +       static atomic_t have_key = ATOMIC_INIT(0);
> +       unsigned long hashval;
> +
> +        if (atomic_xchg(&have_key, 1) == 0)
> +               get_random_bytes(&ptr_secret, sizeof(ptr_secret));

This isn't safe. Initialize ptr_secret in the callback function
provided to add_random_ready_callback. Before ptr_secret is
initialized, you should simply return a stub literal string from that
function of something like "(pointer value)".

> +       hashval = siphash_1ulong((unsigned long)ptr, &ptr_secret);

Replace this with:

#ifdef CONFIG_64BIT
hashval = (unsigned long)siphash_1u64((u64)ptr, key);
hashval = (unsigned long)siphash_1u32((u32)ptr, key);

However, in another thread, Linus mentioned that he'd prefer all the
obfuscated values actually be 32-bit. So, this then looks like:

unsigned int hashval;
#ifdef CONFIG_64BIT
hashval = (unsigned int)siphash_1u64((u64)ptr, key);
hashval = (unsigned int)siphash_1u32((u32)ptr, key);

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.