overlayfs: Make getxattr work with inode only
Change the getxattr inode operation to only use its inode argument, and
ignore the dentry. This is possible because on overlayfs, each dentry
has a separate inode and inodes are not shared among dentries. Allows
SELinux to work on top of overlayfs.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index d43dba6..9c1e2ee 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -219,16 +219,17 @@
ssize_t ovl_getxattr(struct dentry *dentry, struct inode *inode,
const char *name, void *value, size_t size)
{
+ struct ovl_entry *oe = inode->i_private;
struct dentry *realdentry;
-
- if (!dentry)
- return -ECHILD;
-
- realdentry = ovl_dentry_real(dentry);
+ bool is_upper;
if (ovl_is_private_xattr(name))
return -ENODATA;
+ realdentry = ovl_entry_real(oe, &is_upper);
+ if (WARN_ON(!realdentry->d_inode))
+ return -ENOENT;
+
return vfs_getxattr(realdentry, name, value, size);
}