Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933275AbcCKRXy (ORCPT ); Fri, 11 Mar 2016 12:23:54 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:33043 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933131AbcCKRXw (ORCPT ); Fri, 11 Mar 2016 12:23:52 -0500 MIME-Version: 1.0 In-Reply-To: <20160311135952.57a44931@lxorguk.ukuu.org.uk> References: <20160302040947.16685.42926.stgit@birch.djwong.org> <20160302225601.GB21890@birch.djwong.org> <20160303180924.GA4116@infradead.org> <20160303223952.GE24012@thunk.org> <20160303231050.GU29057@dastard> <20160309230819.GB3949@thunk.org> <56E18B9B.5070503@gmail.com> <56E24CA5.3030702@redhat.com> <20160311135952.57a44931@lxorguk.ukuu.org.uk> Date: Fri, 11 Mar 2016 09:23:50 -0800 X-Google-Sender-Auth: 3-bNZwT9_OeCUT6mP1NcAAjFMHw Message-ID: Subject: Re: [PATCH 2/2] block: create ioctl to discard-or-zeroout a range of blocks From: Linus Torvalds To: One Thousand Gnomes Cc: Ric Wheeler , "Theodore Ts'o" , Gregory Farnum , Dave Chinner , "Martin K. Petersen" , Christoph Hellwig , "Darrick J. Wong" , Jens Axboe , Andrew Morton , Linux API , Linux Kernel Mailing List , shane.seymour@hpe.com, Bruce Fields , linux-fsdevel , Jeff Layton , Eric Sandeen Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1493 Lines: 34 On Fri, Mar 11, 2016 at 5:59 AM, One Thousand Gnomes wrote: > > > > We can do the security check at the filesystem level, because we have > > > sb->s_bdev->bd_inode, and if you have read and write permissions to > > > that inode, you might as well have permission to create a unsafe hole. > > Not if you don't have access to a block device node to open it, or there > are SELinux rules that control the access. There are cases it isn't > entirely the same thing as far as I can see. Consider within a container > for example. I agree that it's not the same thing, but I don't think it really ends up mattering. Either the container is properly separated and set up - in which case the uid mapping is what protects you - or it isn't - in which case the container could just mknod whatever hell node it wants anyway. So we do pretty much have the permission model. > The paranoid approach would IMHO to have a mount option so you can > explicitly declare a file system mount should trust its owner/group and > then that can also be used to wire up any other "unsafe" activities in a > general "mounted for a special use" option. I think that a mount option to enable it isn't a bad idea, but the mount option should be something generic and not be about "this group is special" which it sounds like google is currently using. More like "enable hole punching" - which doesn't enable it unconditionally, you'd still have the security checks. Linus