Skip to contentSkip to conversation

tipc: block BH before using dst_cache

PATCH In review Eric Dumazet 6 participants 13 messages May 21, 2020 – May 23, 2020 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: block BH before using dst_cache

dst_cache_get() documents it must be used with BH disabled.

sysbot reported :

BUG: using smp_processor_id() in preemptible [00000000] code: /21697
caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
CPU: 0 PID: 21697 Comm:  Not tainted 5.7.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 check_preemption_disabled lib/smp_processor_id.c:47 [inline]
 debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57
 dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
 tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164
 tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244
 tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526
 tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331
 __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995
 tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003
 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
 genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
 ___sys_sendmsg+0x100/0x170 net/socket.c:2416
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45ca29
Fixes e9c1a793210f ("tipc: add dst_cache support for udp media")
Cc Xin Long <[email protected]>
Cc Jon Maloy <[email protected]>
---
 net/tipc/udp_media.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -1
index d6620ad535461a4d04ed5ba90569ce8b7df9f994..28a283f26a8dff24d613e6ed57e5e69d894dae66 100644
@@ -161,9 +161,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
 			 struct udp_bearer *ub, struct udp_media_addr *src,
 			 struct udp_media_addr *dst, struct dst_cache *cache)
 {
-	struct dst_entry *ndst = dst_cache_get(cache);
+	struct dst_entry *ndst;
 	int ttl, err = 0;
 
+	local_bh_disable();
+	ndst = dst_cache_get(cache);
 	if (dst->proto == htons(ETH_P_IP)) {
 		struct rtable *rt = (struct rtable *)ndst;
 
@@ -210,9 +212,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
 					   src->port, dst->port, false);
 #endif
 	}
+	local_bh_enable();
 	return err;
 
 tx_error:
+	local_bh_enable();
 	kfree_skb(skb);
 	return err;
 }
Signature · 1 line
2.27.0.rc0.183.gde8f92d652-goog
#1 lore raw
Quoted 2 lines · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().
have you checked other places where dst_cache_get() are used?

Quoted 77 lines

sysbot reported :

BUG: using smp_processor_id() in preemptible [00000000] code: /21697
caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
CPU: 0 PID: 21697 Comm:  Not tainted 5.7.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 check_preemption_disabled lib/smp_processor_id.c:47 [inline]
 debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57
 dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
 tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164
 tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244
 tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526
 tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331
 __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995
 tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003
 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
 genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
 ___sys_sendmsg+0x100/0x170 net/socket.c:2416
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45ca29
Fixes e9c1a793210f ("tipc: add dst_cache support for udp media")
Cc Xin Long <[email protected]>
Cc Jon Maloy <[email protected]>
---
 net/tipc/udp_media.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -2
index d6620ad535461a4d04ed5ba90569ce8b7df9f994..28a283f26a8dff24d613e6ed57e5e69d894dae66 100644
@@ -161,9 +161,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                         struct udp_bearer *ub, struct udp_media_addr *src,
                         struct udp_media_addr *dst, struct dst_cache *cache)
 {
-       struct dst_entry *ndst = dst_cache_get(cache);
+       struct dst_entry *ndst;
        int ttl, err = 0;
 
+       local_bh_disable();
+       ndst = dst_cache_get(cache);
        if (dst->proto == htons(ETH_P_IP)) {
                struct rtable *rt = (struct rtable *)ndst;
 
@@ -210,9 +212,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                                           src->port, dst->port, false);
 #endif
        }
+       local_bh_enable();
        return err;
 
 tx_error:
+       local_bh_enable();
        kfree_skb(skb);
        return err;
 }
--

2.27.0.rc0.183.gde8f92d652-goog

A message that is not in the archive (sent off-list or not yet received): CANn89i+x=xbXoKekC6bF_ZMBRMY_mkmuVbNSW3LcRncsiZGd_g@mail.gmail.com

#3 lore raw

Resend to the list in non HTML form

