[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHXqBFKE_hLvFgL1_7F+k+pQ0+tEuhBqeRUOtgaM1yrjvXQQww@mail.gmail.com>
Date: Fri, 8 Jul 2011 21:39:18 +0200
From: Michał Mirosław <mirqus@...il.com>
To: David Miller <davem@...emloft.net>
Cc: roland@...estorage.com, johnwheffner@...il.com, mj@....cz,
netdev@...r.kernel.org
Subject: Re: ipv4: Simplify ARP hash function.
2011/7/8 David Miller <davem@...emloft.net>:
> From: Roland Dreier <roland@...estorage.com>
> Date: Fri, 8 Jul 2011 12:26:17 -0700
>
>> On Fri, Jul 8, 2011 at 11:06 AM, David Miller <davem@...emloft.net> wrote:
>>> Ok, there was also an unintended bug in my original patch,
>>> I lost the bottom 8 bits in the fold, the hash function
>>> should instead be:
>>>
>>> +static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd)
>>> +{
>>> + u32 val = key ^ dev->ifindex ^ hash_rnd;
>>> +
>>> + return val ^ (val >> 8) ^ (val >> 16) ^ (val >> 24);
>>> +}
>>
>> Doesn't seem to matter much -- this is now equivalent to
>>
>> a = key ^ dev->ifindex
>> return (a ^ (a >> 8) ^ (a >> 16) ^ (a >> 24)) // (1)
>> ^ (rnd ^ (rnd >> 8) ^ (rnd >> 16) ^ (rnd >> 24)) // (2)
>>
>> where again the attacker controls (1), and (2) is a constant.
>
> Right, but how can you attack it? Show me how you can grow
> a hash chain of arbitrary length by modulating the key in
> a deterministic way.
For 256 buckets its easy:
hash_index = b[0] ^ b[1] ^ b[2] ^ b[3];
(b[i] are bytes of the key)
With b[3] = b[0] ^ b[1] ^ b[2] you get 2^24 keys that hash to the same bucket.
Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists