[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230308193033.13965-3-fw@strlen.de>
Date: Wed, 8 Mar 2023 20:30:26 +0100
From: Florian Westphal <fw@...len.de>
To: <netdev@...r.kernel.org>
Cc: Paolo Abeni <pabeni@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
<netfilter-devel@...r.kernel.org>, Xin Long <lucien.xin@...il.com>,
Simon Horman <simon.horman@...igine.com>,
Nikolay Aleksandrov <razor@...ckwall.org>,
Aaron Conole <aconole@...hat.com>
Subject: [PATCH net-next 2/9] netfilter: bridge: call pskb_may_pull in br_nf_check_hbh_len
From: Xin Long <lucien.xin@...il.com>
When checking Hop-by-hop option header, if the option data is in
nonlinear area, it should do pskb_may_pull instead of discarding
the skb as a bad IPv6 packet.
Signed-off-by: Xin Long <lucien.xin@...il.com>
Reviewed-by: Simon Horman <simon.horman@...igine.com>
Acked-by: Nikolay Aleksandrov <razor@...ckwall.org>
Reviewed-by: Aaron Conole <aconole@...hat.com>
Signed-off-by: Florian Westphal <fw@...len.de>
---
net/bridge/br_netfilter_ipv6.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/net/bridge/br_netfilter_ipv6.c b/net/bridge/br_netfilter_ipv6.c
index 6b07f30675bb..afd1c718b683 100644
--- a/net/bridge/br_netfilter_ipv6.c
+++ b/net/bridge/br_netfilter_ipv6.c
@@ -45,14 +45,18 @@
*/
static int br_nf_check_hbh_len(struct sk_buff *skb)
{
- unsigned char *raw = (u8 *)(ipv6_hdr(skb) + 1);
+ int len, off = sizeof(struct ipv6hdr);
+ unsigned char *nh;
u32 pkt_len;
- const unsigned char *nh = skb_network_header(skb);
- int off = raw - nh;
- int len = (raw[1] + 1) << 3;
- if ((raw + len) - skb->data > skb_headlen(skb))
+ if (!pskb_may_pull(skb, off + 8))
goto bad;
+ nh = (unsigned char *)(ipv6_hdr(skb) + 1);
+ len = (nh[1] + 1) << 3;
+
+ if (!pskb_may_pull(skb, off + len))
+ goto bad;
+ nh = skb_network_header(skb);
off += 2;
len -= 2;
--
2.39.2
Powered by blists - more mailing lists