Quoted 103 lines · Eric Dumazet
Quoted 6 lines · Xin Long
Quoted 2 lines · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Quoted 2 lines

have you checked other places where dst_cache_get() are used?

Yes, other paths are fine.

Quoted 79 lines
Quoted 79 lines

sysbot reported :

BUG: using smp_processor_id() in preemptible [00000000] code: /21697
caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
CPU: 0 PID: 21697 Comm:  Not tainted 5.7.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 check_preemption_disabled lib/smp_processor_id.c:47 [inline]
 debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57
 dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
 tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164
 tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244
 tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526
 tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331
 __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995
 tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003
 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
 genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
 ___sys_sendmsg+0x100/0x170 net/socket.c:2416
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45ca29
Fixes e9c1a793210f ("tipc: add dst_cache support for udp media")
Cc Xin Long <[email protected]>
Cc Jon Maloy <[email protected]>
---
 net/tipc/udp_media.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -2
index d6620ad535461a4d04ed5ba90569ce8b7df9f994..28a283f26a8dff24d613e6ed57e5e69d894dae66 100644
@@ -161,9 +161,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                         struct udp_bearer *ub, struct udp_media_addr *src,
                         struct udp_media_addr *dst, struct dst_cache *cache)
 {
-       struct dst_entry *ndst = dst_cache_get(cache);
+       struct dst_entry *ndst;
        int ttl, err = 0;
 
+       local_bh_disable();
+       ndst = dst_cache_get(cache);
        if (dst->proto == htons(ETH_P_IP)) {
                struct rtable *rt = (struct rtable *)ndst;
 
@@ -210,9 +212,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                                           src->port, dst->port, false);
 #endif
        }
+       local_bh_enable();
        return err;
 
 tx_error:
+       local_bh_enable();
        kfree_skb(skb);
        return err;
 }
--

2.27.0.rc0.183.gde8f92d652-goog

#4 lore raw
Quoted 20 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 15 lines · Eric Dumazet
Quoted 6 lines · Xin Long
Quoted 2 lines · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Also add tipc-discussion and Jon to CC list.

Thanks.

Quoted 88 lines
Quoted 88 lines
Quoted 4 lines

have you checked other places where dst_cache_get() are used?

Yes, other paths are fine.

Quoted 79 lines
Quoted 79 lines

sysbot reported :

BUG: using smp_processor_id() in preemptible [00000000] code: /21697
caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
CPU: 0 PID: 21697 Comm:  Not tainted 5.7.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x188/0x20d lib/dump_stack.c:118
 check_preemption_disabled lib/smp_processor_id.c:47 [inline]
 debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57
 dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
 tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164
 tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244
 tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526
 tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331
 __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995
 tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003
 genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
 genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
 genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
 netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
 genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
 netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
 netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
 netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
 sock_sendmsg_nosec net/socket.c:652 [inline]
 sock_sendmsg+0xcf/0x120 net/socket.c:672
 ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
 ___sys_sendmsg+0x100/0x170 net/socket.c:2416
 __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
 do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
 entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45ca29
Fixes e9c1a793210f ("tipc: add dst_cache support for udp media")
Cc Xin Long <[email protected]>
Cc Jon Maloy <[email protected]>
---
 net/tipc/udp_media.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -2
index d6620ad535461a4d04ed5ba90569ce8b7df9f994..28a283f26a8dff24d613e6ed57e5e69d894dae66 100644
@@ -161,9 +161,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                         struct udp_bearer *ub, struct udp_media_addr *src,
                         struct udp_media_addr *dst, struct dst_cache *cache)
 {
-       struct dst_entry *ndst = dst_cache_get(cache);
+       struct dst_entry *ndst;
        int ttl, err = 0;
 
+       local_bh_disable();
+       ndst = dst_cache_get(cache);
        if (dst->proto == htons(ETH_P_IP)) {
                struct rtable *rt = (struct rtable *)ndst;
 
@@ -210,9 +212,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                                           src->port, dst->port, false);
 #endif
        }
+       local_bh_enable();
        return err;
 
 tx_error:
+       local_bh_enable();
        kfree_skb(skb);
        return err;
 }
--

2.27.0.rc0.183.gde8f92d652-goog

maintainer
#5 lore raw
Quoted 13 lines · Xin Long
Quoted 12 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 8 lines · Eric Dumazet
Quoted 4 lines · Xin Long
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Also add tipc-discussion and Jon to CC list.

The suggested solution will affect all bearers, not only UDP, so it is not a good. Is there anything preventing us from disabling preemtion inside the scope of the rcu lock?

///jon

Quoted 86 lines

Thanks.

Quoted 83 lines
Quoted 83 lines
Quoted 2 lines

have you checked other places where dst_cache_get() are used?

Yes, other paths are fine.

Quoted 77 lines
Quoted 77 lines

sysbot reported :

BUG: using smp_processor_id() in preemptible [00000000] code: /21697
caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
CPU: 0 PID: 21697 Comm:  Not tainted 5.7.0-rc6-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0x188/0x20d lib/dump_stack.c:118
  check_preemption_disabled lib/smp_processor_id.c:47 [inline]
  debug_smp_processor_id.cold+0x88/0x9b lib/smp_processor_id.c:57
  dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68
  tipc_udp_xmit.isra.0+0xb9/0xad0 net/tipc/udp_media.c:164
  tipc_udp_send_msg+0x3e6/0x490 net/tipc/udp_media.c:244
  tipc_bearer_xmit_skb+0x1de/0x3f0 net/tipc/bearer.c:526
  tipc_enable_bearer+0xb2f/0xd60 net/tipc/bearer.c:331
  __tipc_nl_bearer_enable+0x2bf/0x390 net/tipc/bearer.c:995
  tipc_nl_bearer_enable+0x1e/0x30 net/tipc/bearer.c:1003
  genl_family_rcv_msg_doit net/netlink/genetlink.c:673 [inline]
  genl_family_rcv_msg net/netlink/genetlink.c:718 [inline]
  genl_rcv_msg+0x627/0xdf0 net/netlink/genetlink.c:735
  netlink_rcv_skb+0x15a/0x410 net/netlink/af_netlink.c:2469
  genl_rcv+0x24/0x40 net/netlink/genetlink.c:746
  netlink_unicast_kernel net/netlink/af_netlink.c:1303 [inline]
  netlink_unicast+0x537/0x740 net/netlink/af_netlink.c:1329
  netlink_sendmsg+0x882/0xe10 net/netlink/af_netlink.c:1918
  sock_sendmsg_nosec net/socket.c:652 [inline]
  sock_sendmsg+0xcf/0x120 net/socket.c:672
  ____sys_sendmsg+0x6bf/0x7e0 net/socket.c:2362
  ___sys_sendmsg+0x100/0x170 net/socket.c:2416
  __sys_sendmsg+0xec/0x1b0 net/socket.c:2449
  do_syscall_64+0xf6/0x7d0 arch/x86/entry/common.c:295
  entry_SYSCALL_64_after_hwframe+0x49/0xb3
RIP: 0033:0x45ca29
Fixes e9c1a793210f ("tipc: add dst_cache support for udp media")
Cc Xin Long <[email protected]>
Cc Jon Maloy <[email protected]>
---
  net/tipc/udp_media.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
net/tipc/udp_media.c +5 -2
index d6620ad535461a4d04ed5ba90569ce8b7df9f994..28a283f26a8dff24d613e6ed57e5e69d894dae66 100644
@@ -161,9 +161,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                          struct udp_bearer *ub, struct udp_media_addr *src,
                          struct udp_media_addr *dst, struct dst_cache *cache)
  {
-       struct dst_entry *ndst = dst_cache_get(cache);
+       struct dst_entry *ndst;
         int ttl, err = 0;
 
+       local_bh_disable();
+       ndst = dst_cache_get(cache);
         if (dst->proto == htons(ETH_P_IP)) {
                 struct rtable *rt = (struct rtable *)ndst;
 
@@ -210,9 +212,11 @@ static int tipc_udp_xmit(struct net *net, struct sk_buff *skb,
                                            src->port, dst->port, false);
  #endif
         }
+       local_bh_enable();
         return err;
 
  tx_error:
+       local_bh_enable();
         kfree_skb(skb);
         return err;
  }
