From: Shuah Khan <skhan@linuxfoundation.org>
To: Hillf Danton <hdanton@sina.com>,
syzbot <syzbot+95ce4b142579611ef0a9@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Andrey Konovalov <andreyknvl@google.com>,
Valentina Manea <valentina.manea.m@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
syzkaller-bugs@googlegroups.com,
Shuah Khan <skhan@linuxfoundation.org>
Subject: Re: general protection fault in tomoyo_socket_sendmsg_permission
Date: Fri, 13 Nov 2020 10:14:40 -0700 [thread overview]
Message-ID: <5f71e0c1-d387-6d72-d8e4-edb11cf57f72@linuxfoundation.org> (raw)
In-Reply-To: <20201113120055.11748-1-hdanton@sina.com>
On 11/13/20 5:00 AM, Hillf Danton wrote:
> Thu, 12 Nov 2020 23:21:26 -0800
>> syzbot found the following issue on:
>>
>> HEAD commit: 9dbc1c03 Merge tag 'xfs-5.10-fixes-3' of git://git.kernel...
>> git tree: upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=10453034500000
>> kernel config: https://syzkaller.appspot.com/x/.config?x=1735b7978b1c3721
>> dashboard link: https://syzkaller.appspot.com/bug?extid=95ce4b142579611ef0a9
>> compiler: gcc (GCC) 10.1.0-syz 20200507
>> userspace arch: i386
>>
>> Unfortunately, I don't have any reproducer for this issue yet.
>>
I would like to see the reproducer for this. I just can't reproduce
this problem.
>
> Fix 96c2737716d5 ("usbip: move usbip kernel code out of staging")
> by closing the race between readers and writer of ud->tcp_socket on
> sock shutdown. To do that, add waitqueue for usbip device and make
> writer wait for all readers to go home before releasing the socket.
>
>
> --- a/drivers/usb/usbip/usbip_common.h
> +++ b/drivers/usb/usbip/usbip_common.h
> @@ -277,6 +277,9 @@ struct usbip_device {
> void (*reset)(struct usbip_device *);
> void (*unusable)(struct usbip_device *);
> } eh_ops;
> +
> + atomic_t sk_shutdown_count;
> + wait_queue_head_t sk_shutdown_waitq;
> };
>
> #define kthread_get_run(threadfn, data, namefmt, ...) \
> --- a/drivers/usb/usbip/vhci_hcd.c
> +++ b/drivers/usb/usbip/vhci_hcd.c
> @@ -1008,15 +1008,20 @@ static void vhci_shutdown_connection(str
>
> /* kill threads related to this sdev */
> if (vdev->ud.tcp_rx) {
> + atomic_inc(&ud->sk_shutdown_count);
> kthread_stop_put(vdev->ud.tcp_rx);
> vdev->ud.tcp_rx = NULL;
> }
> if (vdev->ud.tcp_tx) {
> + atomic_inc(&ud->sk_shutdown_count);
> kthread_stop_put(vdev->ud.tcp_tx);
> vdev->ud.tcp_tx = NULL;
> }
> pr_info("stop threads\n");
>
> + wait_event(ud->sk_shutdown_waitq,
> + !atomic_read(&ud->sk_shutdown_count));
> +
> /* active connection is closed */
> if (vdev->ud.tcp_socket) {
> sockfd_put(vdev->ud.tcp_socket);
> @@ -1104,6 +1109,8 @@ static void vhci_device_init(struct vhci
> vdev->ud.eh_ops.reset = vhci_device_reset;
> vdev->ud.eh_ops.unusable = vhci_device_unusable;
>
> + init_waitqueue_head(&vdev->ud.sk_shutdown_waitq);
> +
> usbip_start_eh(&vdev->ud);
> }
>
> --- a/drivers/usb/usbip/vhci_rx.c
> +++ b/drivers/usb/usbip/vhci_rx.c
> @@ -264,5 +264,8 @@ int vhci_rx_loop(void *data)
> vhci_rx_pdu(ud);
> }
>
> + if (atomic_dec_and_test(&ud->sk_shutdown_count))
> + wake_up(&ud->sk_shutdown_waitq);
> +
> return 0;
> }
> --- a/drivers/usb/usbip/vhci_tx.c
> +++ b/drivers/usb/usbip/vhci_tx.c
> @@ -252,5 +252,8 @@ int vhci_tx_loop(void *data)
> usbip_dbg_vhci_tx("pending urbs ?, now wake up\n");
> }
>
> + if (atomic_dec_and_test(&ud->sk_shutdown_count))
> + wake_up(&ud->sk_shutdown_waitq);
> +
> return 0;
> }
>
Without a reproducer, it is hard to verify the fix.
thanks,
-- Shuah
next prev parent reply other threads:[~2020-11-13 17:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-13 7:21 syzbot
[not found] ` <20201113120055.11748-1-hdanton@sina.com>
2020-11-13 17:14 ` Shuah Khan [this message]
2021-01-28 6:09 ` Tetsuo Handa
[not found] ` <2b70d360-a293-4acb-ea6c-2badda5e8b8b@linuxfoundation.org>
2021-01-29 5:48 ` Tetsuo Handa
[not found] ` <6b8da36f-a994-7604-77f4-52e29434605f@linuxfoundation.org>
2021-01-29 17:08 ` Tetsuo Handa
2021-01-29 21:18 ` Shuah Khan
2021-01-30 2:25 ` Tetsuo Handa
2021-02-10 18:17 ` Shuah Khan
2021-02-10 19:07 ` Tetsuo Handa
2021-02-10 19:29 ` Shuah Khan
2021-02-11 1:14 ` Tetsuo Handa
2021-02-12 1:34 ` Shuah Khan
2021-02-12 2:22 ` Tetsuo Handa
2021-02-12 4:58 ` Tetsuo Handa
2021-02-12 20:02 ` Shuah Khan
2021-02-13 10:02 ` Tetsuo Handa
2021-02-13 10:10 ` Greg Kroah-Hartman
2021-02-13 10:10 ` Greg Kroah-Hartman
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=5f71e0c1-d387-6d72-d8e4-edb11cf57f72@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=andreyknvl@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=syzbot+95ce4b142579611ef0a9@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=valentina.manea.m@gmail.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
all inboxes | Powered by JetHome®