Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] ath9k: turn on btcoex_enable as default
From: Kai-Heng Feng @ 2018-08-23  1:33 UTC (permalink / raw)
  To: Felix Fietkau
  Cc: Kalle Valo, ath9k-devel, linux-wireless, netdev, linux-kernel
In-Reply-To: <6A0F65EF-A7C4-469F-8FAF-CBE314676237@canonical.com>

at 12:15, Kai Heng Feng <kai.heng.feng@canonical.com> wrote:

>
>
>> On 10 Feb 2018, at 10:05 PM, Felix Fietkau <nbd@nbd.name> wrote:
>>
>> On 2018-02-10 14:56, Kai Heng Feng wrote:
>>>> On 9 Feb 2018, at 3:16 PM, Kalle Valo <kvalo@codeaurora.org> wrote:
>>>> Sure, but we have to make sure that we don't create regressions on
>>>> existing systems. For example, did you test this with any system which
>>>> don't support btcoex? (just asking, haven't tested this myself)
>>>
>>> No not really, but I will definitely test it.
>>> The only module I have that uses ath9k is Dell’s DW1707.
>>> How do I check if it support btcoex or not?
>> I just reviewed the code again, and I am sure that we cannot merge this
>> patch. Enabling the btcoex parameter makes the driver enable a whole
>> bunch of code starting timers, listening to some GPIOs, etc.
>>
>> On non-btcoex systems, some of those GPIOs might be floating or even
>> connected to different things, which could cause a lot of undefined
>> behavior.
>>
>> This is simply too big a risk, so there absolutely needs to be a
>> whitelist for systems that need this, otherwise it has to remain
>> disabled by default.
>
> So what information can we use to whitelist btcoex chips?
> Can we get btcoex support status at ath9k probing?

Sorry for bringing this up again.

Is DMI based match an acceptable approach for ath9k?

Kai-Heng

>
> Kai-Heng
>
>> - Felix

^ permalink raw reply

* [Patch net 1/4] net: hns: fix length and page_offset overflow when CONFIG_ARM64_64K_PAGES
From: Huazhong Tan @ 2018-08-23  3:10 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong
In-Reply-To: <1534993813-236850-1-git-send-email-tanhuazhong@huawei.com>

When enable the config item "CONFIG_ARM64_64K_PAGES", the size of PAGE_SIZE
is 65536(64K). But the  type of length and page_offset are u16, they will
overflow. So change them to u32.

