From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755145AbcANWIM (ORCPT ); Thu, 14 Jan 2016 17:08:12 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36649 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752700AbcANWIJ (ORCPT ); Thu, 14 Jan 2016 17:08:09 -0500 Message-ID: <1452809286.1223.152.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout From: Eric Dumazet To: Haiyang Zhang Cc: Tom Herbert , One Thousand Gnomes , David Miller , "vkuznets@redhat.com" , "netdev@vger.kernel.org" , KY Srinivasan , "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" Date: Thu, 14 Jan 2016 14:08:06 -0800 In-Reply-To: References: <1452159189-11473-1-git-send-email-vkuznets@redhat.com> <20160110.172558.367101858392871618.davem@davemloft.net> <20160114175304.161ff0af@lxorguk.ukuu.org.uk> <1452795849.1223.112.camel@edumazet-glaptop2.roam.corp.google.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2016-01-14 at 20:23 +0000, Haiyang Zhang wrote: > > For non-random inputs, I used the port selection of iperf that increases > the port number by 2 for each connection. Only send-port numbers are > different, other values are the same. I also tested some other fixed > increment, Toeplitz spreads the connections evenly. For real applications, > if the load came from local area, then the IP/port combinations are > likely to have some non-random patterns. We are not putting code in core networking stack favoring non secure behavior. The +2 behavior for connections from A to B: is something that we will eventually remove in the future. It used to be +1 not a long time ago... Say if we implement the following, https://tools.ietf.org/html/rfc6056#section-3.3.4 The fact that Toeplitz hash has this linear property should not be a valid reason to help hackers to exploit vulnerabilities. In my tests I was using netperf, which randomizes both source & destination ports. This is why I could not reproduce your results based on iperf, which generates 5-tuple in a totally predictable way. This reminds me some drivers had a well known Toeplitz RSS key, allowing attackers to direct their attack on a single queue. I guess we could replace sk_txhash generator by a simple linear allocator and boom, your driver will be pleased. But this is only for a very specific workload. diff --git a/include/net/sock.h b/include/net/sock.h index e830c1006935..949527413cfb 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1689,7 +1689,8 @@ unsigned long sock_i_ino(struct sock *sk); static inline u32 net_tx_rndhash(void) { - u32 v = prandom_u32(); + static u32 last_hash; + u32 v = ++last_hash; // do not care about SMP races. return v ?: 1; }