From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0648C433E6 for ; Mon, 15 Mar 2021 14:43:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CCFA264F2A for ; Mon, 15 Mar 2021 14:43:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234259AbhCOOm7 (ORCPT ); Mon, 15 Mar 2021 10:42:59 -0400 Received: from imap3.hz.codethink.co.uk ([176.9.8.87]:56398 "EHLO imap3.hz.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237391AbhCOOlt (ORCPT ); Mon, 15 Mar 2021 10:41:49 -0400 Received: from cpc79921-stkp12-2-0-cust288.10-2.cable.virginm.net ([86.16.139.33] helo=[192.168.0.18]) by imap3.hz.codethink.co.uk with esmtpsa (Exim 4.92 #3 (Debian)) id 1lLoPf-0004SH-9m; Mon, 15 Mar 2021 14:41:43 +0000 Subject: Re: [syzbot] BUG: unable to handle kernel access to user memory in sock_ioctl To: Dmitry Vyukov Cc: syzbot , Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv , andrii@kernel.org, Alexei Starovoitov , bpf , Daniel Borkmann , David Miller , John Fastabend , Martin KaFai Lau , kpsingh@kernel.org, Jakub Kicinski , LKML , netdev , Song Liu , syzkaller-bugs , Yonghong Song References: <00000000000096cdaa05bd32d46f@google.com> From: Ben Dooks Organization: Codethink Limited. Message-ID: Date: Mon, 15 Mar 2021 14:41:42 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On 15/03/2021 11:52, Dmitry Vyukov wrote: > On Mon, Mar 15, 2021 at 12:30 PM Ben Dooks wrote: >> >> On 14/03/2021 11:03, Dmitry Vyukov wrote: >>> On Sun, Mar 14, 2021 at 11:01 AM Dmitry Vyukov wrote: >>>>> On Wed, Mar 10, 2021 at 7:28 PM syzbot >>>>> wrote: >>>>>> >>>>>> Hello, >>>>>> >>>>>> syzbot found the following issue on: >>>>>> >>>>>> HEAD commit: 0d7588ab riscv: process: Fix no prototype for arch_dup_tas.. >>>>>> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git fixes >>>>>> console output: https://syzkaller.appspot.com/x/log.txt?x=122c343ad00000 >>>>>> kernel config: https://syzkaller.appspot.com/x/.config?x=e3c595255fb2d136 >>>>>> dashboard link: https://syzkaller.appspot.com/bug?extid=c23c5421600e9b454849 >>>>>> userspace arch: riscv64 >>>>>> >>>>>> Unfortunately, I don't have any reproducer for this issue yet. >>>>>> >>>>>> IMPORTANT: if you fix the issue, please add the following tag to the commit: >>>>>> Reported-by: syzbot+c23c5421600e9b454849@syzkaller.appspotmail.com >>>>> >>>>> +riscv maintainers >>>>> >>>>> Another case of put_user crashing. >>>> >>>> There are 58 crashes in sock_ioctl already. Somehow there is a very >>>> significant skew towards crashing with this "user memory without >>>> uaccess routines" in schedule_tail and sock_ioctl of all places in the >>>> kernel that use put_user... This looks very strange... Any ideas >>>> what's special about these 2 locations? >>> >>> I could imagine if such a crash happens after a previous stack >>> overflow and now task data structures are corrupted. But f_getown does >>> not look like a function that consumes way more than other kernel >>> syscalls... >> >> The last crash I looked at suggested somehow put_user got re-entered >> with the user protection turned back on. Either there is a path through >> one of the kernel handlers where this happens or there's something >> weird going on with qemu. > > Is there any kind of tracking/reporting that would help to localize > it? I could re-reproduce with that code. I'm not sure. I will have a go at debugging on qemu today just to make sure I can reproduce here before I have to go into the office and fix my Icicle board for real hardware tests. I think my first plan post reproduction is to stuff some trace points into the fault handlers to see if we can get a idea of faults being processed, etc. Maybe also add a check in the fault handler to see if the fault was in a fixable region and post an error if that happens / maybe retry the instruction with the relevant SR_SUM flag set. Hopefully tomorrow I can get a run on real hardware to confirm. Would have been better if the Unmatched board I ordered last year would turn up. -- Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius https://www.codethink.co.uk/privacy.html