public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: "D. Wythe" <alibuda@linux.alibaba.com    >
To: Wang Liang <wangliang74@huawei.com>
Cc: Paolo Abeni <pabeni@redhat.com>,
	wenjia@linux.ibm.com, jaka@linux.ibm.com,
	alibuda@linux.alibaba.com, tonylu@linux.alibaba.com,
	guwen@linux.alibaba.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, horms@kernel.org,
	ubraun@linux.vnet.ibm.com, yanjun.zhu@linux.dev,
	yuehaibing@huawei.com, zhangchangzhong@huawei.com,
	linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net/smc: fix general protection fault in __smc_diag_dump
Date: Wed, 2 Apr 2025 15:20:10 +0800	[thread overview]
Message-ID: <20250402072010.GA110656@j66a10360.sqa.eu95> (raw)
In-Reply-To: <99f284be-bf1d-4bc4-a629-77b268522fff@huawei.com>

On Wed, Apr 02, 2025 at 10:37:24AM +0800, Wang Liang wrote:
> 
> 在 2025/4/1 19:01, Paolo Abeni 写道:
> >On 3/31/25 10:10 AM, Wang Liang wrote:
> >>diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> >>index 3e6cb35baf25..454801188514 100644
> >>--- a/net/smc/af_smc.c
> >>+++ b/net/smc/af_smc.c
> >>@@ -371,6 +371,7 @@ void smc_sk_init(struct net *net, struct sock *sk, int protocol)
> >>  	sk->sk_protocol = protocol;
> >>  	WRITE_ONCE(sk->sk_sndbuf, 2 * READ_ONCE(net->smc.sysctl_wmem));
> >>  	WRITE_ONCE(sk->sk_rcvbuf, 2 * READ_ONCE(net->smc.sysctl_rmem));
> >>+	smc->clcsock = NULL;
> >>  	INIT_WORK(&smc->tcp_listen_work, smc_tcp_listen_work);
> >>  	INIT_WORK(&smc->connect_work, smc_connect_work);
> >>  	INIT_DELAYED_WORK(&smc->conn.tx_work, smc_tx_work);
> >The syzkaller report has a few reproducers, have you tested this? AFAICS
> >the smc socket is already zeroed on allocation by sk_alloc().
> 
> 
> Yes, I test it by the C repro:
> https://syzkaller.appspot.com/text?tag=ReproC&x=13d2dc98580000
> 
> The C repro is provided by the 2025/02/27 15:16 crash from
>   https://syzkaller.appspot.com/bug?extid=271fed3ed6f24600c364
> 
> After apply my patch, the crash no longer happens when running the C repro.
> 
> "the smc socket is already zeroed on allocation by sk_alloc()", That
> is right.
> However, smc->clcsock may be modified indirectly in inet6_create().
> The process like this:
> 
>   __sys_socket
>     __sys_socket_create
>       sock_create
>         __sock_create
>           # pf->create
>           inet6_create
>             // init smc->clcsock = 0
>             sk = sk_alloc()
> 
>             // set smc->clcsock to invalid address
>             inet = inet_sk(sk);
>             inet_assign_bit(IS_ICSK, sk, INET_PROTOSW_ICSK & answer_flags);
>             inet6_set_bit(MC6_LOOP, sk);
>             inet6_set_bit(MC6_ALL, sk);
> 
>             smc_inet_init_sock
>               smc_sk_init
>                 // add sk to smc_hash
>                 smc_hash_sk
>                   sk_add_node(sk, head);
>               smc_create_clcsk
>                 // set smc->clcsock
>                 sock_create_kern(..., &smc->clcsock);)
> 
> So initialize smc->clcsock to NULL explicitly in smc_sk_init() can fix
> this crash scene. If the problem can be reproduced after this patch, I
> guess it is not the same reason, and fix it by another patch is more
> appropriate.
> 

This is actually because the current smc_sock is not an inet_sock,
leading to two modules simultaneously modifying the same offset in
memory but interpreting its structure differently. I previously proposed
embedding an inet(6)_sock at the beginning of smc_sock, but the
community had some objections...

I'm not sure on the community's current stance on this matter, but if a
fix is absolutely necessary, my recommendation would still be to embed
an inet(6)_sock within the smc_sock structure

D.

> >



> >/P
> >
> >

  reply	other threads:[~2025-04-02  7:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-31  8:10 [PATCH net] net/smc: fix general protection fault in __smc_diag_dump Wang Liang
2025-04-01 11:01 ` Paolo Abeni
2025-04-01 13:31   ` Zhu Yanjun
2025-04-02  2:37   ` Wang Liang
2025-04-02  7:20     ` D. Wythe [this message]
2025-04-03  7:09       ` Wang Liang
2025-04-03 11:55 ` Wenjia Zhang
2025-04-10  3:11   ` Wang Liang
  -- strict thread matches above, loose matches on Subject: below --
2025-09-22 12:18 Wang Liang
2025-09-25 14:32 ` Eric Dumazet
2025-09-25 18:46   ` Kuniyuki Iwashima
2025-09-25 18:53     ` Eric Dumazet
2025-09-25 19:25       ` Kuniyuki Iwashima
2025-09-25 19:37         ` Eric Dumazet
2025-09-25 19:51           ` Kuniyuki Iwashima
2025-09-26  8:42             ` Wang Liang
2025-10-14  2:04               ` D. Wythe

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=20250402072010.GA110656@j66a10360.sqa.eu95 \
    --to=alibuda@linux.alibaba.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=horms@kernel.org \
    --cc=jaka@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tonylu@linux.alibaba.com \
    --cc=ubraun@linux.vnet.ibm.com \
    --cc=wangliang74@huawei.com \
    --cc=wenjia@linux.ibm.com \
    --cc=yanjun.zhu@linux.dev \
    --cc=yuehaibing@huawei.com \
    --cc=zhangchangzhong@huawei.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