From: Ido Schimmel <idosch@nvidia.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
Tamir Shahar <tamirthesis@gmail.com>,
Amit Klein <aksecurity@gmail.com>
Subject: Re: [PATCH net] ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options
Date: Mon, 1 Jun 2026 18:34:01 +0300 [thread overview]
Message-ID: <20260601153401.GA391068@shredder> (raw)
In-Reply-To: <20260601124157.699463-1-edumazet@google.com>
On Mon, Jun 01, 2026 at 12:41:57PM +0000, Eric Dumazet wrote:
> This patch restricts setting Loose Source and Record Route (LSRR)
> and Strict Source and Record Route (SSRR) IP options to users
> with CAP_NET_RAW capability.
>
> This prevents unprivileged applications from forcing packets to route
> through attacker-controlled nodes to leak TCP ISN and possibly other
> protocol information.
>
> While LSRR and SSRR are commonly filtered in many network environments,
> they may still be supported and forwarded along some network paths.
>
> RFC 7126 (Recommendations on Filtering of IPv4 Packets Containing
> IPv4 Options) recommend to drop these options in 4.3 and 4.4.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Reported-by: Tamir Shahar <tamirthesis@gmail.com>
> Reported-by: Amit Klein <aksecurity@gmail.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
> net/ipv4/ip_options.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
> index be8815ce3ac242372eeae4a97091cda26d40ceb0..ac0d147c4b8cc347839a044adc43897faffd95c8 100644
> --- a/net/ipv4/ip_options.c
> +++ b/net/ipv4/ip_options.c
> @@ -283,6 +283,10 @@ int __ip_options_compile(struct net *net,
> switch (*optptr) {
> case IPOPT_SSRR:
> case IPOPT_LSRR:
> + if (!skb && !ns_capable(net->user_ns, CAP_NET_RAW)) {
> + pp_ptr = optptr;
> + goto error;
> + }
This might be a problem for netfilter which calls __ip_options_compile()
without an skb from ipv4_find_option().
AFAICT, user space can include IP options either using the IP_OPTIONS
socket options or using the IP_RETOPTS cmsg, but the latter is not
applicable to TCP.
If we put the check in do_ip_setsockopt(), we create a weird situation
for non-TCP sockets: They can't set these IP options using IP_OPTIONS,
but can set them via the IP_RETOPTS cmsg.
So maybe we should just put the check in ip_options_get() which is
called from both paths? Something like:
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c
index be8815ce3ac2..09d745112c15 100644
--- a/net/ipv4/ip_options.c
+++ b/net/ipv4/ip_options.c
@@ -530,6 +530,10 @@ int ip_options_get(struct net *net, struct ip_options_rcu **optp,
kfree(opt);
return -EINVAL;
}
+ if (opt->opt.srr && !ns_capable(net->user_ns, CAP_NET_RAW)) {
+ kfree(opt);
+ return -EPERM;
+ }
kfree(*optp);
*optp = opt;
return 0;
prev parent reply other threads:[~2026-06-01 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 12:41 [PATCH net] ipv4: restrict IPOPT_SSRR and IPOPT_LSRR options Eric Dumazet
2026-06-01 15:34 ` Ido Schimmel [this message]
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=20260601153401.GA391068@shredder \
--to=idosch@nvidia.com \
--cc=aksecurity@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tamirthesis@gmail.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