From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <edumazet@google.com>
Cc: <davem@davemloft.net>, <ematsumiya@suse.de>, <horms@kernel.org>,
<kuba@kernel.org>, <kuni1840@gmail.com>, <kuniyu@amazon.com>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>,
<peterz@infradead.org>, <sfrench@samba.org>,
<stable@vger.kernel.org>, <wangzhaolong1@huawei.com>,
<willemb@google.com>
Subject: Re: [PATCH v2 net] net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod.
Date: Mon, 7 Apr 2025 08:52:02 -0700 [thread overview]
Message-ID: <20250407155204.16501-1-kuniyu@amazon.com> (raw)
In-Reply-To: <CANn89iKc_7RNordD-YcZv9DPw8CNubnDVkhgYGma20q4cxgAdw@mail.gmail.com>
From: Eric Dumazet <edumazet@google.com>
Date: Mon, 7 Apr 2025 13:21:11 +0200
> > diff --git a/net/core/sock.c b/net/core/sock.c
> > index 323892066def..d426c5f8e20f 100644
> > --- a/net/core/sock.c
> > +++ b/net/core/sock.c
> > @@ -2130,6 +2130,8 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
> > */
> > static inline void sock_lock_init(struct sock *sk)
> > {
> > + sk_owner_clear(sk);
> > +
> > if (sk->sk_kern_sock)
> > sock_lock_init_class_and_name(
> > sk,
> > @@ -2324,6 +2326,8 @@ static void __sk_destruct(struct rcu_head *head)
> > __netns_tracker_free(net, &sk->ns_tracker, false);
> > net_passive_dec(net);
> > }
> > +
> > + sk_owner_put(sk);
>
> I am not convinced that the socket lock can be used after this point,
> now or in the future.
>
> > sk_prot_free(sk->sk_prot_creator, sk);
> > }
>
> Maybe move this in sk_prot_free() instead ?
Makes sense.
Will move sk_owner_put() to sk_prot_free() in v3.
Thanks!
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index 323892066def..9ab149d1584c 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -2226,6 +2226,9 @@ static void sk_prot_free(struct proto *prot,
> struct sock *sk)
> cgroup_sk_free(&sk->sk_cgrp_data);
> mem_cgroup_sk_free(sk);
> security_sk_free(sk);
> +
> + sk_owner_put(sk);
> +
> if (slab != NULL)
> kmem_cache_free(slab, sk);
> else
prev parent reply other threads:[~2025-04-07 15:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-03 20:34 [PATCH v2 net] net: Fix null-ptr-deref by sock_lock_init_class_and_name() and rmmod Kuniyuki Iwashima
2025-04-07 10:45 ` Simon Horman
2025-04-07 15:46 ` Kuniyuki Iwashima
2025-04-07 11:21 ` Eric Dumazet
2025-04-07 15:52 ` Kuniyuki Iwashima [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=20250407155204.16501-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ematsumiya@suse.de \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuni1840@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peterz@infradead.org \
--cc=sfrench@samba.org \
--cc=stable@vger.kernel.org \
--cc=wangzhaolong1@huawei.com \
--cc=willemb@google.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).