drivers/net/wan/lapbether.c: Fixed kernel panic when used with AF_PACKET sockets
Subsystems (3)
PATCH 1/1 drivers/net/wan/lapbether.c: Fixed kernel panic when used with AF_PACKET sockets
When we use "AF_PACKET" sockets to send data directly over LAPB over Ethernet using this driver, the kernel will panic because of insufficient header space allocated in the "sk_buff" struct.
The header space needs 18 bytes because:
the lapbether driver will remove a pseudo header of 1 byte; the lapb module will prepend the LAPB header of 2 or 3 bytes; the lapbether driver will prepend a length field of 2 bytes and the
Ethernet header of 14 bytes.
So -1 + 3 + 16 = 18.
--- drivers/net/wan/lapbether.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wan/lapbether.c +2 -1
@@ -303,7 +303,8 @@ static void lapbeth_setup(struct net_device *dev) dev->netdev_ops = &lapbeth_netdev_ops; dev->needs_free_netdev = true; dev->type =ARPHRD_X25 ; - dev->hard_header_len =3 ; +/* 18 = -1 (lapbether) + 3 (lapb) + 16 (lapbether) */ + dev->hard_header_len =18 ; dev->mtu =1000 ; dev->addr_len =0 ; }
Signature · 1 line
2.25.1
David Miller
maintainerFrom: Xie He <[email protected]>
Date: Wed, 27 May 2020 20:21:33 -0700
Quoted 10 lines
When we use "
AF_PACKET" sockets to send data directly over LAPB over Ethernet using this driver, the kernel will panic because of insufficient header space allocated in the "sk_buff" struct.The header space needs 18 bytes because:
the lapbether driver will remove a pseudo header of 1 byte; the lapb module will prepend the LAPB header of 2 or 3 bytes; the lapbether driver will prepend a length field of 2 bytes and the
Ethernet header of 14 bytes.
Quoted 3 lines
So -1 + 3 + 16 = 18.
Signed-off-by Xie He <[email protected]>
This is not the real problem.
The real problem is that this is a stacked, layered, device and the lapbether driver does not take the inner device's header length into consideration. It should take this from the child device's netdev structure rather than use constants.
Your test case will still fail when lapbether is stacked on top of a VLAN device or similar, even with your changes.
From: David Miller <[email protected]>
Date: Mon, Jun 1, 2020 at 11:32 AM -0700
Quoted 20 lines
From: Xie He <[email protected]>
Date: Wed, 27 May 2020 20:21:33 -0700Quoted 10 lines
When we use "
AF_PACKET" sockets to send data directly over LAPB over Ethernet using this driver, the kernel will panic because of insufficient header space allocated in the "sk_buff" struct.The header space needs 18 bytes because:
the lapbether driver will remove a pseudo header of 1 byte; the lapb module will prepend the LAPB header of 2 or 3 bytes; the lapbether driver will prepend a length field of 2 bytes and the
Ethernet header of 14 bytes.Quoted 3 lines
So -1 + 3 + 16 = 18.
Signed-off-by Xie He <[email protected]>This is not the real problem.
Quoted 7 lines
The real problem is that this is a stacked, layered, device and the lapbether driver does not take the inner device's header length into consideration. It should take this from the child device's netdev structure rather than use constants.
Your test case will still fail when lapbether is stacked on top of a VLAN device or similar, even with your changes.
Thank you for your email! I'm sorry I didn't see your email previously because of problems with my mailbox.
Yes, you are right. I'll use better ways to improve this and re-submit my patch. Thanks for pointing this out.