--

2.27.0.rc0.183.gde8f92d652-goog

#6 lore raw
Quoted 18 lines · Jon Maloy
Quoted 15 lines · Xin Long
Quoted 14 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 10 lines · Eric Dumazet
Quoted 4 lines · Xin Long
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

Quoted 9 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Also add tipc-discussion and Jon to CC list.

The suggested solution will affect all bearers, not only UDP, so it is not a good. Is there anything preventing us from disabling preemtion inside the scope of the rcu lock?

///jon

BH is disabled any way few nano seconds later, disabling it a bit earlier wont make any difference.

Also, if you intend to make dst_cache BH reentrant, you will have to make that for net-next, not net tree.

Please carefully read include/net/dst_cache.h

It is very clear about BH requirements.

maintainer
#7 lore raw
Quoted 20 lines · Eric Dumazet
Quoted 18 lines · Jon Maloy
Quoted 16 lines · Xin Long
Quoted 13 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 9 lines · Eric Dumazet
Quoted 4 lines · Xin Long
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

Also add tipc-discussion and Jon to CC list.

The suggested solution will affect all bearers, not only UDP, so it is not a good. Is there anything preventing us from disabling preemtion inside the scope of the rcu lock?

///jon

BH is disabled any way few nano seconds later, disabling it a bit earlier wont make any difference.

The point is that if we only disable inside tipc_udp_xmit() (the function pointer call) the change will only affect the UDP bearer, where dst_cache is used. The corresponding calls for the Ethernet and Infiniband bearers don't use dst_cache, and don't need this disabling. So it does makes a difference. ///jon

Quoted 8 lines

Also, if you intend to make dst_cache BH reentrant, you will have to make that for net-next, not net tree.

Please carefully read include/net/dst_cache.h

It is very clear about BH requirements.

#8 lore raw
Quoted 24 lines · Jon Maloy
Quoted 21 lines · Eric Dumazet
Quoted 19 lines · Jon Maloy
Quoted 17 lines · Xin Long
Quoted 13 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 9 lines · Eric Dumazet
Quoted 4 lines · Xin Long
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Also add tipc-discussion and Jon to CC list.

Quoted 9 lines
Quoted 6 lines
Quoted 5 lines

The suggested solution will affect all bearers, not only UDP, so it is not a good. Is there anything preventing us from disabling preemtion inside the scope of the rcu lock?

///jon

BH is disabled any way few nano seconds later, disabling it a bit earlier wont make any difference.

The point is that if we only disable inside tipc_udp_xmit() (the function pointer call) the change will only affect the UDP bearer, where dst_cache is used. The corresponding calls for the Ethernet and Infiniband bearers don't use dst_cache, and don't need this disabling. So it does makes a difference.

I honestly do not understand your concern, this makes no sense to me.

I have disabled BH _right_ before the dst_cache_get(cache) call, so has no effect if the dst_cache is not used, this should be obvious.

If some other paths do not use dst)cache, how can my patch have any effect on them ?

What alternative are you suggesting ?

maintainer
#9 lore raw
Quoted 27 lines · Eric Dumazet
Quoted 25 lines · Jon Maloy
Quoted 23 lines · Eric Dumazet
Quoted 22 lines · Jon Maloy
Quoted 8 lines · Xin Long
Quoted 7 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 3 lines · Eric Dumazet
Quoted 2 lines · Xin Long
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Also add tipc-discussion and Jon to CC list.

The suggested solution will affect all bearers, not only UDP, so it is not a good. Is there anything preventing us from disabling preemtion inside the scope of the rcu lock?

///jon

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

