From patchwork Thu Aug 20 18:19:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Andreas_Gr=C3=BCnbacher?= X-Patchwork-Id: 7046491 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4A484C05AC for ; Thu, 20 Aug 2015 18:25:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4D76A205C1 for ; Thu, 20 Aug 2015 18:24:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A1FD2044C for ; Thu, 20 Aug 2015 18:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751462AbbHTSY4 (ORCPT ); Thu, 20 Aug 2015 14:24:56 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35898 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbbHTSYz (ORCPT ); Thu, 20 Aug 2015 14:24:55 -0400 Received: by wicja10 with SMTP id ja10so152384928wic.1; Thu, 20 Aug 2015 11:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9tSkt4OzP3MkNUsmrIvnyzbNBSUsdWbDgczYjZxDbeI=; b=ylPbZQJ9DvB0VjyXnoAk+Y4t1W0HYU4CyC7nmB3T6dijYU4TE0uU77zomzY2FsBcLY Qiwf8Suf63ZadtAEBT90QywuMFrawdQveB2fQhXjjgLa5409Ad/f7/33IgqEQ25pJuZg HzDiYn2vQSdZP0S+L1/cC8/hRUTpjXTgKBhVJjhaVM86eEZhZzToWjpYdISZgIfvcxi5 zg/+VWlaNnu8/GEa/5oMpaHceREG18rix93usMlk0h8bT2F8tdlehnTcIXIwrRZ6UzpA jRS/z/eh9ftQtFjmCXtMLU+Hp5fCfyj79Y1sHH6MPPmGe6/rshWmG1Bf7D6JURhGKCz/ zfgw== X-Received: by 10.194.87.102 with SMTP id w6mr8119666wjz.111.1440095093985; Thu, 20 Aug 2015 11:24:53 -0700 (PDT) Received: from nuc.home.com (p549817FE.dip0.t-ipconnect.de. [84.152.23.254]) by smtp.gmail.com with ESMTPSA id ma4sm6598334wjb.38.2015.08.20.11.23.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2015 11:24:52 -0700 (PDT) From: Andreas Gruenbacher X-Google-Original-From: Andreas Gruenbacher To: Alexander Viro , Christoph Hellwig , Eric Paris , "Aneesh Kumar K.V" , linux-fsdevel@vger.kernel.org, David Quigley , "J. Bruce Fields" Cc: linux-security-module@vger.kernel.org, cluster-devel@redhat.com Subject: [RFC 09/11] vfs: Add igetxattr inode operation Date: Thu, 20 Aug 2015 20:19:56 +0200 Message-Id: <1440094798-1411-10-git-send-email-agruenba@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com> References: <1440094798-1411-1-git-send-email-agruenba@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add an igetxattr inode operation that behaves as getxattr but operates on inodes instead of dentries. File systems that support this operation can implement igetxattr for reading xattrs in contexts where a dentry is not available, such as within SELinux inode security checks. Signed-off-by: Andreas Gruenbacher --- Documentation/filesystems/Locking | 2 ++ Documentation/filesystems/vfs.txt | 4 ++++ fs/xattr.c | 12 +++++++++--- include/linux/fs.h | 1 + include/linux/xattr.h | 1 + 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/Locking b/Documentation/filesystems/Locking index 6a34a0f..77d6d50 100644 --- a/Documentation/filesystems/Locking +++ b/Documentation/filesystems/Locking @@ -58,6 +58,7 @@ prototypes: int (*setattr) (struct dentry *, struct iattr *); int (*getattr) (struct vfsmount *, struct dentry *, struct kstat *); int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); + ssize_t (*igetxattr) (struct inode *, const char *, void *, size_t); ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); ssize_t (*listxattr) (struct dentry *, char *, size_t); int (*removexattr) (struct dentry *, const char *); @@ -90,6 +91,7 @@ permission: no (may not block if called in rcu-walk mode) get_acl: no getattr: no setxattr: yes +igetxattr: no getxattr: no listxattr: no removexattr: yes diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 5eb8456..4c9512e 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -357,6 +357,7 @@ struct inode_operations { int (*setattr) (struct dentry *, struct iattr *); int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); + ssize_t (*igetxattr) (struct inode *, const char *, void *, size_t); ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); ssize_t (*listxattr) (struct dentry *, char *, size_t); int (*removexattr) (struct dentry *, const char *); @@ -473,6 +474,9 @@ otherwise noted. attribute name. This method is called by getxattr(2) function call. + igetxattr: retrieve the value of an extended attribute name of an + inode; otherwise identical to getxattr which takes a dentry. + listxattr: called by the VFS to list all extended attributes for a given file. This method is called by listxattr(2) system call. diff --git a/fs/xattr.c b/fs/xattr.c index c45db57..e706e6b 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -702,14 +702,20 @@ xattr_resolve_name(const struct xattr_handler **handlers, const char **name) * Find the handler for the prefix and dispatch its get() operation. */ ssize_t -generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) +generic_igetxattr(struct inode *inode, const char *name, void *buffer, size_t size) { const struct xattr_handler *handler; - handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); + handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); if (!handler) return -EOPNOTSUPP; - return handler->get(dentry->d_inode, name, buffer, size, handler); + return handler->get(inode, name, buffer, size, handler); +} + +ssize_t +generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) +{ + return generic_igetxattr(dentry->d_inode, name, buffer, size); } /* diff --git a/include/linux/fs.h b/include/linux/fs.h index 84b783f..dbca464 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1657,6 +1657,7 @@ struct inode_operations { int (*setattr) (struct dentry *, struct iattr *); int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *); int (*setxattr) (struct dentry *, const char *,const void *,size_t,int); + ssize_t (*igetxattr) (struct inode *, const char *, void *, size_t); ssize_t (*getxattr) (struct dentry *, const char *, void *, size_t); ssize_t (*listxattr) (struct dentry *, char *, size_t); int (*removexattr) (struct dentry *, const char *); diff --git a/include/linux/xattr.h b/include/linux/xattr.h index 0a0539e..9762025 100644 --- a/include/linux/xattr.h +++ b/include/linux/xattr.h @@ -44,6 +44,7 @@ int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, i int vfs_setxattr(struct dentry *, const char *, const void *, size_t, int); int vfs_removexattr(struct dentry *, const char *); +ssize_t generic_igetxattr(struct inode *inode, const char *name, void *buffer, size_t size); ssize_t generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size); ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size); int generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags);