From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:39338 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752456AbdK3Pq4 (ORCPT ); Thu, 30 Nov 2017 10:46:56 -0500 Date: Thu, 30 Nov 2017 15:46:42 +0000 From: Al Viro To: Christoph Hellwig Cc: Linus Torvalds , Cong Wang , syzbot , David Miller , LKML , Linux Kernel Network Developers , syzkaller-bugs@googlegroups.com, linux-fsdevel Subject: Re: KASAN: use-after-free Read in sock_release Message-ID: <20171130154641.GH21978@ZenIV.linux.org.uk> References: <94eb2c19e756c0119b055f1afbd0@google.com> <20171130020719.GE21978@ZenIV.linux.org.uk> <20171130131833.GA28908@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171130131833.GA28908@infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Nov 30, 2017 at 05:18:33AM -0800, Christoph Hellwig wrote: > On Thu, Nov 30, 2017 at 02:07:19AM +0000, Al Viro wrote: > > Incidentally, grepping for sys_close() shows another piece of fun in > > net/netfilter/xt_bpf.c. Folks, ONCE DESCRIPTOR IS INSTALLED, THAT'S > > IT; THERE'S NO REMOVING IT ON FAILURE EXITS. sys_close() should > > never, ever be used that way. Sigh... > > Would be great do unexport the thing. Except that we also have > binfmt_misc (which looks legit) and autofs4, which on crack decided > that close() isn't a fun syscall, they'd much rather have an ioctl > that does exactly the same.. Yes, since binfmt_misc one is guaranteed that its descriptor table is not shared - all callchains go through do_execveat_common(), where we'd use unshare_files(). autofs one is... not in good taste, but still safe; there the descriptor is preexisting and it's essentially a weird way of spelling close(2). References from syscall tables are, of course, OK. init/*.c uses are done pretty much from userland - they could have been straight syscalls, if not for the lack of klibc in kernel tree. Everything else, though... IMO we need a whack-a-mole list somewhere; "new callers of sys_close() anywhere outside of init/* and syscall tables" definitely should be on it...