Fixes: 6fe6611ff275 ("net: add Hisilicon Network Subsystem hnae framework support")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hnae.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h
index fa5b30f..cad52bd 100644
--- a/drivers/net/ethernet/hisilicon/hns/hnae.h
+++ b/drivers/net/ethernet/hisilicon/hns/hnae.h
@@ -220,10 +220,10 @@ struct hnae_desc_cb {
 
 	/* priv data for the desc, e.g. skb when use with ip stack*/
 	void *priv;
-	u16 page_offset;
-	u16 reuse_flag;
+	u32 page_offset;
+	u32 length;     /* length of the buffer */
 
-	u16 length;     /* length of the buffer */
+	u16 reuse_flag;
 
        /* desc type, used by the ring user to mark the type of the priv data */
 	u16 type;
-- 
1.9.1

^ permalink raw reply related

* [Patch net 2/4] net: hns: modify variable type in hns_nic_reuse_page
From: Huazhong Tan @ 2018-08-23  3:10 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong
In-Reply-To: <1534993813-236850-1-git-send-email-tanhuazhong@huawei.com>

'truesize' is supposed to be u32, not int, so fix it.

Signed-off-by: Huazhong tan <tanhuazhong@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 9f2b552..c8c0b03 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -512,7 +512,8 @@ static void hns_nic_reuse_page(struct sk_buff *skb, int i,
 			       struct hnae_desc_cb *desc_cb)
 {
 	struct hnae_desc *desc;
-	int truesize, size;
+	u32 truesize;
+	int size;
 	int last_offset;
 	bool twobufs;
 
-- 
1.9.1

^ permalink raw reply related

* [Patch net 4/4] net: hns: use eth_get_headlen interface instead of hns_nic_get_headlen
From: Huazhong Tan @ 2018-08-23  3:10 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong
In-Reply-To: <1534993813-236850-1-git-send-email-tanhuazhong@huawei.com>

Update hns to drop the hns_nic_get_headlen function in favour of
eth_get_headlen, and hence also removes now redundant hns_nic_get_headlen.

Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 103 +-------------------------
 1 file changed, 1 insertion(+), 102 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index 71bd3bf..02a0ba2 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -406,107 +406,6 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
 	return NETDEV_TX_BUSY;
 }
 
-/**
- * hns_nic_get_headlen - determine size of header for RSC/LRO/GRO/FCOE
- * @data: pointer to the start of the headers
- * @max: total length of section to find headers in
- *
- * This function is meant to determine the length of headers that will
- * be recognized by hardware for LRO, GRO, and RSC offloads.  The main
- * motivation of doing this is to only perform one pull for IPv4 TCP
- * packets so that we can do basic things like calculating the gso_size
- * based on the average data per packet.
- **/
-static unsigned int hns_nic_get_headlen(unsigned char *data, u32 flag,
-					unsigned int max_size)
-{
-	unsigned char *network;
-	u8 hlen;
-
-	/* this should never happen, but better safe than sorry */
-	if (max_size < ETH_HLEN)
-		return max_size;
-
-	/* initialize network frame pointer */
-	network = data;
-
-	/* set first protocol and move network header forward */
-	network += ETH_HLEN;
-
-	/* handle any vlan tag if present */
-	if (hnae_get_field(flag, HNS_RXD_VLAN_M, HNS_RXD_VLAN_S)
-		== HNS_RX_FLAG_VLAN_PRESENT) {
-		if ((typeof(max_size))(network - data) > (max_size - VLAN_HLEN))
-			return max_size;
-
-		network += VLAN_HLEN;
-	}
-
-	/* handle L3 protocols */
-	if (hnae_get_field(flag, HNS_RXD_L3ID_M, HNS_RXD_L3ID_S)
-		== HNS_RX_FLAG_L3ID_IPV4) {
-		if ((typeof(max_size))(network - data) >
-		    (max_size - sizeof(struct iphdr)))
-			return max_size;
-
-		/* access ihl as a u8 to avoid unaligned access on ia64 */
-		hlen = (network[0] & 0x0F) << 2;
-
-		/* verify hlen meets minimum size requirements */
-		if (hlen < sizeof(struct iphdr))
-			return network - data;
-
-		/* record next protocol if header is present */
-	} else if (hnae_get_field(flag, HNS_RXD_L3ID_M, HNS_RXD_L3ID_S)
-		== HNS_RX_FLAG_L3ID_IPV6) {
-		if ((typeof(max_size))(network - data) >
-		    (max_size - sizeof(struct ipv6hdr)))
-			return max_size;
-
-		/* record next protocol */
-		hlen = sizeof(struct ipv6hdr);
-	} else {
-		return network - data;
-	}
-
-	/* relocate pointer to start of L4 header */
-	network += hlen;
-
-	/* finally sort out TCP/UDP */
-	if (hnae_get_field(flag, HNS_RXD_L4ID_M, HNS_RXD_L4ID_S)
-		== HNS_RX_FLAG_L4ID_TCP) {
-		if ((typeof(max_size))(network - data) >
-		    (max_size - sizeof(struct tcphdr)))
-			return max_size;
-
-		/* access doff as a u8 to avoid unaligned access on ia64 */
-		hlen = (network[12] & 0xF0) >> 2;
-
-		/* verify hlen meets minimum size requirements */
-		if (hlen < sizeof(struct tcphdr))
-			return network - data;
-
-		network += hlen;
-	} else if (hnae_get_field(flag, HNS_RXD_L4ID_M, HNS_RXD_L4ID_S)
-		== HNS_RX_FLAG_L4ID_UDP) {
-		if ((typeof(max_size))(network - data) >
-		    (max_size - sizeof(struct udphdr)))
-			return max_size;
-
-		network += sizeof(struct udphdr);
-	}
-
-	/* If everything has gone correctly network should be the
-	 * data section of the packet and will be the end of the header.
-	 * If not then it probably represents the end of the last recognized
-	 * header.
-	 */
-	if ((typeof(max_size))(network - data) < max_size)
-		return network - data;
-	else
-		return max_size;
-}
-
 static void hns_nic_reuse_page(struct sk_buff *skb, int i,
 			       struct hnae_ring *ring, int pull_len,
 			       struct hnae_desc_cb *desc_cb)
@@ -696,7 +595,7 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
 	} else {
 		ring->stats.seg_pkt_cnt++;
 
-		pull_len = hns_nic_get_headlen(va, bnum_flag, HNS_RX_HEAD_SIZE);
+		pull_len = eth_get_headlen(va, HNS_RX_HEAD_SIZE);
 		memcpy(__skb_put(skb, pull_len), va,
 		       ALIGN(pull_len, sizeof(long)));
 
-- 
1.9.1

^ permalink raw reply related

* [Patch net 0/4] net: hns: bug fixes & optimization for HNS driver
From: Huazhong Tan @ 2018-08-23  3:10 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong

This patchset presents some bug fixes found out when CONFIG_ARM64_64K_PAGES
enable and an optimization for HNS driver.

Huazhong Tan (4):
  net: hns: fix length and page_offset overflow when
    CONFIG_ARM64_64K_PAGES
  net: hns: modify variable type in hns_nic_reuse_page
  net: hns: fix skb->truesize underestimation
  net: hns: use eth_get_headlen interface instead of hns_nic_get_headlen

 drivers/net/ethernet/hisilicon/hns/hnae.h     |   6 +-
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 108 +-------------------------
 2 files changed, 7 insertions(+), 107 deletions(-)

-- 
1.9.1

^ permalink raw reply

* [Patch net 3/4] net: hns: fix skb->truesize underestimation
From: Huazhong Tan @ 2018-08-23  3:10 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong
In-Reply-To: <1534993813-236850-1-git-send-email-tanhuazhong@huawei.com>

skb->truesize is not meant to be tracking amount of used bytes in a skb,
but amount of reserved/consumed bytes in memory.

For instance, if we use a single byte in last page fragment, we have to
account the full size of the fragment.

So skb_add_rx_frag needs to calculate the length of the entire buffer into
turesize.

Fixes: 9cbe9fd5214e ("net: hns: optimize XGE capability by reducing cpu usage")
Signed-off-by: Huazhong tan <tanhuazhong@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns/hns_enet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
index c8c0b03..71bd3bf 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c
@@ -531,7 +531,7 @@ static void hns_nic_reuse_page(struct sk_buff *skb, int i,
 	}
 
 	skb_add_rx_frag(skb, i, desc_cb->priv, desc_cb->page_offset + pull_len,
-			size - pull_len, truesize - pull_len);
+			size - pull_len, truesize);
 
 	 /* avoid re-using remote pages,flag default unreuse */
 	if (unlikely(page_to_nid(desc_cb->priv) != numa_node_id()))
-- 
1.9.1

^ permalink raw reply related

* [PATCH] net/ipv6: init ip6 anycast rt->dst.input as ip6_input
From: Hangbin Liu @ 2018-08-23  3:31 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern, David S. Miller, Hangbin Liu

Commit 6edb3c96a5f02 ("net/ipv6: Defer initialization of dst to data path")
forgot to handle anycast route and init anycast rt->dst.input to ip6_forward.
Fix it by setting anycast rt->dst.input back to ip6_input.

Fixes: 6edb3c96a5f02 ("net/ipv6: Defer initialization of dst to data path")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 net/ipv6/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 7208c16..c4ea13e 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -956,7 +956,7 @@ static void ip6_rt_init_dst(struct rt6_info *rt, struct fib6_info *ort)
 	rt->dst.error = 0;
 	rt->dst.output = ip6_output;
 
-	if (ort->fib6_type == RTN_LOCAL) {
+	if (ort->fib6_type == RTN_LOCAL || ort->fib6_type == RTN_ANYCAST) {
 		rt->dst.input = ip6_input;
 	} else if (ipv6_addr_type(&ort->fib6_dst.addr) & IPV6_ADDR_MULTICAST) {
 		rt->dst.input = ip6_mc_input;
-- 
2.5.5

^ permalink raw reply related

* [Patch net 2/2] net: hns3: modify variable type in hns3_nic_reuse_page
From: Huazhong Tan @ 2018-08-23  3:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong
In-Reply-To: <1534995436-25259-1-git-send-email-tanhuazhong@huawei.com>

'truesize' is supposed to be u32, not int, so fix it.

Signed-off-by: Huazhong tan <tanhuazhong@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
index 3554dca..955c4ab 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
@@ -2019,7 +2019,8 @@ static void hns3_nic_reuse_page(struct sk_buff *skb, int i,
 				struct hns3_desc_cb *desc_cb)
 {
 	struct hns3_desc *desc;
-	int truesize, size;
+	u32 truesize;
+	int size;
 	int last_offset;
 	bool twobufs;
 
-- 
1.9.1

^ permalink raw reply related

* [Patch net 1/2] net: hns3: fix page_offset overflow when CONFIG_ARM64_64K_PAGES
From: Huazhong Tan @ 2018-08-23  3:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong
In-Reply-To: <1534995436-25259-1-git-send-email-tanhuazhong@huawei.com>

When enable the config item "CONFIG_ARM64_64K_PAGES", the size of
PAGE_SIZE is 65536(64K). But the type of page_offset is u16, it will
overflow. So change it to u32, when "CONFIG_ARM64_64K_PAGES" enabled.

Fixes: 76ad4f0ee747 ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: Salil Mehta <salil.mehta@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
index a02a96a..cb450d7 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h
@@ -284,11 +284,11 @@ struct hns3_desc_cb {
 
 	/* priv data for the desc, e.g. skb when use with ip stack*/
 	void *priv;
-	u16 page_offset;
-	u16 reuse_flag;
-
+	u32 page_offset;
 	u32 length;     /* length of the buffer */
 
+	u16 reuse_flag;
+
        /* desc type, used by the ring user to mark the type of the priv data */
 	u16 type;
 };
-- 
1.9.1

^ permalink raw reply related

* [Patch net 0/2] net: hns3: bug fix & optimization for HNS3 driver
From: Huazhong Tan @ 2018-08-23  3:37 UTC (permalink / raw)
  To: davem; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321,
	tanhuazhong

This patchset presents a bug fix found out when CONFIG_ARM64_64K_PAGES
enable and an optimization for HNS3 driver.

Huazhong Tan (2):
  net: hns3: fix page_offset overflow when CONFIG_ARM64_64K_PAGES
  net: hns3: modify variable type in hns3_nic_reuse_page

 drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 3 ++-
 drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 6 +++---
 2 files changed, 5 insertions(+), 4 deletions(-)

-- 
1.9.1

^ permalink raw reply

* Re: [PATCH] net/ipv6: init ip6 anycast rt->dst.input as ip6_input
From: David Ahern @ 2018-08-23  3:39 UTC (permalink / raw)
  To: Hangbin Liu, netdev; +Cc: David S. Miller
In-Reply-To: <1534995097-6189-1-git-send-email-liuhangbin@gmail.com>

On 8/22/18 9:31 PM, Hangbin Liu wrote:
> Commit 6edb3c96a5f02 ("net/ipv6: Defer initialization of dst to data path")
> forgot to handle anycast route and init anycast rt->dst.input to ip6_forward.
> Fix it by setting anycast rt->dst.input back to ip6_input.
> 
> Fixes: 6edb3c96a5f02 ("net/ipv6: Defer initialization of dst to data path")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
> ---
>  net/ipv6/route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Good catch.

Reviewed-by: David Ahern <dsahern@gmail.com>

^ permalink raw reply

* Re: WARNING in refcount_inc (3)
From: Eric Biggers @ 2018-08-23  7:24 UTC (permalink / raw)
  To: syzbot; +Cc: davem, kuznet, linux-kernel, netdev, syzkaller-bugs, yoshfuji
In-Reply-To: <20180419224509.GB13221@gmail.com>

On Thu, Apr 19, 2018 at 03:45:09PM -0700, Eric Biggers wrote:
> On Sat, Mar 31, 2018 at 04:01:02PM -0700, syzbot wrote:
> > Hello,
> > 
> > syzbot hit the following crash on bpf-next commit
> > 1379ef828a18d8f81c526b25e4d5685caa2cfd65 (Thu Mar 29 22:09:44 2018 +0000)
> > Merge branch 'bpf-sockmap-ingress'
> > syzbot dashboard link:
> > https://syzkaller.appspot.com/bug?extid=6eaf536fd743f5e119c5
> > 
> > So far this crash happened 6 times on bpf-next.
> > C reproducer: https://syzkaller.appspot.com/x/repro.c?id=6614614900998144
> > syzkaller reproducer:
> > https://syzkaller.appspot.com/x/repro.syz?id=5035340528091136
> > Raw console output:
> > https://syzkaller.appspot.com/x/log.txt?id=5063394046509056
> > Kernel config:
> > https://syzkaller.appspot.com/x/.config?id=-1280663959502969741
> > compiler: gcc (GCC) 7.1.1 20170620
> > 
> > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > Reported-by: syzbot+6eaf536fd743f5e119c5@syzkaller.appspotmail.com
> > It will help syzbot understand when the bug is fixed. See footer for
> > details.
> > If you forward the report, please keep this part and the footer.
> > 
> > R13: 0000000000000005 R14: 0000000000001380 R15: 00007ffd314c8768
> > ------------[ cut here ]------------
> > ------------[ cut here ]------------
> > refcount_t: increment on 0; use-after-free.
> > refcount_t: underflow; use-after-free.
> > WARNING: CPU: 1 PID: 4434 at lib/refcount.c:153 refcount_inc+0x47/0x50
> > lib/refcount.c:153
> > WARNING: CPU: 0 PID: 4437 at lib/refcount.c:187
> > refcount_sub_and_test+0x167/0x1b0 lib/refcount.c:187
> > Kernel panic - not syncing: panic_on_warn set ...
> > 
> > Modules linked in:
> > CPU: 1 PID: 4434 Comm: syzkaller349430 Not tainted 4.16.0-rc6+ #41
> > CPU: 0 PID: 4437 Comm: syzkaller349430 Not tainted 4.16.0-rc6+ #41
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> > Google 01/01/2011
> > RIP: 0010:refcount_sub_and_test+0x167/0x1b0 lib/refcount.c:187
> > Call Trace:
> > RSP: 0018:ffff8801b061f728 EFLAGS: 00010286
> >  __dump_stack lib/dump_stack.c:17 [inline]
> >  dump_stack+0x194/0x24d lib/dump_stack.c:53
> > RAX: dffffc0000000008 RBX: 0000000000000000 RCX: ffffffff815ba4be
> > RDX: 0000000000000000 RSI: 1ffff100360c3e95 RDI: 1ffff100360c3e6a
> > RBP: ffff8801b061f7b8 R08: 0000000000000000 R09: 0000000000000000
> > R10: ffff8801b061f850 R11: 0000000000000000 R12: 1ffff100360c3ee6
> >  panic+0x1e4/0x41c kernel/panic.c:183
> > R13: 00000000ffffffff R14: 0000000000000001 R15: ffff8801b1be4184
> > FS:  0000000001817880(0000) GS:ffff8801db200000(0000) knlGS:0000000000000000
> > CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > CR2: 00007ffd314c9000 CR3: 00000001b04a1006 CR4: 00000000001606f0
> > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> > Call Trace:
> >  __warn+0x1dc/0x200 kernel/panic.c:547
> >  report_bug+0x1f4/0x2b0 lib/bug.c:186
> >  fixup_bug.part.11+0x37/0x80 arch/x86/kernel/traps.c:178
> >  fixup_bug arch/x86/kernel/traps.c:247 [inline]
> >  do_error_trap+0x2d7/0x3e0 arch/x86/kernel/traps.c:296
> >  refcount_dec_and_test+0x1a/0x20 lib/refcount.c:212
> >  put_net include/net/net_namespace.h:222 [inline]
> >  __sk_destruct+0x560/0x920 net/core/sock.c:1592
> >  do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315
> >  invalid_op+0x1b/0x40 arch/x86/entry/entry_64.S:986
> > RIP: 0010:refcount_inc+0x47/0x50 lib/refcount.c:153
> > RSP: 0018:ffff8801b058f860 EFLAGS: 00010286
> > RAX: dffffc0000000008 RBX: ffff8801ab55a1c4 RCX: ffffffff815ba4be
> > RDX: 0000000000000000 RSI: 1ffff100360b1ebc RDI: 1ffff100360b1e91
> > RBP: ffff8801b058f868 R08: 0000000000000000 R09: 0000000000000000
> >  sk_destruct+0x47/0x80 net/core/sock.c:1601
> > R10: 0000000000000000 R11: 0000000000000000 R12: ffff8801b058faf8
> >  __sk_free+0xf1/0x2b0 net/core/sock.c:1612
> > R13: ffff8801af87b513 R14: ffff8801ab55a1c0 R15: ffff8801af87b501
> >  sk_free+0x2a/0x40 net/core/sock.c:1623
> >  sock_put include/net/sock.h:1661 [inline]
> >  tcp_close+0x967/0x1190 net/ipv4/tcp.c:2329
> >  get_net include/net/net_namespace.h:204 [inline]
> >  sk_alloc+0x3f9/0x1440 net/core/sock.c:1540
> >  inet_release+0xed/0x1c0 net/ipv4/af_inet.c:427
> >  sock_release+0x8d/0x1e0 net/socket.c:594
> >  sock_close+0x16/0x20 net/socket.c:1149
> >  __fput+0x327/0x7e0 fs/file_table.c:209
> >  ____fput+0x15/0x20 fs/file_table.c:243
> >  task_work_run+0x199/0x270 kernel/task_work.c:113
> >  inet_create+0x47c/0xf50 net/ipv4/af_inet.c:320
> >  tracehook_notify_resume include/linux/tracehook.h:191 [inline]
> >  exit_to_usermode_loop+0x275/0x2f0 arch/x86/entry/common.c:166
> >  __sock_create+0x4d4/0x850 net/socket.c:1285
> >  prepare_exit_to_usermode arch/x86/entry/common.c:196 [inline]
> >  syscall_return_slowpath arch/x86/entry/common.c:265 [inline]
> >  do_syscall_64+0x6ec/0x940 arch/x86/entry/common.c:292
> >  sock_create net/socket.c:1325 [inline]
> >  SYSC_socket net/socket.c:1355 [inline]
> >  SyS_socket+0xeb/0x1d0 net/socket.c:1335
> >  do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287
> >  entry_SYSCALL_64_after_hwframe+0x42/0xb7
> > RIP: 0033:0x402950
> > RSP: 002b:00007ffd314c8628 EFLAGS: 00000246
> >  ORIG_RAX: 0000000000000003
> > RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000402950
> > RDX: 00000000000000e0 RSI: 00007ffd314c8f00 RDI: 0000000000000003
> > RBP: 00007ffd314c8740 R08: 00007ffd314c864c R09: 0000000000000001
> > R10: 00007ffd314c8740 R11: 0000000000000246 R12: 00000000006cf4c0
> > R13: 00000000006cee40 R14: 0000000000001380 R15: 00007ffd314c8768
> > Code:
> >  entry_SYSCALL_64_after_hwframe+0x42/0xb7
> > 5e
> > RIP: 0033:0x4456a7
> > 41
> > RSP: 002b:00007ffd314c8628 EFLAGS: 00000202 ORIG_RAX: 0000000000000029
> > 5f
> > RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00000000004456a7
> > 5d
> > RDX: 0000000000000006 RSI: 0000000000000001 RDI: 0000000000000002
> > RBP: 00007ffd314c8740 R08: 0000000000000000 R09: 0000000000000001
> > c3
> > R10: 0000000000000006 R11: 0000000000000202 R12: 0000000000000003
> > e8
> > R13: 0000000000000003 R14: 0000000000006cc2 R15: 00007ffd314c8768
> > 0a 0b be fe 80 3d 20 c9 84 05 00 75 1a e8 fc 0a be fe 48 c7 c7 e0 78 e5 86
> > c6 05 0b c9 84 05 01 e8 a9 16 8e fe <0f> 0b 31 db eb a3 e8 de 0a be fe 83 fb
> > ff 0f 85 63 ff ff ff 31
> > ---[ end trace dd327356f543ce46 ]---
> > Dumping ftrace buffer:
> >    (ftrace buffer empty)
> > Kernel Offset: disabled
> > Rebooting in 86400 seconds..
> > 
> > 
> > ---
> > This bug is generated by a dumb bot. It may contain errors.
> > See https://goo.gl/tpsmEJ for details.
> > Direct all questions to syzkaller@googlegroups.com.
> > 
> > syzbot will keep track of this bug report.
> > If you forgot to add the Reported-by tag, once the fix for this bug is
> > merged
> > into any tree, please reply to this email with:
> > #syz fix: exact-commit-title
> 
> Broken error handling when mounting rpc_pipefs is messing things up.
> Fixed by patch in vfs/for-linus:
> 
> #syz fix: rpc_pipefs: deal with early sget() failures
> 

Correction: the patch I mentioned above was dropped, and the fix for this that
actually went upstream was commit 8e04944f0ea8b83:

#syz fix: mm,vmscan: Allow preallocating memory for register_shrinker().

- Eric

^ permalink raw reply

* [PATCH 4.4 60/79] net/ethernet/freescale/fman: fix cross-build error
From: Greg Kroah-Hartman @ 2018-08-23  7:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Randy Dunlap, Madalin Bucur, netdev,
	linuxppc-dev, David S. Miller, Sasha Levin
In-Reply-To: <20180823074918.641878835@linuxfoundation.org>

4.4-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit c133459765fae249ba482f62e12f987aec4376f0 ]

  CC [M]  drivers/net/ethernet/freescale/fman/fman.o
In file included from ../drivers/net/ethernet/freescale/fman/fman.c:35:
../include/linux/fsl/guts.h: In function 'guts_set_dmacr':
../include/linux/fsl/guts.h:165:2: error: implicit declaration of function 'clrsetbits_be32' [-Werror=implicit-function-declaration]
  clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift);
  ^~~~~~~~~~~~~~~

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Madalin Bucur <madalin.bucur@nxp.com>
Cc: netdev@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/fsl/guts.h |    1 +
 1 file changed, 1 insertion(+)

--- a/include/linux/fsl/guts.h
+++ b/include/linux/fsl/guts.h
@@ -16,6 +16,7 @@
 #define __FSL_GUTS_H__
 
 #include <linux/types.h>
+#include <linux/io.h>
 
 /**
  * Global Utility Registers.

^ permalink raw reply

* [PATCH 4.9 110/130] net/ethernet/freescale/fman: fix cross-build error
From: Greg Kroah-Hartman @ 2018-08-23  7:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Randy Dunlap, Madalin Bucur, netdev,
	linuxppc-dev, David S. Miller, Sasha Levin
In-Reply-To: <20180823074927.161454870@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit c133459765fae249ba482f62e12f987aec4376f0 ]

  CC [M]  drivers/net/ethernet/freescale/fman/fman.o
In file included from ../drivers/net/ethernet/freescale/fman/fman.c:35:
../include/linux/fsl/guts.h: In function 'guts_set_dmacr':
../include/linux/fsl/guts.h:165:2: error: implicit declaration of function 'clrsetbits_be32' [-Werror=implicit-function-declaration]
  clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift);
  ^~~~~~~~~~~~~~~

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Madalin Bucur <madalin.bucur@nxp.com>
Cc: netdev@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/fsl/guts.h |    1 +
 1 file changed, 1 insertion(+)

--- a/include/linux/fsl/guts.h
+++ b/include/linux/fsl/guts.h
@@ -16,6 +16,7 @@
 #define __FSL_GUTS_H__
 
 #include <linux/types.h>
+#include <linux/io.h>
 
 /**
  * Global Utility Registers.

^ permalink raw reply

* [PATCH 4.14 186/217] net/ethernet/freescale/fman: fix cross-build error
From: Greg Kroah-Hartman @ 2018-08-23  7:54 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Randy Dunlap, Madalin Bucur, netdev,
	linuxppc-dev, David S. Miller, Sasha Levin
In-Reply-To: <20180823075505.090246914@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit c133459765fae249ba482f62e12f987aec4376f0 ]

  CC [M]  drivers/net/ethernet/freescale/fman/fman.o
In file included from ../drivers/net/ethernet/freescale/fman/fman.c:35:
../include/linux/fsl/guts.h: In function 'guts_set_dmacr':
../include/linux/fsl/guts.h:165:2: error: implicit declaration of function 'clrsetbits_be32' [-Werror=implicit-function-declaration]
  clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift);
  ^~~~~~~~~~~~~~~

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Madalin Bucur <madalin.bucur@nxp.com>
Cc: netdev@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/fsl/guts.h |    1 +
 1 file changed, 1 insertion(+)

--- a/include/linux/fsl/guts.h
+++ b/include/linux/fsl/guts.h
@@ -16,6 +16,7 @@
 #define __FSL_GUTS_H__
 
 #include <linux/types.h>
+#include <linux/io.h>
 
 /**
  * Global Utility Registers.

^ permalink raw reply

* [PATCH 4.17 271/324] net/ethernet/freescale/fman: fix cross-build error
From: Greg Kroah-Hartman @ 2018-08-23  7:55 UTC (permalink / raw)
  To: linux-kernel
  Cc: Greg Kroah-Hartman, stable, Randy Dunlap, Madalin Bucur, netdev,
	linuxppc-dev, David S. Miller, Sasha Levin
In-Reply-To: <20180823074955.885811006@linuxfoundation.org>

4.17-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Randy Dunlap <rdunlap@infradead.org>

[ Upstream commit c133459765fae249ba482f62e12f987aec4376f0 ]

  CC [M]  drivers/net/ethernet/freescale/fman/fman.o
In file included from ../drivers/net/ethernet/freescale/fman/fman.c:35:
../include/linux/fsl/guts.h: In function 'guts_set_dmacr':
../include/linux/fsl/guts.h:165:2: error: implicit declaration of function 'clrsetbits_be32' [-Werror=implicit-function-declaration]
  clrsetbits_be32(&guts->dmacr, 3 << shift, device << shift);
  ^~~~~~~~~~~~~~~

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Madalin Bucur <madalin.bucur@nxp.com>
Cc: netdev@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/fsl/guts.h |    1 +
 1 file changed, 1 insertion(+)

--- a/include/linux/fsl/guts.h
+++ b/include/linux/fsl/guts.h
@@ -16,6 +16,7 @@
 #define __FSL_GUTS_H__
 
 #include <linux/types.h>
+#include <linux/io.h>
 
 /**
  * Global Utility Registers.

^ permalink raw reply

* Re: [PATCH] sch_cake: Fix TC filter flow override and expand it to hosts as well
From: David Miller @ 2018-08-23  4:40 UTC (permalink / raw)
  To: toke; +Cc: netdev, cake
In-Reply-To: <153493378299.2819.2335994387383507473.stgit@alrua-kau>

From: Toke Høiland-Jørgensen <toke@toke.dk>
Date: Wed, 22 Aug 2018 12:29:43 +0200

> The TC filter flow mapping override completely skipped the call to
> cake_hash(); however that meant that the internal state was not being
> updated, which ultimately leads to deadlocks in some configurations. Fix
> that by passing the overridden flow ID into cake_hash() instead so it can
> react appropriately.
> 
> In addition, the major number of the class ID can now be set to override
> the host mapping in host isolation mode. If both host and flow are
> overridden (or if the respective modes are disabled), flow dissection and
> hashing will be skipped entirely; otherwise, the hashing will be kept for
> the portions that are not set by the filter.
> 
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>

Applied.

^ permalink raw reply

* Re: [PATCH] net_sched: fix unused variable warning in stmmac
From: David Miller @ 2018-08-23  4:40 UTC (permalink / raw)
  To: arnd
  Cc: jhs, xiyou.wangcong, jiri, jakub.kicinski, simon.horman, nogahf,
	aring, john.hurley, netdev, linux-kernel
In-Reply-To: <20180822152608.4173947-1-arnd@arndb.de>

From: Arnd Bergmann <arnd@arndb.de>
Date: Wed, 22 Aug 2018 17:25:44 +0200

> The new tcf_exts_for_each_action() macro doesn't reference its
> arguments when CONFIG_NET_CLS_ACT is disabled, which leads to
> a harmless warning in at least one driver:
> 
> drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c: In function 'tc_fill_actions':
> drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c:64:6: error: unused variable 'i' [-Werror=unused-variable]
> 
> Adding a cast to void lets us avoid this kind of warning.
> To be on the safe side, do it for all three arguments, not
> just the one that caused the warning.
> 
> Fixes: 244cd96adb5f ("net_sched: remove list_head from tc_action")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks Arnd.

^ permalink raw reply

* Re: [Patch net] addrconf: reduce unnecessary atomic allocations
From: David Miller @ 2018-08-23  4:42 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, dsahern
In-Reply-To: <20180822195834.7217-1-xiyou.wangcong@gmail.com>

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Wed, 22 Aug 2018 12:58:34 -0700

> All the 3 callers of addrconf_add_mroute() assert RTNL
> lock, they don't take any additional lock either, so
> it is safe to convert it to GFP_KERNEL.
> 
> Same for sit_add_v4_addrs().
> 
> Cc: David Ahern <dsahern@gmail.com>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Applied.

^ permalink raw reply

* Re: [PATCH net] ipv4: tcp: send zero IPID for RST and ACK sent in SYN-RECV and TIME-WAIT state
From: David Miller @ 2018-08-23  4:43 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, alexandg, eric.dumazet
In-Reply-To: <20180822203045.76928-1-edumazet@google.com>

From: Eric Dumazet <edumazet@google.com>
Date: Wed, 22 Aug 2018 13:30:45 -0700

> tcp uses per-cpu (and per namespace) sockets (net->ipv4.tcp_sk) internally
> to send some control packets.
> 
> 1) RST packets, through tcp_v4_send_reset()
> 2) ACK packets in SYN-RECV and TIME-WAIT state, through tcp_v4_send_ack()
> 
> These packets assert IP_DF, and also use the hashed IP ident generator
> to provide an IPv4 ID number.
> 
> Geoff Alexander reported this could be used to build off-path attacks.
> 
> These packets should not be fragmented, since their size is smaller than
> IPV4_MIN_MTU. Only some tunneled paths could eventually have to fragment,
> regardless of inner IPID.
> 
> We really can use zero IPID, to address the flaw, and as a bonus,
> avoid a couple of atomic operations in ip_idents_reserve()
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Reported-by: Geoff Alexander <alexandg@cs.unm.edu>
> Tested-by: Geoff Alexander <alexandg@cs.unm.edu>

Applied and queued up for -stable.

^ permalink raw reply

* Re: [PATCH net 0/3] tcp_bbr: PROBE_RTT minor bug fixes
From: David Miller @ 2018-08-23  4:45 UTC (permalink / raw)
  To: yyd; +Cc: netdev
In-Reply-To: <20180822214316.174161-1-yyd@google.com>

From: Kevin Yang <yyd@google.com>
Date: Wed, 22 Aug 2018 17:43:13 -0400

> From: "Kevin(Yudong) Yang" <yyd@google.com>
> 
> This series includes two minor bug fixes for the TCP BBR PROBE_RTT
> mechanism, and one preparatory patch:
> 
> (1) A preparatory patch to reorganize the PROBE_RTT logic by refactoring
>     (into its own function) the code to exit PROBE_RTT, since the next
>     patch will be using that code in a new context.
> 
> (2) Fix: When BBR restarts from idle and if BBR is in PROBE_RTT mode,
>     BBR should check if it's time to exit PROBE_RTT. If yes, then BBR
>     should exit PROBE_RTT mode and restore the cwnd to its full value.
> 
> (3) Fix: Apply the PROBE_RTT cwnd cap even if the count of fully-ACKed
>     packets is 0.

Series applied, thank you.

^ permalink raw reply

* Re: [Patch net 0/4] net: hns: bug fixes & optimization for HNS driver
From: David Miller @ 2018-08-23  4:48 UTC (permalink / raw)
  To: tanhuazhong; +Cc: netdev, linuxarm, salil.mehta, yisen.zhuang, lipeng321
In-Reply-To: <1534993813-236850-1-git-send-email-tanhuazhong@huawei.com>

From: Huazhong Tan <tanhuazhong@huawei.com>
Date: Thu, 23 Aug 2018 11:10:09 +0800

> This patchset presents some bug fixes found out when
> CONFIG_ARM64_64K_PAGES enable and an optimization for HNS driver.

Series applied, thank you.

^ permalink raw reply

* Re: [PATCH] net/ipv6: init ip6 anycast rt->dst.input as ip6_input
From: David Miller @ 2018-08-23  4:53 UTC (permalink / raw)
  To: liuhangbin; +Cc: netdev, dsahern
In-Reply-To: <1534995097-6189-1-git-send-email-liuhangbin@gmail.com>

From: Hangbin Liu <liuhangbin@gmail.com>
Date: Thu, 23 Aug 2018 11:31:37 +0800

> Commit 6edb3c96a5f02 ("net/ipv6: Defer initialization of dst to data path")
> forgot to handle anycast route and init anycast rt->dst.input to ip6_forward.
> Fix it by setting anycast rt->dst.input back to ip6_input.
> 
> Fixes: 6edb3c96a5f02 ("net/ipv6: Defer initialization of dst to data path")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply

* Re: [PATCH net-next] ieee802154: Use kmemdup instead of duplicating it in ca8210_test_int_driver_write
From: Stefan Schmidt @ 2018-08-23  8:31 UTC (permalink / raw)
  To: YueHaibing, davem, h.morris, alex.aring; +Cc: linux-kernel, netdev, linux-wpan
In-Reply-To: <20180809064429.13348-1-yuehaibing@huawei.com>

Hello.

On 08/09/2018 08:44 AM, YueHaibing wrote:
> Replace calls to kmalloc followed by a memcpy with a direct call to
> kmemdup.
> 
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/net/ieee802154/ca8210.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c
> index 58299fb..e21279d 100644
> --- a/drivers/net/ieee802154/ca8210.c
> +++ b/drivers/net/ieee802154/ca8210.c
> @@ -634,10 +634,9 @@ static int ca8210_test_int_driver_write(
>  	for (i = 0; i < len; i++)
>  		dev_dbg(&priv->spi->dev, "%#03x\n", buf[i]);
>  
> -	fifo_buffer = kmalloc(len, GFP_KERNEL);
> +	fifo_buffer = kmemdup(buf, len, GFP_KERNEL);
>  	if (!fifo_buffer)
>  		return -ENOMEM;
> -	memcpy(fifo_buffer, buf, len);
>  	kfifo_in(&test->up_fifo, &fifo_buffer, 4);
>  	wake_up_interruptible(&priv->test.readq);
>  


This patch has been applied to the wpan tree and will be
part of the next pull request to net. Thanks!

regards
Stefan Schmidt

^ permalink raw reply

* Re: [PATCH bpf] bpf: use per htab salt for bucket hash
From: Song Liu @ 2018-08-23  5:06 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: Alexei Starovoitov, Networking
In-Reply-To: <3d91bc248da2fb1d2a88bcaa75d1b2d2da936986.1534974407.git.daniel@iogearbox.net>

On Wed, Aug 22, 2018 at 2:49 PM, Daniel Borkmann <daniel@iogearbox.net> wrote:
> All BPF hash and LRU maps currently have a known and global seed
> we feed into jhash() which is 0. This is suboptimal, thus fix it
> by generating a random seed upon hashtab setup time which we can
> later on feed into jhash() on lookup, update and deletions.
>
> Fixes: 0f8e4bd8a1fc8 ("bpf: add hashtable type of eBPF maps")
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Acked-by: Alexei Starovoitov <ast@kernel.org>

Acked-by: Song Liu <songliubraving@fb.com>

> ---
>  kernel/bpf/hashtab.c | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/kernel/bpf/hashtab.c b/kernel/bpf/hashtab.c
> index 04b8eda..03cc59e 100644
> --- a/kernel/bpf/hashtab.c
> +++ b/kernel/bpf/hashtab.c
> @@ -15,6 +15,7 @@
>  #include <linux/jhash.h>
>  #include <linux/filter.h>
>  #include <linux/rculist_nulls.h>
> +#include <linux/random.h>
>  #include <uapi/linux/btf.h>
>  #include "percpu_freelist.h"
>  #include "bpf_lru_list.h"
> @@ -41,6 +42,7 @@ struct bpf_htab {
>         atomic_t count; /* number of elements in this hashtable */
>         u32 n_buckets;  /* number of hash buckets */
>         u32 elem_size;  /* size of each element in bytes */
> +       u32 hashrnd;
>  };
>
>  /* each htab element is struct htab_elem + key + value */
> @@ -371,6 +373,7 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
>         if (!htab->buckets)
>                 goto free_htab;
>
> +       htab->hashrnd = get_random_int();
>         for (i = 0; i < htab->n_buckets; i++) {
>                 INIT_HLIST_NULLS_HEAD(&htab->buckets[i].head, i);
>                 raw_spin_lock_init(&htab->buckets[i].lock);
> @@ -402,9 +405,9 @@ static struct bpf_map *htab_map_alloc(union bpf_attr *attr)
>         return ERR_PTR(err);
>  }
>
> -static inline u32 htab_map_hash(const void *key, u32 key_len)
> +static inline u32 htab_map_hash(const void *key, u32 key_len, u32 hashrnd)
>  {
> -       return jhash(key, key_len, 0);
> +       return jhash(key, key_len, hashrnd);
>  }
>
>  static inline struct bucket *__select_bucket(struct bpf_htab *htab, u32 hash)
> @@ -470,7 +473,7 @@ static void *__htab_map_lookup_elem(struct bpf_map *map, void *key)
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>
>         head = select_bucket(htab, hash);
>
> @@ -597,7 +600,7 @@ static int htab_map_get_next_key(struct bpf_map *map, void *key, void *next_key)
>         if (!key)
>                 goto find_first_elem;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>
>         head = select_bucket(htab, hash);
>
> @@ -824,7 +827,7 @@ static int htab_map_update_elem(struct bpf_map *map, void *key, void *value,
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>
>         b = __select_bucket(htab, hash);
>         head = &b->head;
> @@ -880,7 +883,7 @@ static int htab_lru_map_update_elem(struct bpf_map *map, void *key, void *value,
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>
>         b = __select_bucket(htab, hash);
>         head = &b->head;
> @@ -945,7 +948,7 @@ static int __htab_percpu_map_update_elem(struct bpf_map *map, void *key,
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>
>         b = __select_bucket(htab, hash);
>         head = &b->head;
> @@ -998,7 +1001,7 @@ static int __htab_lru_percpu_map_update_elem(struct bpf_map *map, void *key,
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>
>         b = __select_bucket(htab, hash);
>         head = &b->head;
> @@ -1071,7 +1074,7 @@ static int htab_map_delete_elem(struct bpf_map *map, void *key)
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>         b = __select_bucket(htab, hash);
>         head = &b->head;
>
> @@ -1103,7 +1106,7 @@ static int htab_lru_map_delete_elem(struct bpf_map *map, void *key)
>
>         key_size = map->key_size;
>
> -       hash = htab_map_hash(key, key_size);
> +       hash = htab_map_hash(key, key_size, htab->hashrnd);
>         b = __select_bucket(htab, hash);
>         head = &b->head;
>
> --
> 2.9.5
>

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox