From: Pavel Skripkin <paskripkin@gmail.com>
To: syzbot <syzbot+e6741b97d5552f97c24d@syzkaller.appspotmail.com>
Cc: davem@davemloft.net, devicetree@vger.kernel.org,
frowand.list@gmail.com, gregkh@linuxfoundation.org,
jmaloy@redhat.com, kuba@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, rafael@kernel.org, robh+dt@kernel.org,
robh@kernel.org, syzkaller-bugs@googlegroups.com,
tipc-discussion@lists.sourceforge.net, ying.xue@windriver.com
Subject: Re: [syzbot] KASAN: use-after-free Read in tipc_recvmsg
Date: Fri, 23 Jul 2021 19:36:11 +0300 [thread overview]
Message-ID: <20210723193611.746e7071@gmail.com> (raw)
In-Reply-To: <00000000000017e9a105c768f7a0@google.com>
[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]
On Sun, 18 Jul 2021 10:15:19 -0700
syzbot <syzbot+e6741b97d5552f97c24d@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: ab0441b4a920 Merge branch 'vmxnet3-version-6'
> git tree: net-next
> console output:
> https://syzkaller.appspot.com/x/log.txt?x=1744ac6a300000 kernel
> config: https://syzkaller.appspot.com/x/.config?x=da140227e4f25b17
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=e6741b97d5552f97c24d syz
> repro:
> https://syzkaller.appspot.com/x/repro.syz?x=13973a74300000 C
> reproducer: https://syzkaller.appspot.com/x/repro.c?x=17ffc902300000
>
> The issue was bisected to:
>
> commit 67a3156453859ceb40dc4448b7a6a99ea0ad27c7
> Author: Rob Herring <robh@kernel.org>
> Date: Thu May 27 19:45:47 2021 +0000
>
> of: Merge of_address_to_resource() and
> of_pci_address_to_resource() implementations
>
> bisection log:
> https://syzkaller.appspot.com/x/bisect.txt?x=129b0438300000 final
> oops: https://syzkaller.appspot.com/x/report.txt?x=119b0438300000
> console output:
> https://syzkaller.appspot.com/x/log.txt?x=169b0438300000
>
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit: Reported-by:
> syzbot+e6741b97d5552f97c24d@syzkaller.appspotmail.com Fixes:
> 67a315645385 ("of: Merge of_address_to_resource() and
> of_pci_address_to_resource() implementations")
>
> ==================================================================
> BUG: KASAN: use-after-free in tipc_recvmsg+0xf77/0xf90
> net/tipc/socket.c:1979 Read of size 4 at addr ffff8880328cf1c0 by
> task kworker/u4:0/8
>
Since code accesing skb_cb after possible kfree_skb() call let's just
store bytes_read to variable and use it instead of acessing
skb_cb->bytes_read
#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
With regards,
Pavel Skripkin
[-- Attachment #2: 0001-tipc-fix-use-after-free-in-tipc_recvmsg.patch --]
[-- Type: text/x-patch, Size: 1230 bytes --]
From 9f81f8574bfc1183209022b405848e01c35b86e6 Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <paskripkin@gmail.com>
Date: Fri, 23 Jul 2021 19:34:06 +0300
Subject: [PATCH] tipc: fix use-after-free in tipc_recvmsg
/* .. */
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
net/tipc/socket.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 9b0b311c7ec1..0cf2468d209d 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1886,6 +1886,7 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
struct sk_buff *skb;
bool grp_evt;
long timeout;
+ unsigned int bytes_read;
/* Catch invalid receive requests */
if (unlikely(!buflen))
@@ -1973,10 +1974,13 @@ static int tipc_recvmsg(struct socket *sock, struct msghdr *m,
tipc_node_distr_xmit(sock_net(sk), &xmitq);
}
- if (!skb_cb->bytes_read)
+ /* To avoid accesing skb_cb after tsk_advance_rx_queue */
+ bytes_read = skb_cb->bytes_read;
+
+ if (!bytes_read)
tsk_advance_rx_queue(sk);
- if (likely(!connected) || skb_cb->bytes_read)
+ if (likely(!connected) || bytes_read)
goto exit;
/* Send connection flow control advertisement when applicable */
--
2.32.0
next prev parent reply other threads:[~2021-07-23 16:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-18 17:15 [syzbot] KASAN: use-after-free Read in tipc_recvmsg syzbot
2021-07-23 16:36 ` Pavel Skripkin [this message]
2021-07-23 16:41 ` Xin Long
2021-07-23 16:52 ` Pavel Skripkin
2021-07-23 16:49 ` Pavel Skripkin
2021-07-23 23:10 ` syzbot
2021-07-23 22:51 ` syzbot
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=20210723193611.746e7071@gmail.com \
--to=paskripkin@gmail.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robh+dt@kernel.org \
--cc=robh@kernel.org \
--cc=syzbot+e6741b97d5552f97c24d@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.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).