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=-7.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT 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 B9DB6C43381 for ; Tue, 12 Mar 2019 16:35:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 919932083D for ; Tue, 12 Mar 2019 16:35:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726451AbfCLQfo (ORCPT ); Tue, 12 Mar 2019 12:35:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:56426 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726272AbfCLQfo (ORCPT ); Tue, 12 Mar 2019 12:35:44 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A1160AF01; Tue, 12 Mar 2019 16:35:43 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 496531E426A; Tue, 12 Mar 2019 17:35:43 +0100 (CET) Date: Tue, 12 Mar 2019 17:35:43 +0100 From: Jan Kara To: Amir Goldstein Cc: Jan Kara , Andrew Morton , linux-fsdevel Subject: Re: Fw: WARNING: bad usercopy in fanotify_read Message-ID: <20190312163543.GD32521@quack2.suse.cz> References: <20190311163004.68f936ab4119a7e8dd272f59@linux-foundation.org> <20190312114528.GA32521@quack2.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue 12-03-19 14:59:27, Amir Goldstein wrote: > On Tue, Mar 12, 2019 at 1:45 PM Jan Kara wrote: > > > > Thanks for forwarding Andrew! > > > > On Mon 11-03-19 16:30:04, Andrew Morton wrote: > > > fyi > > > > > > Begin forwarded message: > > > > > > Date: Mon, 11 Mar 2019 13:42:06 -0700 > > > From: syzbot > > > To: akpm@linux-foundation.org, cai@lca.pw, crecklin@redhat.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com > > > Subject: WARNING: bad usercopy in fanotify_read > > > > > > > > > Hello, > > > > > > syzbot found the following crash on: > > > > > > HEAD commit: 12ad143e Merge branch 'perf-urgent-for-linus' of git://git.. > > > git tree: upstream > > > console output: https://syzkaller.appspot.com/x/log.txt?x=12776f57200000 > > > kernel config: https://syzkaller.appspot.com/x/.config?x=e9d91b7192a5e96e > > > dashboard link: https://syzkaller.appspot.com/bug?extid=2c49971e251e36216d1f > > > compiler: gcc (GCC) 9.0.0 20181231 (experimental) > > > userspace arch: amd64 > > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1287516f200000 > > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17ee410b200000 > > > > > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > > > Reported-by: syzbot+2c49971e251e36216d1f@syzkaller.appspotmail.com > > > > > > ------------[ cut here ]------------ > > > Bad or missing usercopy whitelist? Kernel memory exposure attempt detected > > > from SLAB object 'fanotify_event' (offset 40, size 8)! > > > WARNING: CPU: 1 PID: 7649 at mm/usercopy.c:78 usercopy_warn+0xeb/0x110 > > > mm/usercopy.c:78 > > > > Yeah, right. We need to create fanotify_event cache so that copying of > > fanotify_event.fid.fh to userspace is allowed. Sadly the area is unioned > > with a possible slab pointer so that won't be protected from leaking but > > life is not perfect. Amir, something like attached patch? > > I agree. We could do something like this, to first copy the inline fh > from slab to short stack buf: > > static inline void *fanotify_fid_fh_user(struct fanotify_fid *fid, > unsigned int fh_len, char *fh_buf) > { > if (fh_len > FANOTIFY_INLINE_FH_LEN) > return fid->ext_fh; > memcpy(fh_buf, fid->fh, fh_len); > return fh_buf; > } > > But I don't think we should bother. OK, pushed my fix to my tree. Honza -- Jan Kara SUSE Labs, CR