diff mbox series

[net] net: core: reduce recursion limit value

Message ID 20200615150037.21529-1-ap420073@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series [net] net: core: reduce recursion limit value | expand

Commit Message

Taehee Yoo June 15, 2020, 3 p.m. UTC
In the current code, ->ndo_start_xmit() can be executed recursively only
10 times because of stack memory.
But, in the case of the vxlan, 10 recursion limit value results in
a stack overflow.
In the current code, the nested interface is limited by 8 depth.
There is no critical reason that the recursion limitation value should
be 10.
So, it would be good to be the same value with the limitation value of
nesting interface depth.

Test commands:
    ip link add vxlan10 type vxlan vni 10 dstport 4789 srcport 4789 4789
    ip link set vxlan10 up
    ip a a 192.168.10.1/24 dev vxlan10
    ip n a 192.168.10.2 dev vxlan10 lladdr fc:22:33:44:55:66 nud permanent

    for i in {9..0}
    do
        let A=$i+1
	ip link add vxlan$i type vxlan vni $i dstport 4789 srcport 4789 4789
	ip link set vxlan$i up
	ip a a 192.168.$i.1/24 dev vxlan$i
	ip n a 192.168.$i.2 dev vxlan$i lladdr fc:22:33:44:55:66 nud permanent
	bridge fdb add fc:22:33:44:55:66 dev vxlan$A dst 192.168.$i.2 self
    done
    hping3 192.168.10.2 -2 -d 60000

Splat looks like:
[  103.814237][ T1127] =============================================================================
[  103.871955][ T1127] BUG kmalloc-2k (Tainted: G    B            ): Padding overwritten. 0x00000000897a2e4f-0x000
[  103.873187][ T1127] -----------------------------------------------------------------------------
[  103.873187][ T1127]
[  103.874252][ T1127] INFO: Slab 0x000000005cccc724 objects=5 used=5 fp=0x0000000000000000 flags=0x10000000001020
[  103.881323][ T1127] CPU: 3 PID: 1127 Comm: hping3 Tainted: G    B             5.7.0+ #575
[  103.882131][ T1127] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[  103.883006][ T1127] Call Trace:
[  103.883324][ T1127]  dump_stack+0x96/0xdb
[  103.883716][ T1127]  slab_err+0xad/0xd0
[  103.884106][ T1127]  ? _raw_spin_unlock+0x1f/0x30
[  103.884620][ T1127]  ? get_partial_node.isra.78+0x140/0x360
[  103.885214][ T1127]  slab_pad_check.part.53+0xf7/0x160
[  103.885769][ T1127]  ? pskb_expand_head+0x110/0xe10
[  103.886316][ T1127]  check_slab+0x97/0xb0
[  103.886763][ T1127]  alloc_debug_processing+0x84/0x1a0
[  103.887308][ T1127]  ___slab_alloc+0x5a5/0x630
[  103.887765][ T1127]  ? pskb_expand_head+0x110/0xe10
[  103.888265][ T1127]  ? lock_downgrade+0x730/0x730
[  103.888762][ T1127]  ? pskb_expand_head+0x110/0xe10
[  103.889244][ T1127]  ? __slab_alloc+0x3e/0x80
[  103.889675][ T1127]  __slab_alloc+0x3e/0x80
[  103.890108][ T1127]  __kmalloc_node_track_caller+0xc7/0x420
[ ... ]

Fixes: 97cdcf37b57e ("net: place xmit recursion in softnet data")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
 include/linux/netdevice.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Westphal June 15, 2020, 3:21 p.m. UTC | #1
Taehee Yoo <ap420073@gmail.com> wrote:
> In the current code, ->ndo_start_xmit() can be executed recursively only
> 10 times because of stack memory.
> But, in the case of the vxlan, 10 recursion limit value results in
> a stack overflow.
[..]

> Fixes: 97cdcf37b57e ("net: place xmit recursion in softnet data")

That commit did not change the recursion limit,
11a766ce915fc9f86 ("net: Increase xmit RECURSION_LIMIT to 10.") did?
Taehee Yoo June 16, 2020, 10:49 a.m. UTC | #2
On Tue, 16 Jun 2020 at 00:21, Florian Westphal <fw@strlen.de> wrote:
>

Hi Florian,
Thank you for the review!

> Taehee Yoo <ap420073@gmail.com> wrote:
> > In the current code, ->ndo_start_xmit() can be executed recursively only
> > 10 times because of stack memory.
> > But, in the case of the vxlan, 10 recursion limit value results in
> > a stack overflow.
> [..]
>
> > Fixes: 97cdcf37b57e ("net: place xmit recursion in softnet data")
>
> That commit did not change the recursion limit,
> 11a766ce915fc9f86 ("net: Increase xmit RECURSION_LIMIT to 10.") did?

You're right.
I will send a v2 patch.

Thanks!
diff mbox series

Patch

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 6fc613ed8eae..39e28e11863c 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -3157,7 +3157,7 @@  static inline int dev_recursion_level(void)
 	return this_cpu_read(softnet_data.xmit.recursion);
 }
 
-#define XMIT_RECURSION_LIMIT	10
+#define XMIT_RECURSION_LIMIT	8
 static inline bool dev_xmit_recursion(void)
 {
 	return unlikely(__this_cpu_read(softnet_data.xmit.recursion) >