public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, g.nault@alphalink.fr,
	Cong Wang <cong.wang@bytedance.com>,
	syzbot+52866e24647f9a23403f@syzkaller.appspotmail.com,
	syzbot+94cc2a66fc228b23f360@syzkaller.appspotmail.com,
	Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
	Jakub Sitnicki <jakub@cloudflare.com>,
	Eric Dumazet <edumazet@google.com>
Subject: Re: [Patch net 2/2] l2tp: close all race conditions in l2tp_tunnel_register()
Date: Sat, 7 Jan 2023 10:41:41 -0800	[thread overview]
Message-ID: <Y7m85XdeKwi9+Ytt@x130> (raw)
In-Reply-To: <20230105191339.506839-3-xiyou.wangcong@gmail.com>

On 05 Jan 11:13, Cong Wang wrote:
>From: Cong Wang <cong.wang@bytedance.com>
>
>The code in l2tp_tunnel_register() is racy in several ways:
>
>1. It modifies the tunnel socket _after_ publishing it.
>
>2. It calls setup_udp_tunnel_sock() on an existing socket without
>   locking.
>
>3. It changes sock lock class on fly, which triggers many syzbot
>   reports.
>
>This patch amends all of them by moving socket initialization code
>before publishing and under sock lock. As suggested by Jakub, the
>l2tp lockdep class is not necessary as we can just switch to
>bh_lock_sock_nested().
>
>Fixes: 37159ef2c1ae ("l2tp: fix a lockdep splat")
>Fixes: 6b9f34239b00 ("l2tp: fix races in tunnel creation")

This patch relies on the previous one which doesn't include any tags.
If you are interested in this making it to -stable then maybe you need to
add those tags to the previous commit ?

I am not really familiar with the issue and how socket locks should work
here, but code wise LGTM.

Reviewed-by: Saeed Mahameed <saeed@kernel.org>


>Reported-by: syzbot+52866e24647f9a23403f@syzkaller.appspotmail.com
>Reported-by: syzbot+94cc2a66fc228b23f360@syzkaller.appspotmail.com
>Reported-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>Cc: Guillaume Nault <g.nault@alphalink.fr>
>Cc: Jakub Sitnicki <jakub@cloudflare.com>
>Cc: Eric Dumazet <edumazet@google.com>
>Signed-off-by: Cong Wang <cong.wang@bytedance.com>


  reply	other threads:[~2023-01-07 18:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 19:13 [Patch net 0/2] l2tp: fix race conditions in l2tp_tunnel_register() Cong Wang
2023-01-05 19:13 ` [Patch net 1/2] l2tp: convert l2tp_tunnel_list to idr Cong Wang
2023-01-07 18:25   ` Saeed Mahameed
2023-01-07 19:48     ` Cong Wang
2023-01-07 19:48   ` Guillaume Nault
2023-01-09  9:55     ` Tom Parkin
2023-01-10  6:49     ` Cong Wang
2023-01-05 19:13 ` [Patch net 2/2] l2tp: close all race conditions in l2tp_tunnel_register() Cong Wang
2023-01-07 18:41   ` Saeed Mahameed [this message]
2023-01-07 19:52     ` Cong Wang
2023-01-10  1:36       ` Jakub Kicinski

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=Y7m85XdeKwi9+Ytt@x130 \
    --to=saeed@kernel.org \
    --cc=cong.wang@bytedance.com \
    --cc=edumazet@google.com \
    --cc=g.nault@alphalink.fr \
    --cc=jakub@cloudflare.com \
    --cc=netdev@vger.kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=syzbot+52866e24647f9a23403f@syzkaller.appspotmail.com \
    --cc=syzbot+94cc2a66fc228b23f360@syzkaller.appspotmail.com \
    --cc=xiyou.wangcong@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