From: Joe Damato <joe@dama.to>
To: Breno Leitao <leitao@debian.org>
Cc: David Ahern <dsahern@kernel.org>,
Ido Schimmel <idosch@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Shuah Khan <shuah@kernel.org>, Eric Dumazet <edumazet@kernel.org>,
linux-kernel@vger.kernel.org, netdev@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 v4 5/7] ipv4: convert do_ip_getsockopt() to sockopt_t
Date: Tue, 3 Nov 2026 15:07:12 -0800 [thread overview]
Message-ID: <auppIKnm1NvzBIzH@devvm20253.cco0.facebook.com> (raw)
In-Reply-To: <20261103-sockopt_expand_out_v2-v4-5-2d36da923578@debian.org>
On Tue, Nov 03, 2026 at 03:01:04AM -0800, Breno Leitao wrote:
> Convert the SOL_IP switch and ip_mroute_getsockopt() to sockopt_t, its
> last leaf on a sockptr_t pair. The IP_MSFILTER and MCAST_MSFILTER
> bridges go away.
>
> ip_getsockopt() builds the sockopt_t with sockopt_init_user() and
> writes optlen back unconditionally, because IP_OPTIONS and others
> report a length and can then fail. ip_mc_msfget() therefore stores its
> length only after its last copy, so a copy failure can't report a
> changed one.
>
> The write-back also happens before the netfilter fallback, so an
> unwritable optlen turns any error into -EFAULT and skips the fallback.
> Likewise optlen is now read before the level check and the MRT_*
> dispatch, so an unreadable or negative one wins over -EOPNOTSUPP.
>
> IP_OPTIONS with no options set and IP_PKTOPTIONS used to return the
> result of copy_to_sockptr(), the number of bytes not copied, so an
> unwritable optlen made getsockopt() return 4. They now return -EFAULT.
>
> sol_ip_sockopt() builds the sockopt_t with sockptr_to_sockopt() and
> stores optlen back as well. This extra code will go away when we
> convert sol_ip_sockopt() to talk sockopt as well, but for now we are
> converting the leaves.
>
> Acked-by: Stanislav Fomichev <sdf@fomichev.me>
> Acked-by: Ido Schimmel <idosch@nvidia.com>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
> include/linux/mroute.h | 4 +--
> include/net/ip.h | 3 +-
> net/core/filter.c | 18 ++++++++---
> net/ipv4/igmp.c | 3 +-
> net/ipv4/ip_sockglue.c | 87 +++++++++++++++++++-------------------------------
> net/ipv4/ipmr.c | 11 +++----
> 6 files changed, 56 insertions(+), 70 deletions(-)
[...]
> @@ -1711,43 +1707,25 @@ int do_ip_getsockopt(struct sock *sk, int level, int optname,
> case IP_MSFILTER:
> {
> struct ip_msfilter msf;
> - struct kvec kvec;
> - sockopt_t opt;
>
> if (len < IP_MSFILTER_SIZE(0)) {
> err = -EINVAL;
> goto out;
> }
> - if (copy_from_sockptr(&msf, optval, IP_MSFILTER_SIZE(0))) {
> + if (copy_from_iter(&msf, IP_MSFILTER_SIZE(0), &sopt->iter_in) !=
> + IP_MSFILTER_SIZE(0)) {
The line wrapping is a little weird looking to me. Not sure if there is
anything that can be done about it and not sure it would be worth a re-spin
just because I think it's a little ugly :)
Reviewed-by: Joe Damato <joe@dama.to>
next prev parent reply other threads:[~2026-11-03 23:07 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 11:00 [PATCH net-next v4 0/7] ipv4,ipv6: convert the getsockopt switches " Breno Leitao
2026-11-03 11:01 ` [PATCH net-next v4 1/7] ipv6: treat a negative optlen as 4 in do_ipv6_getsockopt() Breno Leitao
2026-11-03 21:45 ` Joe Damato
2026-11-04 4:15 ` Jiayuan Chen
2026-11-03 11:01 ` [PATCH net-next v4 2/7] net: cap sockopt_expand_out() at MAX_RW_COUNT Breno Leitao
2026-11-03 19:32 ` Stanislav Fomichev
2026-11-03 21:47 ` Joe Damato
2026-11-04 4:15 ` Jiayuan Chen
2026-11-03 11:01 ` [PATCH net-next v4 3/7] ipv6: mcast: convert ip6_mc_msfget() to sockopt_t Breno Leitao
2026-11-03 23:01 ` Joe Damato
2026-11-03 11:01 ` [PATCH net-next v4 4/7] ipv4: igmp: convert ip_mc_gsfget() " Breno Leitao
2026-11-03 23:03 ` Joe Damato
2026-11-03 11:01 ` [PATCH net-next v4 5/7] ipv4: convert do_ip_getsockopt() " Breno Leitao
2026-11-03 23:07 ` Joe Damato [this message]
2026-11-03 11:01 ` [PATCH net-next v4 6/7] ipv6: convert do_ipv6_getsockopt() " Breno Leitao
2026-11-03 19:32 ` Stanislav Fomichev
2026-11-03 11:01 ` [PATCH net-next v4 7/7] selftests: net: getsockopt_iter: cover ip and ipv6 Breno Leitao
2026-11-03 19:32 ` Stanislav Fomichev
2026-11-03 23:32 ` Joe Damato
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=auppIKnm1NvzBIzH@devvm20253.cco0.facebook.com \
--to=joe@dama.to \
--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
all inboxes | Powered by JetHome®