public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Jiayuan Chen" <jiayuan.chen@linux.dev>
To: "Eric Dumazet" <edumazet@google.com>
Cc: netdev@vger.kernel.org,
	syzbot+827ae2bfb3a3529333e9@syzkaller.appspotmail.com,
	"D. Wythe" <alibuda@linux.alibaba.com>,
	"Dust Li" <dust.li@linux.alibaba.com>,
	"Sidraya Jayagond" <sidraya@linux.ibm.com>,
	"Wenjia Zhang" <wenjia@linux.ibm.com>,
	"Mahanta Jambigi" <mjambigi@linux.ibm.com>,
	"Tony Lu" <tonylu@linux.alibaba.com>,
	"Wen Gu" <guwen@linux.alibaba.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v1] net/smc: fix NULL dereference and UAF in smc_tcp_syn_recv_sock()
Date: Sat, 07 Mar 2026 04:36:51 +0000	[thread overview]
Message-ID: <8f8b43cb3b8d5b855ffd51f74340214a0b780124@linux.dev> (raw)
In-Reply-To: <CANn89iJ0V6un1un7zjG-J9d4EJQOjTO37s3EQUKTodwPWsXhFQ@mail.gmail.com>

March 7, 2026 at 11:56, "Eric Dumazet" <edumazet@google.com mailto:edumazet@google.com?to=%22Eric%20Dumazet%22%20%3Cedumazet%40google.com%3E > wrote:


> 
> On Sat, Mar 7, 2026 at 4:22 AM Jiayuan Chen <jiayuan.chen@linux.dev> wrote:
> 
[...]
> >  diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> >  index d0119afcc6a1..21218b9b0f9a 100644
> >  --- a/net/smc/af_smc.c
> >  +++ b/net/smc/af_smc.c
> >  @@ -131,7 +131,14 @@ static struct sock *smc_tcp_syn_recv_sock(const struct sock *sk,
> >  struct smc_sock *smc;
> >  struct sock *child;
> > 
> >  + read_lock_bh(&((struct sock *)sk)->sk_callback_lock);
> > 
> This will not survive a SYN flood attack.
> 
> Please use RCU instead.
> 
> > 
> > smc = smc_clcsock_user_data(sk);
> >  + if (!smc) {
> >  + read_unlock_bh(&((struct sock *)sk)->sk_callback_lock);
> >  + return NULL;
> >  + }
> >  + sock_hold(&smc->sk);
> > 
> If you must take a refcount, use
> 
> if (!refcount_inc_not_zero(&smc->sk->sk_refcnt)) {
>  rcu_read_unlock();
>  return NULL;
> }

Thanks for the review.

Will try rcu_read_lock() + refcount_inc_not_zero()
and set SOCK_RCU_FREE on the listen socket.

      reply	other threads:[~2026-03-07  4:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-07  3:21 [PATCH net v1] net/smc: fix NULL dereference and UAF in smc_tcp_syn_recv_sock() Jiayuan Chen
2026-03-07  3:56 ` Eric Dumazet
2026-03-07  4:36   ` Jiayuan Chen [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=8f8b43cb3b8d5b855ffd51f74340214a0b780124@linux.dev \
    --to=jiayuan.chen@linux.dev \
    --cc=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjambigi@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sidraya@linux.ibm.com \
    --cc=syzbot+827ae2bfb3a3529333e9@syzkaller.appspotmail.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=wenjia@linux.ibm.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