Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3237592pxv; Mon, 12 Jul 2021 12:33:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3h2mCkPcmryGmiY6lpK6sJ6WHVxHJihriKz7zyj1DUOjUiwfnn5Q9+tJ7nMOUUbasPNxm X-Received: by 2002:a05:6402:22c6:: with SMTP id dm6mr566337edb.228.1626118419053; Mon, 12 Jul 2021 12:33:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626118419; cv=none; d=google.com; s=arc-20160816; b=Fp7DM8wEeNsOPFRgS5ABSAL7I3ufkvN1aNVT+QDFSTV7T857zUDkZRm2vT8I2AVRjs kIxUVWABxKq0fwkq/PkN/3i2f8x64G0x9Cdq2iZY4/ys8ybBVaNGRF2CUh3U+AJQ2rw8 yddpFxFJW6+cuK52cCX6cwZwjHQpJIQ3PuUrbknPwSy370uvt1U3hJjIiAsvfdjVM+TE e0xiKWDHwmLCBklMh35985JlHn7f52vGWOljY5ZfAQIeDC1+ABZdWrUm4Zrxgm3HVOZP 7kbN+ogjxOGT2Vcyt9r/Mp/sbKUlUKCFF15y5KmEQhYO/Fcj7/H49SdJ7+xL46XvwUw3 kq8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=Zn3SvcMF3FFO49+WTI8pt7ML3V5uhGmeYXXeqsXQrcY=; b=nSPyPvKEDMNk8TKX83ehypIGPsh6/HlrcfAgPeScje2oZTc5w+SfPRKXGP/pWIYnmF Ve9Xull/Saqz+zlGNa6UtY7HMNCVWVQaCVyDj+r9IP+DleFFv2Nex9cZZewbRAfAcC1o q42xj/3GclK3SoFnzx/khNis/M2fxWQDvkHaNxum7lTihXPLYuMrmy+emAukzUHbwz+V K8DZI/Uuq/pk4Gq2Zxy08r9GZVF5o7PxMP4LcNSld7fmvh08h8fZ1c+Z1jWP8lpabcWz pp5V8ceawmLU6Qlg1wrHYJbN0vJubqVihWhf+FloTczxdDUbKbaQNciNvXns1RGCEjgg zkLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=v8DlyIay; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r9si8997567edq.454.2021.07.12.12.33.16; Mon, 12 Jul 2021 12:33:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=v8DlyIay; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236443AbhGLTeb (ORCPT + 99 others); Mon, 12 Jul 2021 15:34:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236190AbhGLTe2 (ORCPT ); Mon, 12 Jul 2021 15:34:28 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56C29C0613DD; Mon, 12 Jul 2021 12:31:40 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 485F269D6; Mon, 12 Jul 2021 15:31:39 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 485F269D6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1626118299; bh=Zn3SvcMF3FFO49+WTI8pt7ML3V5uhGmeYXXeqsXQrcY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=v8DlyIayyg8yDjwJfuxsFYTJvh+t9cDW+Uz+VYzSDSXEbEke0mosrcMLlzmpjVmDX 06wu4GYGB/ZF34UAZkd7LRQK1LLMfmlqQkWptRk7aDVwFxxNO8dF2uGtyK7jm+7Tbu RIR8atVX3reEl7AA0HxjsvEmxSoIIB5kZMNxDEwg= Date: Mon, 12 Jul 2021 15:31:39 -0400 From: "J. Bruce Fields" To: Vivek Goyal Cc: Bruce Fields , Casey Schaufler , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, viro@zeniv.linux.org.uk, virtio-fs@redhat.com, dwalsh@redhat.com, dgilbert@redhat.com, casey.schaufler@intel.com, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, tytso@mit.edu, miklos@szeredi.hu, gscrivan@redhat.com, jack@suse.cz, Christoph Hellwig Subject: Re: [PATCH v2 1/1] xattr: Allow user.* xattr on symlink and special files Message-ID: <20210712193139.GA22997@fieldses.org> References: <20210708175738.360757-1-vgoyal@redhat.com> <20210708175738.360757-2-vgoyal@redhat.com> <20210709091915.2bd4snyfjndexw2b@wittgenstein> <20210709152737.GA398382@redhat.com> <710d1c6f-d477-384f-0cc1-8914258f1fb1@schaufler-ca.com> <20210709175947.GB398382@redhat.com> <20210712140247.GA486376@redhat.com> <20210712154106.GB18679@fieldses.org> <20210712174759.GA502004@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210712174759.GA502004@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 12, 2021 at 01:47:59PM -0400, Vivek Goyal wrote: > On Mon, Jul 12, 2021 at 11:41:06AM -0400, J. Bruce Fields wrote: > > Looks like 0xd is what the server returns to access on a device node > > with mode bits rw- for the caller. > > > > Commit c11d7fd1b317 "nfsd: take xattr bits into account for permission > > checks" added the ACCESS_X* bits for regular files and directories but > > not others. > > > > But you don't want to determine permission from the mode bits anyway, > > you want it to depend on the owner, > > Thinking more about this part. Current implementation of my patch is > effectively doing both the checks. It checks that you are owner or > have CAP_FOWNER in xattr_permission() and then goes on to call > inode_permission(). And that means file mode bits will also play a > role. If caller does not have write permission on the file, it will > be denied setxattr(). > > If I don't call inode_permission(), and just return 0 right away for > file owner (for symlinks and special files), then just being owner > is enough to write user.* xattr. And then even security modules will > not get a chance to block that operation. IOW, if you are owner of > a symlink or special file, you can write as many user.* xattr as you > like and except quota does not look like anything else can block > it. I am wondering if this approach is ok? Yeah, I'd expect security modules to get a say, and I wouldn't expect mode bits on device nodes to be useful for deciding whether it makes sense for xattrs to be readable or writeable. But, I don't really know. Do we have any other use cases besides this case of storing security labels in user xattrs? --b.