From: Florian Westphal <fw@strlen.de>
To: <netdev@vger.kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
<netfilter-devel@vger.kernel.org>,
Xin Long <lucien.xin@gmail.com>,
Simon Horman <simon.horman@corigine.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Aaron Conole <aconole@redhat.com>
Subject: [PATCH net-next 2/9] netfilter: bridge: call pskb_may_pull in br_nf_check_hbh_len
Date: Wed, 8 Mar 2023 20:30:26 +0100 [thread overview]
Message-ID: <20230308193033.13965-3-fw@strlen.de> (raw)
In-Reply-To: <20230308193033.13965-1-fw@strlen.de>
From: Xin Long <lucien.xin@gmail.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@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: Aaron Conole <aconole@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.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
next prev parent reply other threads:[~2023-03-08 19:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 19:30 [PATCH net-next 0/9] Netfilter updates for net-next Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 1/9] netfilter: bridge: introduce broute meta statement Florian Westphal
2023-03-10 7:40 ` patchwork-bot+netdevbpf
2023-03-08 19:30 ` Florian Westphal [this message]
2023-03-08 19:30 ` [PATCH net-next 3/9] netfilter: bridge: check len before accessing more nh data Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 4/9] netfilter: bridge: move pskb_trim_rcsum out of br_nf_check_hbh_len Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 5/9] netfilter: move br_nf_check_hbh_len to utils Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 6/9] netfilter: use nf_ip6_check_hbh_len in nf_ct_skb_network_trim Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 7/9] selftests: add a selftest for big tcp Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 8/9] netfilter: conntrack: fix typo Florian Westphal
2023-03-08 19:30 ` [PATCH net-next 9/9] netfilter: nat: fix indentation of function arguments Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230308193033.13965-3-fw@strlen.de \
--to=fw@strlen.de \
--cc=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=lucien.xin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=razor@blackwall.org \
--cc=simon.horman@corigine.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).