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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable 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 7F777C31E5B for ; Tue, 18 Jun 2019 20:49:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 55DD22082C for ; Tue, 18 Jun 2019 20:49:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730378AbfFRUtm (ORCPT ); Tue, 18 Jun 2019 16:49:42 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:52184 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730171AbfFRUtl (ORCPT ); Tue, 18 Jun 2019 16:49:41 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hdL2r-0003xC-HG; Tue, 18 Jun 2019 20:49:33 +0000 Date: Tue, 18 Jun 2019 21:49:33 +0100 From: Al Viro To: Tetsuo Handa Cc: linux-fsdevel@vger.kernel.org, syzbot , jmorris@namei.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, serge@hallyn.com, syzkaller-bugs@googlegroups.com, takedakn@nttdata.co.jp, "David S. Miller" Subject: Re: [PATCH] tomoyo: Don't check open/getattr permission on sockets. Message-ID: <20190618204933.GE17978@ZenIV.linux.org.uk> References: <0000000000004f43fa058a97f4d3@google.com> <201906060520.x565Kd8j017983@www262.sakura.ne.jp> <1b5722cc-adbc-035d-5ca1-9aa56e70d312@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sun, Jun 16, 2019 at 03:49:00PM +0900, Tetsuo Handa wrote: > Hello, Al. > > Q1: Do you agree that we should fix TOMOYO side rather than SOCKET_I()->sk > management. You do realize that sockets are not unique in that respect, right? All kinds of interesting stuff can be accessed via /proc/*/fd/*, and it _can_ be closed under you. So I'd suggest checking how your code copes with similar for pipes, FIFOs, epoll, etc., accessed that way... We are _not_ going to be checking that in fs/open.c - the stuff found via /proc/*/fd/* can have the associated file closed by the time we get to calling ->open() and we won't know that until said call. > Q2: Do you see any problem with using f->f_path.dentry->d_inode ? > Do we need to use d_backing_inode() or d_inode() ? Huh? What's wrong with file_inode(f), in the first place? And just when can that be NULL, while we are at it? > > static int tomoyo_inode_getattr(const struct path *path) > > { > > + /* It is not safe to call tomoyo_get_socket_name(). */ > > + if (path->dentry->d_inode && S_ISSOCK(path->dentry->d_inode->i_mode)) > > + return 0; Can that be called for a negative?