[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221101091356.531160-1-liuhangbin@gmail.com>
Date: Tue, 1 Nov 2022 17:13:56 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: netdev@...r.kernel.org
Cc: Jay Vosburgh <j.vosburgh@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jonathan Toppins <jtoppins@...hat.com>,
Paolo Abeni <pabeni@...hat.com>,
David Ahern <dsahern@...il.com>,
Hangbin Liu <liuhangbin@...il.com>, Liang Li <liali@...hat.com>
Subject: [PATCH net] bonding: fix ICMPv6 header handling when receiving IPv6 messages
Some drivers, like bnx2x, will call ipv6_gro_receive() and set skb
IPv6 transport header before bond_handle_frame(). But some other drivers,
like be2net, will not call ipv6_gro_receive() and skb transport header
is not set properly. Thus we can't use icmp6_hdr(skb) to get the icmp6
header directly when dealing with IPv6 messages.
Fix this by checking the skb length manually and getting icmp6 header based
on the IPv6 header offset.
Reported-by: Liang Li <liali@...hat.com>
Fixes: 4e24be018eb9 ("bonding: add new parameter ns_targets")
Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
---
drivers/net/bonding/bond_main.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e84c49bf4d0c..08b5f512f5fb 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -3231,12 +3231,23 @@ static int bond_na_rcv(const struct sk_buff *skb, struct bonding *bond,
struct slave *slave)
{
struct slave *curr_active_slave, *curr_arp_slave;
- struct icmp6hdr *hdr = icmp6_hdr(skb);
+ const struct icmp6hdr *icmp6_hdr;
struct in6_addr *saddr, *daddr;
+ const struct ipv6hdr *hdr;
+ u16 pkt_len;
+
+ /* Check if the length is enough manually as we can't use pskb_may_pull */
+ hdr = ipv6_hdr(skb);
+ pkt_len = ntohs(hdr->payload_len);
+ if (hdr->nexthdr != NEXTHDR_ICMP || pkt_len < sizeof(*icmp6_hdr) ||
+ skb_headlen(skb) < sizeof(*hdr) + pkt_len)
+ goto out;
+
+ icmp6_hdr = (const struct icmp6hdr *)(skb->data + sizeof(*hdr));
if (skb->pkt_type == PACKET_OTHERHOST ||
skb->pkt_type == PACKET_LOOPBACK ||
- hdr->icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)
+ icmp6_hdr->icmp6_type != NDISC_NEIGHBOUR_ADVERTISEMENT)
goto out;
saddr = &ipv6_hdr(skb)->saddr;
--
2.38.1
Powered by blists - more mailing lists