From: netdev-bot+sashiko@kernel.org
To: leitao@debian.org
Cc: dsahern@kernel.org, idosch@nvidia.com, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev,
song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org,
emil@etsalapatis.com, ihor.solodrai@linux.dev,
john.fastabend@gmail.com, sdf@fomichev.me, shuah@kernel.org,
edumazet@kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, david.laight.linux@gmail.com,
kernel-team@meta.com
Subject: Re: [PATCH net-next v2 1/7] ipv6: treat a negative optlen as 4 in do_ipv6_getsockopt()
Date: Sat, 10 Oct 2026 09:12:49 +0000 [thread overview]
Message-ID: <179162356933.434549.9128206075467468309@kernel.org> (raw)
In-Reply-To: <20261009-sockopt_expand_out_v2-v2-1-8ac08c469ecb@debian.org>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] This commit's message says a negative optlen is answered as 4
'for every option', and its new comment says 'take it as 4 everywhere'.
- [Low] The commit fixes old behaviour where do_ipv6_getsockopt() treated
a negative optlen as a huge buffer: IPV6_2292PKTOPTIONS wrote control…
--
ipv6: treat a negative optlen as 4 in do_ipv6_getsockopt()
This patch makes do_ipv6_getsockopt() treat a negative optlen as 4. The
int options already behaved this way through their unsigned min_t()
clamp. Sticky headers and the IPV6_2292PKTOPTIONS control buffer are now
cut to 4 bytes, and IPV6_PATHMTU and IPV6_FLOWLABEL_MGR now fail with
-EINVAL, as preparation for the sockopt_t conversion.
> Suggested-by: David Laight <david.laight.linux@gmail.com>
> Signed-off-by: Breno Leitao <leitao@debian.org>
[Severity: Low]
The commit message describes old behaviour that this patch fixes:
- IPV6_2292PKTOPTIONS writes control messages without a limit.
- IPV6_PATHMTU and IPV6_FLOWLABEL_MGR pass their size checks.
- Sticky headers are copied in full.
There is no Fixes: tag or stable guidance, though. Should one be added,
or a note saying this is not meant for stable?
The code involved predates git (1da177e4c3f4). The old behaviour only
wrote to buffers that userspace supplied. This patch also changes results
that userspace can see. For example, IPV6_PATHMTU with a negative optlen
now returns -EINVAL.
Another patch in this series, "net: cap sockopt_expand_out() at
MAX_RW_COUNT", does carry a Fixes: tag.
> diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
> index 4b3536571c980..4091d1521cc09 100644
> --- a/net/ipv6/ipv6_sockglue.c
> +++ b/net/ipv6/ipv6_sockglue.c
> @@ -1002,6 +1002,11 @@ int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
>
> if (copy_from_sockptr(&len, optlen, sizeof(int)))
> return -EFAULT;
> + /* Historic bug compatibility: the int options have always taken a
> + * negative optlen as 4, so take it as 4 everywhere.
> + */
> + if (len < 0)
> + len = 4;
[Severity: Low]
Is "take it as 4 everywhere" accurate at this commit? The commit message
also says a negative optlen is answered as 4 "for every option".
The mroute dispatch at the top of do_ipv6_getsockopt() returns before
the new clamp runs:
net/ipv6/ipv6_sockglue.c:do_ipv6_getsockopt() {
...
if (ip6_mroute_opt(optname))
return ip6_mroute_getsockopt(sk, optname, optval, optlen);
...
}
ip6_mroute_getsockopt() then reads optlen again and rejects a negative
value:
net/ipv6/ip6mr.c:ip6_mroute_getsockopt() {
...
olr = min_t(int, olr, sizeof(int));
if (olr < 0)
return -EINVAL;
...
}
So on a raw ICMPv6 socket, MRT6_VERSION, MRT6_PIM and MRT6_ASSERT still
fail with len = -1, even though they are int options. IPV6_TCLASS
answers 4 bytes in the same case.
This also seems to contradict the part of the comment that says "the int
options have always taken a negative optlen as 4". The MRT6_* int options
have always returned -EINVAL.
The clamp also only changes the local len. When do_ipv6_getsockopt()
returns -ENOPROTOOPT, ipv6_getsockopt() reads the raw optlen again before
it calls nf_getsockopt():
net/ipv6/ipv6_sockglue.c:ipv6_getsockopt() {
...
if (get_user(len, optlen))
return -EFAULT;
err = nf_getsockopt(sk, PF_INET6, optname, optval, &len);
...
}
The ip6_tables and conntrack handlers reached from there seem to reject a
negative length themselves. So this looks like a mismatch in wording, not
a functional problem.
A later patch in this series, "ipv6: convert do_ipv6_getsockopt() to
sockopt_t", moves the clamp into ipv6_getsockopt(). There it runs before
both the mroute dispatch and the netfilter fallback, which closes the gap.
Could the comment and commit message here be changed to describe what
this commit actually does?
> switch (optname) {
> case MCAST_MSFILTER:
> if (in_compat_syscall())
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261009-sockopt_expand_out_v2-v2-0-8ac08c469ecb%40debian.org
next prev parent reply other threads:[~2026-10-10 9:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 8:53 [PATCH net-next v2 0/7] ipv4,ipv6: convert the getsockopt switches to sockopt_t Breno Leitao
2026-10-09 8:53 ` [PATCH net-next v2 1/7] ipv6: treat a negative optlen as 4 in do_ipv6_getsockopt() Breno Leitao
2026-10-10 9:12 ` netdev-bot+sashiko [this message]
2026-10-09 8:53 ` [PATCH net-next v2 2/7] net: cap sockopt_expand_out() at MAX_RW_COUNT Breno Leitao
2026-10-10 9:12 ` netdev-bot+sashiko
2026-10-09 8:53 ` [PATCH net-next v2 3/7] ipv6: mcast: convert ip6_mc_msfget() to sockopt_t Breno Leitao
2026-10-09 8:53 ` [PATCH net-next v2 4/7] ipv4: igmp: convert ip_mc_gsfget() " Breno Leitao
2026-10-09 8:53 ` [PATCH net-next v2 5/7] ipv4: convert do_ip_getsockopt() " Breno Leitao
2026-10-10 9:12 ` netdev-bot+sashiko
2026-10-09 8:53 ` [PATCH net-next v2 6/7] ipv6: convert do_ipv6_getsockopt() " Breno Leitao
2026-10-10 9:12 ` netdev-bot+sashiko
2026-10-09 8:53 ` [PATCH net-next v2 7/7] selftests: net: getsockopt_iter: cover ip and ipv6 Breno Leitao
2026-10-10 9:12 ` netdev-bot+sashiko
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=179162356933.434549.9128206075467468309@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=david.laight.linux@gmail.com \
--cc=dsahern@kernel.org \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=horms@kernel.org \
--cc=idosch@nvidia.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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