BH is disabled any way few nano seconds later, disabling it a bit earlier wont make any difference.

The point is that if we only disable inside tipc_udp_xmit() (the function pointer call) the change will only affect the UDP bearer, where dst_cache is used. The corresponding calls for the Ethernet and Infiniband bearers don't use dst_cache, and don't need this disabling. So it does makes a difference.

I honestly do not understand your concern, this makes no sense to me.

I have disabled BH _right_ before the dst_cache_get(cache) call, so has no effect if the dst_cache is not used, this should be obvious.

Forget my comment. I thought we were discussing to Tetsuo Handa's original patch, and missed that you had posted your own. I have no problems with this one.

///jon

Quoted 5 lines

If some other paths do not use dst)cache, how can my patch have any effect on them ?

What alternative are you suggesting ?

#10 lore raw
Quoted 35 lines · Jon Maloy
Quoted 31 lines · Eric Dumazet
Quoted 29 lines · Jon Maloy
Quoted 17 lines · Eric Dumazet
Quoted 16 lines · Jon Maloy
Quoted 15 lines · Xin Long
Quoted 12 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 8 lines · Eric Dumazet
Quoted 4 lines · Xin Long
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Quoted 7 lines
Quoted 6 lines
Quoted 1 line

Also add tipc-discussion and Jon to CC list.

The suggested solution will affect all bearers, not only UDP, so it is not a good. Is there anything preventing us from disabling preemtion inside the scope of the rcu lock?

///jon

BH is disabled any way few nano seconds later, disabling it a bit earlier wont make any difference.

The point is that if we only disable inside tipc_udp_xmit() (the function pointer call) the change will only affect the UDP bearer, where dst_cache is used. The corresponding calls for the Ethernet and Infiniband bearers don't use dst_cache, and don't need this disabling. So it does makes a difference.

Quoted 7 lines
Quoted 3 lines

I honestly do not understand your concern, this makes no sense to me.

I have disabled BH _right_ before the dst_cache_get(cache) call, so has no effect if the dst_cache is not used, this should be obvious.

Forget my comment. I thought we were discussing to Tetsuo Handa's original patch, and missed that you had posted your own. I have no problems with this one.

Ah, this now makes sense, I was not aware of Tetsuo patch.

You are absolutely right, Tetsuo Handa's patch is wrong.

Thanks

#11 lore raw
Quoted 1 line · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Since the report was complaining about preemption at this_cpu_ptr(), and "#syz test" request with my preemption-disable patch no longer complained, I didn't realize that it is documented in dst_cache.h that dst_cache_get() must be called with BH disabled. It is bug-prone that we don't have a check for complaining that BH is not disabled.

#12 lore raw
In reply to Xin Long
Quoted 18 lines · Xin Long
Quoted 17 lines · Eric Dumazet

Resend to the list in non HTML form

Quoted 12 lines · Eric Dumazet
Quoted 6 lines · Xin Long
Quoted 2 lines · Eric Dumazet

dst_cache_get() documents it must be used with BH disabled.

Interesting, I thought under rcu_read_lock() is enough, which calls preempt_disable().

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

rcu_read_lock() does not disable BH, never.

And rcu_read_lock() does not necessarily disable preemption.

Then I need to think again if it's really worth using dst_cache here.

Also add tipc-discussion and Jon to CC list.

Thanks.

What improvements you got with your patch ?

Disabling BH a bit earlier wont make any difference.

maintainer
#13 lore raw
In reply to Eric Dumazet

From: Eric Dumazet <[email protected]>
Date: Thu, 21 May 2020 11:29:58 -0700

Quoted 6 lines

dst_cache_get() documents it must be used with BH disabled.

sysbot reported :

BUG: using smp_processor_id() in preemptible [00000000] code: /21697
caller is dst_cache_get+0x3a/0xb0 net/core/dst_cache.c:68

...

Quoted 3 lines
Fixes e9c1a793210f ("tipc: add dst_cache support for udp media")

Applied and queued up for -stable, thanks.