From: Qi Tang <tpluszz77@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: "David S . Miller" <davem@davemloft.net>,
David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Qi Tang <tpluszz77@gmail.com>
Subject: Re: [PATCH net v3] ipv6: validate extension header length before copying to cmsg
Date: Sat, 2 May 2026 09:24:38 +0800 [thread overview]
Message-ID: <20260502012438.3685742-1-tpluszz77@gmail.com> (raw)
In-Reply-To: <d0cc3e95-f03d-4bed-b18f-0517f56b8f05@redhat.com>
On Tue, Apr 28, 2026, Paolo Abeni <pabeni@redhat.com> wrote:
> > +static u16 ipv6_get_exthdr_len(const struct sk_buff *skb, const u8 *ptr)
> > +{
> > + u16 len = (ptr[1] + 1) << 3;
>
> Sashiko notes that you should validate even this offset (1) before
> accessing it.
Good catch. I will add a "ptr + 2 > skb_tail_pointer(skb)" check
before reading ptr[1], in both the helper and the inline AH path.
> You may also consider switching to pskb_may_pull().
I considered this but would prefer to keep skb_tail_pointer().
Two reasons:
1. ipv6_parse_hopopts() / dst_opts_rcv() / ipv6_rthdr_rcv() already
pskb_may_pull() the full extension header during input parsing,
so by the time ip6_datagram_recv_specific_ctl() runs the headers
are guaranteed to be in the linear area; another pskb_may_pull()
would be a no-op.
2. When pskb_may_pull() does have work to do, __pskb_pull_tail() can
call pskb_expand_head() and reallocate skb->head, which would
invalidate the caller's `ptr` (computed as nh + offset).
WDYT? Happy to switch if I'm missing something.
Thanks,
Qi
next prev parent reply other threads:[~2026-05-02 1:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 10:32 [PATCH net v3] ipv6: validate extension header length before copying to cmsg Qi Tang
2026-04-28 11:24 ` Paolo Abeni
2026-05-02 1:24 ` Qi Tang [this message]
2026-05-09 2:42 ` Qi Tang
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=20260502012438.3685742-1-tpluszz77@gmail.com \
--to=tpluszz77@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.