From: Hillf Danton <hdanton@sina.com>
To: James Chapman <jchapman@katalix.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com, tparkin@katalix.com,
syzbot+b471b7c936301a59745b@syzkaller.appspotmail.com,
syzbot+c041b4ce3a6dfd1e63e2@syzkaller.appspotmail.com
Subject: Re: [PATCH net-next v2] l2tp: fix possible UAF when cleaning up tunnels
Date: Mon, 8 Jul 2024 19:59:40 +0800 [thread overview]
Message-ID: <20240708115940.892-1-hdanton@sina.com> (raw)
In-Reply-To: <cfee59ae-4807-f384-b525-ce47fa4135e6@katalix.com>
On Mon, 8 Jul 2024 11:06:25 +0100 James Chapman <jchapman@katalix.com>
> On 05/07/2024 11:32, Hillf Danton wrote:
> > On Thu, 4 Jul 2024 16:25:08 +0100 James Chapman <jchapman@katalix.com>
> >> --- a/net/l2tp/l2tp_core.c
> >> +++ b/net/l2tp/l2tp_core.c
> >> @@ -1290,17 +1290,20 @@ static void l2tp_session_unhash(struct l2tp_session *session)
> >> static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
> >> {
> >> struct l2tp_session *session;
> >> - struct list_head *pos;
> >> - struct list_head *tmp;
> >>
> >> spin_lock_bh(&tunnel->list_lock);
> >> tunnel->acpt_newsess = false;
> >> - list_for_each_safe(pos, tmp, &tunnel->session_list) {
> >> - session = list_entry(pos, struct l2tp_session, list);
> >> + for (;;) {
> >> + session = list_first_entry_or_null(&tunnel->session_list,
> >> + struct l2tp_session, list);
> >> + if (!session)
> >> + break;
> >> + l2tp_session_inc_refcount(session);
> >> list_del_init(&session->list);
> >> spin_unlock_bh(&tunnel->list_lock);
> >> l2tp_session_delete(session);
> >> spin_lock_bh(&tunnel->list_lock);
> >> + l2tp_session_dec_refcount(session);
> >
> > Bumping refcount up makes it safe for the current cpu to go thru race
> > after releasing lock, and if it wins the race, dropping refcount makes
> > the peer head on uaf.
>
> Thanks for reviewing this. Can you elaborate on what you mean by "makes
> the peer head on uaf", please?
>
Given race, there are winner and loser. If the current cpu wins the race,
the loser hits uaf once winner drops refcount.
next prev parent reply other threads:[~2024-07-08 12:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 15:25 [PATCH net-next v2] l2tp: fix possible UAF when cleaning up tunnels James Chapman
2024-07-05 10:32 ` Hillf Danton
2024-07-08 10:06 ` James Chapman
2024-07-08 11:59 ` Hillf Danton [this message]
2024-07-08 13:57 ` James Chapman
2024-07-09 9:03 ` Paolo Abeni
2024-07-09 9:29 ` James Chapman
2024-07-09 9:40 ` patchwork-bot+netdevbpf
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=20240708115940.892-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=jchapman@katalix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=syzbot+b471b7c936301a59745b@syzkaller.appspotmail.com \
--cc=syzbot+c041b4ce3a6dfd1e63e2@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--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