netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guvenc Gulce <guvenc@linux.ibm.com>
To: Pavel Skripkin <paskripkin@gmail.com>,
	syzbot <syzbot+5dda108b672b54141857@syzkaller.appspotmail.com>
Cc: coreteam@netfilter.org, davem@davemloft.net, dsahern@kernel.org,
	fw@strlen.de, kadlec@netfilter.org, kgraul@linux.ibm.com,
	kuba@kernel.org, linux-kernel@vger.kernel.org,
	linux-s390@vger.kernel.org, netdev@vger.kernel.org,
	netfilter-devel@vger.kernel.org, pablo@netfilter.org,
	syzkaller-bugs@googlegroups.com, yoshfuji@linux-ipv6.org
Subject: Re: [syzbot] general protection fault in smc_tx_sendmsg
Date: Mon, 21 Jun 2021 19:18:56 +0200	[thread overview]
Message-ID: <c8fd3740-8233-2b14-1fc9-57ecebc31ad8@linux.ibm.com> (raw)
In-Reply-To: <20210621175603.40ac6eaa@gmail.com>



On 21/06/2021 16:56, Pavel Skripkin wrote:
> On Sun, 20 Jun 2021 16:22:16 -0700
> syzbot <syzbot+5dda108b672b54141857@syzkaller.appspotmail.com> wrote:
>
>> Hello,
>>
>> syzbot found the following issue on:
>>
>> HEAD commit:    0c337952 Merge tag 'wireless-drivers-next-2021-06-16'
>> of g.. git tree:       net-next
>> console output:
>> https://syzkaller.appspot.com/x/log.txt?x=1621de10300000 kernel
>> config:  https://syzkaller.appspot.com/x/.config?x=a6380da8984033f1
>> dashboard link:
>> https://syzkaller.appspot.com/bug?extid=5dda108b672b54141857 syz
>> repro:
>> https://syzkaller.appspot.com/x/repro.syz?x=121d2d20300000 C
>> reproducer:   https://syzkaller.appspot.com/x/repro.c?x=100bd768300000
>>
>> The issue was bisected to:
>>
>> commit f9006acc8dfe59e25aa75729728ac57a8d84fc32
>> Author: Florian Westphal <fw@strlen.de>
>> Date:   Wed Apr 21 07:51:08 2021 +0000
>>
>>      netfilter: arp_tables: pass table pointer via nf_hook_ops
>>
> I think, bisection is wrong this time :)
>
> It should be e0e4b8fa533858532f1b9ea9c6a4660d09beb37a ("net/smc: Add SMC
> statistics support")
>
>
> Some debug results:
>
> syzkaller repro just opens the socket and calls sendmsg. Ftrace log:
>
>
>   0)               |  smc_create() {
>   0)               |    smc_sock_alloc() {
>   0) + 88.493 us   |      smc_hash_sk();
>   0) ! 131.487 us  |    }
>   0) ! 189.912 us  |  }
>   0)               |  smc_sendmsg() {
>   0)   2.808 us    |    smc_tx_sendmsg();
>   0) ! 148.484 us  |  }
>
>
> That means, that smc_buf_create() wasn't called at all, so we need to
> check sndbuf_desc before dereferencing
>
> Something like this should work
>
> diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
> index 075c4f4b4..e24071b12 100644
> --- a/net/smc/smc_tx.c
> +++ b/net/smc/smc_tx.c
> @@ -154,7 +154,7 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
>   		goto out_err;
>   	}
>   
> -	if (len > conn->sndbuf_desc->len)
> +	if (conn->sndbuf_desc && len > conn->sndbuf_desc->len)
>   		SMC_STAT_RMB_TX_SIZE_SMALL(smc, !conn->lnk);
>   
>   	if (len > conn->peer_rmbe_size)
>
>
> Thoughts?
>
>
> +CC Guvenc Gulce
>
>
> With regards,
> Pavel Skripkin

Thanks for analyzing the cause. Your approach would work but I would prefer that we
check the state of the socket before doing the statistics relevant if check. This will ensure
that smc_buf_create() was already called.
I am testing the fix at the moment which would look like the following:

diff --git a/net/smc/smc_tx.c b/net/smc/smc_tx.c
index 075c4f4b41cf..289025cd545a 100644
--- a/net/smc/smc_tx.c
+++ b/net/smc/smc_tx.c
@@ -154,6 +154,9 @@ int smc_tx_sendmsg(struct smc_sock *smc, struct msghdr *msg, size_t len)
                 goto out_err;
         }

+       if (sk->sk_state == SMC_INIT)
+               return -ENOTCONN;
+
         if (len > conn->sndbuf_desc->len)
                 SMC_STAT_RMB_TX_SIZE_SMALL(smc, !conn->lnk);



  reply	other threads:[~2021-06-21 17:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-20 23:22 [syzbot] general protection fault in smc_tx_sendmsg syzbot
2021-06-21 14:56 ` Pavel Skripkin
2021-06-21 17:18   ` Guvenc Gulce [this message]
2021-06-21 19:04     ` Pavel Skripkin

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=c8fd3740-8233-2b14-1fc9-57ecebc31ad8@linux.ibm.com \
    --to=guvenc@linux.ibm.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=kgraul@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=paskripkin@gmail.com \
    --cc=syzbot+5dda108b672b54141857@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=yoshfuji@linux-ipv6.org \
    /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).