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=-5.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 BA1D0C433FF for ; Wed, 14 Aug 2019 11:00:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8F352206C1 for ; Wed, 14 Aug 2019 11:00:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="R20LnwhY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8F352206C1 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mhnNe2cPaKU6SLz34P24CO4VEqXbD1kmwUwigkuMye0=; b=R20LnwhYMOYB0r l2Q5nNE96gVZsYHPpP9ddPVcMwqGWI4nkSRfGAwkDW7UORABss2VnDZVYQfaQgDWkLp511dGSrar9 7M+LDm0XMbtsJlLlNPWxQG0RprgyEW5KgotoH9XH4eNgbRbnew3//PuWuMeDyNiI6L6/sLCCi7d14 upzc/KKF1iU4HDTTjXzc59GRnfKfBu48hpyGkb/33Po+ZDXZulp3X+Md6rATjlELrPO+6fW7HkEQM fC+x1Pfh+THYb69VDtqCV1N/VTFB4E8wDx3Izb/7M/E8PTYomp7G0ZgBQnZ08MyBzvFpE/8rgdlmF XXLY7Ji2q03n9+3uRhTw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hxr1B-0004H8-Dr; Wed, 14 Aug 2019 11:00:37 +0000 Received: from mx2.suse.de ([195.135.220.15] helo=mx1.suse.de) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hxr17-0004GU-H5; Wed, 14 Aug 2019 11:00:35 +0000 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 3537FADEF; Wed, 14 Aug 2019 11:00:26 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 81D741E4200; Wed, 14 Aug 2019 13:00:22 +0200 (CEST) Date: Wed, 14 Aug 2019 13:00:22 +0200 From: Jan Kara To: Mark Salyzyn Subject: Re: [PATCH v2] Add flags option to get xattr method paired to __vfs_getxattr Message-ID: <20190814110022.GB26273@quack2.suse.cz> References: <20190813145527.26289-1-salyzyn@android.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190813145527.26289-1-salyzyn@android.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190814_040033_860215_2CFC18C1 X-CRM114-Status: GOOD ( 15.54 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Latchesar Ionkov , Dave Kleikamp , jfs-discussion@lists.sourceforge.net, Phillip Lougher , linux-integrity@vger.kernel.org, Martin Brandenburg , samba-technical@lists.samba.org, Dominique Martinet , Chao Yu , Mimi Zohar , Adrian Hunter , linux-mm@kvack.org, Chris Mason , netdev@vger.kernel.org, Andreas Dilger , linux-xfs@vger.kernel.org, Eric Paris , linux-f2fs-devel@lists.sourceforge.net, linux-afs@lists.infradead.org, Stephen Smalley , Mike Marshall , devel@driverdev.osuosl.org, linux-cifs@vger.kernel.org, Paul Moore , Sage Weil , "Darrick J. Wong" , Richard Weinberger , Mark Fasheh , linux-unionfs@vger.kernel.org, Hugh Dickins , James Morris , cluster-devel@redhat.com, Joseph Qi , Vyacheslav Dubeyko , Casey Schaufler , v9fs-developer@lists.sourceforge.net, Ilya Dryomov , linux-ext4@vger.kernel.org, kernel-team@android.com, devel@lists.orangefs.org, Serge Hallyn , Gao Xiang , Eric Van Hensbergen , ecryptfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, Josef Bacik , reiserfs-devel@vger.kernel.org, Bob Peterson , Joel Becker , Anna Schumaker , David Sterba , Jaegeuk Kim , ceph-devel@vger.kernel.org, selinux@vger.kernel.org, Trond Myklebust , Andreas Gruenbacher , David Howells , linux-nfs@vger.kernel.org, Theodore Ts'o , linux-fsdevel@vger.kernel.org, Artem Bityutskiy , Mathieu Malaterre , Greg Kroah-Hartman , Miklos Szeredi , Jeff Layton , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Tyler Hicks , Steve French , Ernesto =?iso-8859-1?Q?A=2E_Fern=E1ndez?= , linux-btrfs@vger.kernel.org, linux-security-module@vger.kernel.org, Jan Kara , Tejun Heo , linux-mtd@lists.infradead.org, Andrew Morton , David Woodhouse , "David S. Miller" , ocfs2-devel@oss.oracle.com, Alexander Viro Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On Tue 13-08-19 07:55:06, Mark Salyzyn wrote: ... > diff --git a/fs/xattr.c b/fs/xattr.c > index 90dd78f0eb27..71f887518d6f 100644 > --- a/fs/xattr.c > +++ b/fs/xattr.c ... > ssize_t > __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name, > - void *value, size_t size) > + void *value, size_t size, int flags) > { > const struct xattr_handler *handler; > - > - handler = xattr_resolve_name(inode, &name); > - if (IS_ERR(handler)) > - return PTR_ERR(handler); > - if (!handler->get) > - return -EOPNOTSUPP; > - return handler->get(handler, dentry, inode, name, value, size); > -} > -EXPORT_SYMBOL(__vfs_getxattr); > - > -ssize_t > -vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size) > -{ > - struct inode *inode = dentry->d_inode; > int error; > > + if (flags & XATTR_NOSECURITY) > + goto nolsm; Hum, is it OK for XATTR_NOSECURITY to skip even the xattr_permission() check? I understand that for reads of security xattrs it actually does not matter in practice but conceptually that seems wrong to me as XATTR_NOSECURITY is supposed to skip just security-module checks to avoid recursion AFAIU. > diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h > index c1395b5bd432..1216d777d210 100644 > --- a/include/uapi/linux/xattr.h > +++ b/include/uapi/linux/xattr.h > @@ -17,8 +17,9 @@ > #if __UAPI_DEF_XATTR > #define __USE_KERNEL_XATTR_DEFS > > -#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ > -#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ > +#define XATTR_CREATE 0x1 /* set value, fail if attr already exists */ > +#define XATTR_REPLACE 0x2 /* set value, fail if attr does not exist */ > +#define XATTR_NOSECURITY 0x4 /* get value, do not involve security check */ > #endif It seems confusing to export XATTR_NOSECURITY definition to userspace when that is kernel-internal flag. I'd just define it in include/linux/xattr.h somewhere from the top of flags space (like 0x40000000). Otherwise the patch looks OK to me (cannot really comment on the security module aspect of this whole thing though). Honza -- Jan Kara SUSE Labs, CR ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/