Skip to content

Commit 8bc0095

Browse files
braunerMiklos Szeredi
authored andcommitted
ovl: handle idmappings in ovl_xattr_{g,s}et()
When retrieving xattrs from the upper or lower layers take the relevant mount's idmapping into account. We rely on the previously introduced ovl_i_path_real() helper to retrieve the relevant path. This is needed to support idmapped base layers with overlay. Cc: <linux-unionfs@vger.kernel.org> Tested-by: Giuseppe Scrivano <gscrivan@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 8423b3b commit 8bc0095

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

fs/overlayfs/inode.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,15 +349,17 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name,
349349
struct ovl_fs *ofs = OVL_FS(dentry->d_sb);
350350
struct dentry *upperdentry = ovl_i_dentry_upper(inode);
351351
struct dentry *realdentry = upperdentry ?: ovl_dentry_lower(dentry);
352+
struct path realpath;
352353
const struct cred *old_cred;
353354

354355
err = ovl_want_write(dentry);
355356
if (err)
356357
goto out;
357358

358359
if (!value && !upperdentry) {
360+
ovl_path_lower(dentry, &realpath);
359361
old_cred = ovl_override_creds(dentry->d_sb);
360-
err = vfs_getxattr(&init_user_ns, realdentry, name, NULL, 0);
362+
err = vfs_getxattr(mnt_user_ns(realpath.mnt), realdentry, name, NULL, 0);
361363
revert_creds(old_cred);
362364
if (err < 0)
363365
goto out_drop_write;
@@ -395,11 +397,11 @@ int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,
395397
{
396398
ssize_t res;
397399
const struct cred *old_cred;
398-
struct dentry *realdentry =
399-
ovl_i_dentry_upper(inode) ?: ovl_dentry_lower(dentry);
400+
struct path realpath;
400401

402+
ovl_i_path_real(inode, &realpath);
401403
old_cred = ovl_override_creds(dentry->d_sb);
402-
res = vfs_getxattr(&init_user_ns, realdentry, name, value, size);
404+
res = vfs_getxattr(mnt_user_ns(realpath.mnt), realpath.dentry, name, value, size);
403405
revert_creds(old_cred);
404406
return res;
405407
}

0 commit comments

Comments
 (0)