From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com> To: Alexander Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@infradead.org>, Eric Paris <eparis@redhat.com>, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>, linux-fsdevel@vger.kernel.org, David Quigley <dpquigl@davequigley.com>, "J. Bruce Fields" <bfields@fieldses.org> 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 [thread overview] Message-ID: <1440094798-1411-10-git-send-email-agruenba@redhat.com> (raw) In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com> 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 <agruenba@redhat.com> --- 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); -- 2.4.3
WARNING: multiple messages have this Message-ID (diff)
From: Andreas Gruenbacher <andreas.gruenbacher@gmail.com> To: cluster-devel.redhat.com Subject: [Cluster-devel] [RFC 09/11] vfs: Add igetxattr inode operation Date: Thu, 20 Aug 2015 20:19:56 +0200 [thread overview] Message-ID: <1440094798-1411-10-git-send-email-agruenba@redhat.com> (raw) In-Reply-To: <1440094798-1411-1-git-send-email-agruenba@redhat.com> 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 <agruenba@redhat.com> --- 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); -- 2.4.3
next prev parent reply other threads:[~2015-08-20 18:24 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-08-20 18:19 [RFC 00/11] Inode security label invalidation Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 01/11] ubifs: Remove unused "security.*" xattr handler Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 02/11] hfsplus: Remove unused xattr handler list operations Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 03/11] 9p: Simplify the xattr handlers Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 04/11] xattr handlers: Pass handler to operations instead of flags Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 05/11] xattr handlers: Some simplifications Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 06/11] lib: Move strcmp_prefix into string.c Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 07/11] 9p: Stop using the generic xattr_handler infrastructure Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-21 6:46 ` Christoph Hellwig 2015-08-21 6:46 ` [Cluster-devel] " Christoph Hellwig 2015-08-21 8:35 ` Steven Whitehouse 2015-08-21 8:35 ` Steven Whitehouse 2015-08-20 18:19 ` [RFC 08/11] xattr: Pass inodes to xattr handlers instead of dentries Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` Andreas Gruenbacher [this message] 2015-08-20 18:19 ` [Cluster-devel] [RFC 09/11] vfs: Add igetxattr inode operation Andreas Gruenbacher 2015-08-21 6:48 ` Christoph Hellwig 2015-08-21 6:48 ` [Cluster-devel] " Christoph Hellwig 2015-08-20 18:19 ` [RFC 10/11] selinux: Allow to invalidate an inode's security label Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-20 18:19 ` [RFC 11/11] gfs2: Invalide security labels of inodes that go invalid Andreas Gruenbacher 2015-08-20 18:19 ` [Cluster-devel] " Andreas Gruenbacher 2015-08-21 6:49 ` Christoph Hellwig 2015-08-21 6:49 ` [Cluster-devel] " Christoph Hellwig 2015-08-21 9:25 ` Andreas Gruenbacher 2015-08-21 9:25 ` Andreas Gruenbacher 2015-08-24 17:42 ` [RFC 00/11] Inode security label invalidation Stephen Smalley 2015-08-24 17:42 ` [Cluster-devel] " Stephen Smalley 2015-08-24 19:13 ` Andreas Grünbacher 2015-08-24 19:13 ` [Cluster-devel] " Andreas Grünbacher 2015-08-24 20:47 ` Eric Paris 2015-08-24 20:47 ` [Cluster-devel] " Eric Paris
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1440094798-1411-10-git-send-email-agruenba@redhat.com \ --to=andreas.gruenbacher@gmail.com \ --cc=aneesh.kumar@linux.vnet.ibm.com \ --cc=bfields@fieldses.org \ --cc=cluster-devel@redhat.com \ --cc=dpquigl@davequigley.com \ --cc=eparis@redhat.com \ --cc=hch@infradead.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=linux-security-module@vger.kernel.org \ --cc=viro@zeniv.linux.org.uk \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.