Skip to content

Commit 2c5ca23

Browse files
committed
Merge tag 'ovl-update-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs
Pull overlayfs updates from Miklos Szeredi: - Support idmapped layers in overlayfs (Christian Brauner) - Add a fix to exportfs that is relevant to open_by_handle_at(2) as well - Introduce new lookup helpers that allow passing mnt_userns into inode_permission() * tag 'ovl-update-5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs: ovl: support idmapped layers ovl: handle idmappings in ovl_xattr_{g,s}et() ovl: handle idmappings in layer open helpers ovl: handle idmappings in ovl_permission() ovl: use ovl_copy_{real,upper}attr() wrappers ovl: store lower path in ovl_inode ovl: handle idmappings for layer lookup ovl: handle idmappings for layer fileattrs ovl: use ovl_path_getxattr() wrapper ovl: use ovl_lookup_upper() wrapper ovl: use ovl_do_notify_change() wrapper ovl: pass layer mnt to ovl_open_realfile() ovl: pass ofs to setattr operations ovl: handle idmappings in creation operations ovl: add ovl_upper_mnt_userns() wrapper ovl: pass ofs to creation operations ovl: use wrappers to all vfs_*xattr() calls exportfs: support idmapped mounts fs: add two trivial lookup helpers
2 parents 73d15ba + bc70682 commit 2c5ca23

File tree

14 files changed

+598
-336
lines changed

14 files changed

+598
-336
lines changed

fs/exportfs/expfs.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static struct dentry *reconnect_one(struct vfsmount *mnt,
145145
if (err)
146146
goto out_err;
147147
dprintk("%s: found name: %s\n", __func__, nbuf);
148-
tmp = lookup_one_len_unlocked(nbuf, parent, strlen(nbuf));
148+
tmp = lookup_one_unlocked(mnt_user_ns(mnt), nbuf, parent, strlen(nbuf));
149149
if (IS_ERR(tmp)) {
150150
dprintk("%s: lookup failed: %d\n", __func__, PTR_ERR(tmp));
151151
err = PTR_ERR(tmp);
@@ -525,7 +525,8 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
525525
}
526526

527527
inode_lock(target_dir->d_inode);
528-
nresult = lookup_one_len(nbuf, target_dir, strlen(nbuf));
528+
nresult = lookup_one(mnt_user_ns(mnt), nbuf,
529+
target_dir, strlen(nbuf));
529530
if (!IS_ERR(nresult)) {
530531
if (unlikely(nresult->d_inode != result->d_inode)) {
531532
dput(nresult);

fs/namei.c

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,7 +2769,8 @@ struct dentry *lookup_one(struct user_namespace *mnt_userns, const char *name,
27692769
EXPORT_SYMBOL(lookup_one);
27702770

27712771
/**
2772-
* lookup_one_len_unlocked - filesystem helper to lookup single pathname component
2772+
* lookup_one_unlocked - filesystem helper to lookup single pathname component
2773+
* @mnt_userns: idmapping of the mount the lookup is performed from
27732774
* @name: pathname component to lookup
27742775
* @base: base directory to lookup from
27752776
* @len: maximum length @len should be interpreted to
@@ -2780,14 +2781,15 @@ EXPORT_SYMBOL(lookup_one);
27802781
* Unlike lookup_one_len, it should be called without the parent
27812782
* i_mutex held, and will take the i_mutex itself if necessary.
27822783
*/
2783-
struct dentry *lookup_one_len_unlocked(const char *name,
2784-
struct dentry *base, int len)
2784+
struct dentry *lookup_one_unlocked(struct user_namespace *mnt_userns,
2785+
const char *name, struct dentry *base,
2786+
int len)
27852787
{
27862788
struct qstr this;
27872789
int err;
27882790
struct dentry *ret;
27892791

2790-
err = lookup_one_common(&init_user_ns, name, base, len, &this);
2792+
err = lookup_one_common(mnt_userns, name, base, len, &this);
27912793
if (err)
27922794
return ERR_PTR(err);
27932795

@@ -2796,6 +2798,59 @@ struct dentry *lookup_one_len_unlocked(const char *name,
27962798
ret = lookup_slow(&this, base, 0);
27972799
return ret;
27982800
}
2801+
EXPORT_SYMBOL(lookup_one_unlocked);
2802+
2803+
/**
2804+
* lookup_one_positive_unlocked - filesystem helper to lookup single
2805+
* pathname component
2806+
* @mnt_userns: idmapping of the mount the lookup is performed from
2807+
* @name: pathname component to lookup
2808+
* @base: base directory to lookup from
2809+
* @len: maximum length @len should be interpreted to
2810+
*
2811+
* This helper will yield ERR_PTR(-ENOENT) on negatives. The helper returns
2812+
* known positive or ERR_PTR(). This is what most of the users want.
2813+
*
2814+
* Note that pinned negative with unlocked parent _can_ become positive at any
2815+
* time, so callers of lookup_one_unlocked() need to be very careful; pinned
2816+
* positives have >d_inode stable, so this one avoids such problems.
2817+
*
2818+
* Note that this routine is purely a helper for filesystem usage and should
2819+
* not be called by generic code.
2820+
*
2821+
* The helper should be called without i_mutex held.
2822+
*/
2823+
struct dentry *lookup_one_positive_unlocked(struct user_namespace *mnt_userns,
2824+
const char *name,
2825+
struct dentry *base, int len)
2826+
{
2827+
struct dentry *ret = lookup_one_unlocked(mnt_userns, name, base, len);
2828+
2829+
if (!IS_ERR(ret) && d_flags_negative(smp_load_acquire(&ret->d_flags))) {
2830+
dput(ret);
2831+
ret = ERR_PTR(-ENOENT);
2832+
}
2833+
return ret;
2834+
}
2835+
EXPORT_SYMBOL(lookup_one_positive_unlocked);
2836+
2837+
/**
2838+
* lookup_one_len_unlocked - filesystem helper to lookup single pathname component
2839+
* @name: pathname component to lookup
2840+
* @base: base directory to lookup from
2841+
* @len: maximum length @len should be interpreted to
2842+
*
2843+
* Note that this routine is purely a helper for filesystem usage and should
2844+
* not be called by generic code.
2845+
*
2846+
* Unlike lookup_one_len, it should be called without the parent
2847+
* i_mutex held, and will take the i_mutex itself if necessary.
2848+
*/
2849+
struct dentry *lookup_one_len_unlocked(const char *name,
2850+
struct dentry *base, int len)
2851+
{
2852+
return lookup_one_unlocked(&init_user_ns, name, base, len);
2853+
}
27992854
EXPORT_SYMBOL(lookup_one_len_unlocked);
28002855

28012856
/*
@@ -2809,12 +2864,7 @@ EXPORT_SYMBOL(lookup_one_len_unlocked);
28092864
struct dentry *lookup_positive_unlocked(const char *name,
28102865
struct dentry *base, int len)
28112866
{
2812-
struct dentry *ret = lookup_one_len_unlocked(name, base, len);
2813-
if (!IS_ERR(ret) && d_flags_negative(smp_load_acquire(&ret->d_flags))) {
2814-
dput(ret);
2815-
ret = ERR_PTR(-ENOENT);
2816-
}
2817-
return ret;
2867+
return lookup_one_positive_unlocked(&init_user_ns, name, base, len);
28182868
}
28192869
EXPORT_SYMBOL(lookup_positive_unlocked);
28202870

0 commit comments

Comments
 (0)