From: Aaron Conole <aconole@redhat.com>
To: Xin Long <lucien.xin@gmail.com>
Cc: netfilter-devel@vger.kernel.org,
network dev <netdev@vger.kernel.org>,
Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
davem@davemloft.net, kuba@kernel.org,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Roopa Prabhu <roopa@nvidia.com>,
Nikolay Aleksandrov <razor@blackwall.org>,
Pravin B Shelar <pshelar@ovn.org>
Subject: Re: [PATCH nf-next 3/6] netfilter: bridge: move pskb_trim_rcsum out of br_nf_check_hbh_len
Date: Tue, 07 Mar 2023 13:32:10 -0500 [thread overview]
Message-ID: <f7ty1o84dlh.fsf@redhat.com> (raw)
In-Reply-To: <688b6037c640efeb6141d4646cc9dc1b657796e7.1677888566.git.lucien.xin@gmail.com> (Xin Long's message of "Fri, 3 Mar 2023 19:12:39 -0500")
Xin Long <lucien.xin@gmail.com> writes:
> br_nf_check_hbh_len() is a function to check the Hop-by-hop option
> header, and shouldn't do pskb_trim_rcsum() there. This patch is to
> pass pkt_len out to br_validate_ipv6() and do pskb_trim_rcsum()
> after calling br_validate_ipv6() instead.
>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---
Reviewed-by: Aaron Conole <aconole@redhat.com>
> net/bridge/br_netfilter_ipv6.c | 33 ++++++++++++++-------------------
> 1 file changed, 14 insertions(+), 19 deletions(-)
>
> diff --git a/net/bridge/br_netfilter_ipv6.c b/net/bridge/br_netfilter_ipv6.c
> index 50f564c33551..07289e4f3213 100644
> --- a/net/bridge/br_netfilter_ipv6.c
> +++ b/net/bridge/br_netfilter_ipv6.c
> @@ -43,11 +43,11 @@
> /* We only check the length. A bridge shouldn't do any hop-by-hop stuff
> * anyway
> */
> -static int br_nf_check_hbh_len(struct sk_buff *skb)
> +static int br_nf_check_hbh_len(struct sk_buff *skb, u32 *plen)
> {
> int len, off = sizeof(struct ipv6hdr);
> unsigned char *nh;
> - u32 pkt_len;
> + u32 pkt_len = 0;
>
> if (!pskb_may_pull(skb, off + 8))
> return -1;
> @@ -83,10 +83,6 @@ static int br_nf_check_hbh_len(struct sk_buff *skb)
> return -1;
> if (pkt_len > skb->len - sizeof(struct ipv6hdr))
> return -1;
> - if (pskb_trim_rcsum(skb,
> - pkt_len + sizeof(struct ipv6hdr)))
> - return -1;
> - nh = skb_network_header(skb);
> }
> off += optlen;
> len -= optlen;
> @@ -94,6 +90,8 @@ static int br_nf_check_hbh_len(struct sk_buff *skb)
> if (len)
> return -1;
>
> + if (pkt_len)
> + *plen = pkt_len;
> return 0;
> }
>
> @@ -116,22 +114,19 @@ int br_validate_ipv6(struct net *net, struct sk_buff *skb)
> goto inhdr_error;
>
> pkt_len = ntohs(hdr->payload_len);
> + if (hdr->nexthdr == NEXTHDR_HOP && br_nf_check_hbh_len(skb, &pkt_len))
> + goto drop;
>
> - if (pkt_len || hdr->nexthdr != NEXTHDR_HOP) {
> - if (pkt_len + ip6h_len > skb->len) {
> - __IP6_INC_STATS(net, idev,
> - IPSTATS_MIB_INTRUNCATEDPKTS);
> - goto drop;
> - }
> - if (pskb_trim_rcsum(skb, pkt_len + ip6h_len)) {
> - __IP6_INC_STATS(net, idev,
> - IPSTATS_MIB_INDISCARDS);
> - goto drop;
> - }
> - hdr = ipv6_hdr(skb);
> + if (pkt_len + ip6h_len > skb->len) {
> + __IP6_INC_STATS(net, idev,
> + IPSTATS_MIB_INTRUNCATEDPKTS);
> + goto drop;
> }
> - if (hdr->nexthdr == NEXTHDR_HOP && br_nf_check_hbh_len(skb))
> + if (pskb_trim_rcsum(skb, pkt_len + ip6h_len)) {
> + __IP6_INC_STATS(net, idev,
> + IPSTATS_MIB_INDISCARDS);
> goto drop;
> + }
>
> memset(IP6CB(skb), 0, sizeof(struct inet6_skb_parm));
> /* No IP options in IPv6 header; however it should be
next prev parent reply other threads:[~2023-03-07 18:48 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-04 0:12 [PATCH nf-next 0/6] netfilter: handle ipv6 jumbo packets properly for bridge ovs and tc Xin Long
2023-03-04 0:12 ` [PATCH nf-next 1/6] netfilter: bridge: call pskb_may_pull in br_nf_check_hbh_len Xin Long
2023-03-06 15:52 ` Simon Horman
2023-03-07 9:16 ` Nikolay Aleksandrov
2023-03-07 18:33 ` Aaron Conole
2023-03-04 0:12 ` [PATCH nf-next 2/6] netfilter: bridge: check len before accessing more nh data Xin Long
2023-03-06 15:59 ` Simon Horman
2023-03-07 9:20 ` Nikolay Aleksandrov
2023-03-07 18:32 ` Aaron Conole
2023-03-04 0:12 ` [PATCH nf-next 3/6] netfilter: bridge: move pskb_trim_rcsum out of br_nf_check_hbh_len Xin Long
2023-03-06 16:26 ` Simon Horman
2023-03-07 9:21 ` Nikolay Aleksandrov
2023-03-07 18:32 ` Aaron Conole [this message]
2023-03-04 0:12 ` [PATCH nf-next 4/6] netfilter: move br_nf_check_hbh_len to utils Xin Long
2023-03-06 16:35 ` Simon Horman
2023-03-07 9:21 ` Nikolay Aleksandrov
2023-03-07 18:31 ` Aaron Conole
2023-03-04 0:12 ` [PATCH nf-next 5/6] netfilter: use nf_ip6_check_hbh_len in nf_ct_skb_network_trim Xin Long
2023-03-06 16:35 ` Simon Horman
2023-03-07 20:58 ` Xin Long
2023-03-07 9:22 ` Nikolay Aleksandrov
2023-03-07 18:31 ` Aaron Conole
2023-03-04 0:12 ` [PATCH nf-next 6/6] selftests: add a selftest for big tcp Xin Long
2023-03-07 18:31 ` Aaron Conole
2023-03-07 20:06 ` Xin Long
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=f7ty1o84dlh.fsf@redhat.com \
--to=aconole@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--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=pablo@netfilter.org \
--cc=pshelar@ovn.org \
--cc=razor@blackwall.org \
--cc=roopa@nvidia.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).