From: James Chapman <jchapman@katalix.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
Tom Parkin <tparkin@katalix.com>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH] l2tp: Support several sockets with same IP/port quadruple
Date: Tue, 7 May 2024 09:06:35 +0100 [thread overview]
Message-ID: <66998255-7078-8d4b-6efa-fa7b0751176e@katalix.com> (raw)
In-Reply-To: <20240506214424.4wddiwjdpdl2gf4w@begin>
Hi Samuel,
On 06/05/2024 22:44, Samuel Thibault wrote:
> Hello,
>
> James Chapman, le ven. 03 mai 2024 12:36:14 +0100, a ecrit:
>
>>> + /* We are receiving trafic for another tunnel, probably
>>> + * because we have several tunnels between the same
>>> + * IP/port quadruple, look it up.
>>> + */
>>> + struct l2tp_tunnel *alt_tunnel;
>>> +
>>> + alt_tunnel = l2tp_tunnel_get(tunnel->l2tp_net, tunnel_id);
>> This misses a check that alt_tunnel's protocol version matches the header.
>> Move the existing header version check to after this fragment?
> We need to check the version before getting the tunnel id, which we need
> to look up the struct l2tp_tunnel :)
I was referring to the following code fragment which is before your change:
> version = hdrflags & L2TP_HDR_VER_MASK;
> if (version != tunnel->version) {
> pr_debug_ratelimited("%s: recv protocol version mismatch: got
%d expected %d\n",
> tunnel->name, version, tunnel->version);
> goto invalid;
> }
The tunnel->version check should now be done after the tunnel pointer is
possibly modified by your code.
Also, if the tunnel pointer from sk_user_data isn't trusted due to
5-tuple aliasing, l2tp_udp_recv_core should compare with the local
'version' variable, not tunnel->version, when parsing the L2TP IDs e.g.:
> if (version == L2TP_HDR_VER_2) {
> /* If length is present, skip it */
otherwise, L2TPv2 socket aliasing will still not work properly if one or
more L2TPv3 sockets also alias L2TPv2 sockets, even if there is no
L2TPv3 traffic.
next prev parent reply other threads:[~2024-05-07 8:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-02 23:14 [PATCH] l2tp: Support several sockets with same IP/port quadruple Samuel Thibault
2024-05-03 11:36 ` James Chapman
2024-05-06 21:44 ` Samuel Thibault
2024-05-07 8:06 ` James Chapman [this message]
2024-05-07 10:29 ` Samuel Thibault
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=66998255-7078-8d4b-6efa-fa7b0751176e@katalix.com \
--to=jchapman@katalix.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=samuel.thibault@ens-lyon.org \
--cc=tparkin@katalix.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).