Skip to content

Commit fe78e02

Browse files
committed
Merge tag 'vfs-6.16-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner: - Fix a regression in overlayfs caused by reworking the lookup_one*() set of helpers - Make sure that the name of the dentry is printed in overlayfs' mkdir() helper - Add missing iocb values to TRACE_IOCB_STRINGS define - Unlock the superblock during iterate_supers_type(). This was an accidental internal api change - Drop a misleading assert in file_seek_cur_needs_f_lock() helper - Never refuse to return PIDFD_GET_INGO when parent pid is zero That can trivially happen in container scenarios where the parent process might be located in an ancestor pid namespace - Don't revalidate in try_lookup_noperm() as that causes regression for filesystems such as cifs - Fix simple_xattr_list() and reset the err variable after security_inode_listsecurity() got called so as not to confuse userspace about the length of the xattr * tag 'vfs-6.16-rc3.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: drop assert in file_seek_cur_needs_f_lock fs: unlock the superblock during iterate_supers_type ovl: fix debug print in case of mkdir error VFS: change try_lookup_noperm() to skip revalidation fs: add missing values to TRACE_IOCB_STRINGS fs/xattr.c: fix simple_xattr_list() ovl: fix regression caused by lookup helpers API changes pidfs: never refuse ppid == 0 in PIDFD_GET_INFO
2 parents e04c78d + dd2d6b7 commit fe78e02

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

fs/file.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,8 +1198,12 @@ bool file_seek_cur_needs_f_lock(struct file *file)
11981198
if (!(file->f_mode & FMODE_ATOMIC_POS) && !file->f_op->iterate_shared)
11991199
return false;
12001200

1201-
VFS_WARN_ON_ONCE((file_count(file) > 1) &&
1202-
!mutex_is_locked(&file->f_pos_lock));
1201+
/*
1202+
* Note that we are not guaranteed to be called after fdget_pos() on
1203+
* this file obj, in which case the caller is expected to provide the
1204+
* appropriate locking.
1205+
*/
1206+
12031207
return true;
12041208
}
12051209

fs/namei.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2917,7 +2917,8 @@ static int lookup_one_common(struct mnt_idmap *idmap,
29172917
* @base: base directory to lookup from
29182918
*
29192919
* Look up a dentry by name in the dcache, returning NULL if it does not
2920-
* currently exist. The function does not try to create a dentry.
2920+
* currently exist. The function does not try to create a dentry and if one
2921+
* is found it doesn't try to revalidate it.
29212922
*
29222923
* Note that this routine is purely a helper for filesystem usage and should
29232924
* not be called by generic code. It does no permission checking.
@@ -2933,7 +2934,7 @@ struct dentry *try_lookup_noperm(struct qstr *name, struct dentry *base)
29332934
if (err)
29342935
return ERR_PTR(err);
29352936

2936-
return lookup_dcache(name, base, 0);
2937+
return d_lookup(base, name);
29372938
}
29382939
EXPORT_SYMBOL(try_lookup_noperm);
29392940

@@ -3057,14 +3058,22 @@ EXPORT_SYMBOL(lookup_one_positive_unlocked);
30573058
* Note that this routine is purely a helper for filesystem usage and should
30583059
* not be called by generic code. It does no permission checking.
30593060
*
3060-
* Unlike lookup_noperm, it should be called without the parent
3061+
* Unlike lookup_noperm(), it should be called without the parent
30613062
* i_rwsem held, and will take the i_rwsem itself if necessary.
3063+
*
3064+
* Unlike try_lookup_noperm() it *does* revalidate the dentry if it already
3065+
* existed.
30623066
*/
30633067
struct dentry *lookup_noperm_unlocked(struct qstr *name, struct dentry *base)
30643068
{
30653069
struct dentry *ret;
3070+
int err;
30663071

3067-
ret = try_lookup_noperm(name, base);
3072+
err = lookup_noperm_common(name, base);
3073+
if (err)
3074+
return ERR_PTR(err);
3075+
3076+
ret = lookup_dcache(name, base, 0);
30683077
if (!ret)
30693078
ret = lookup_slow(name, base, 0);
30703079
return ret;

fs/overlayfs/namei.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry,
13931393
bool ovl_lower_positive(struct dentry *dentry)
13941394
{
13951395
struct ovl_entry *poe = OVL_E(dentry->d_parent);
1396-
struct qstr *name = &dentry->d_name;
1396+
const struct qstr *name = &dentry->d_name;
13971397
const struct cred *old_cred;
13981398
unsigned int i;
13991399
bool positive = false;
@@ -1416,9 +1416,15 @@ bool ovl_lower_positive(struct dentry *dentry)
14161416
struct dentry *this;
14171417
struct ovl_path *parentpath = &ovl_lowerstack(poe)[i];
14181418

1419+
/*
1420+
* We need to make a non-const copy of dentry->d_name,
1421+
* because lookup_one_positive_unlocked() will hash name
1422+
* with parentpath base, which is on another (lower fs).
1423+
*/
14191424
this = lookup_one_positive_unlocked(
14201425
mnt_idmap(parentpath->layer->mnt),
1421-
name, parentpath->dentry);
1426+
&QSTR_LEN(name->name, name->len),
1427+
parentpath->dentry);
14221428
if (IS_ERR(this)) {
14231429
switch (PTR_ERR(this)) {
14241430
case -ENOENT:

fs/overlayfs/overlayfs.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,11 @@ static inline struct dentry *ovl_do_mkdir(struct ovl_fs *ofs,
246246
struct dentry *dentry,
247247
umode_t mode)
248248
{
249-
dentry = vfs_mkdir(ovl_upper_mnt_idmap(ofs), dir, dentry, mode);
250-
pr_debug("mkdir(%pd2, 0%o) = %i\n", dentry, mode, PTR_ERR_OR_ZERO(dentry));
251-
return dentry;
249+
struct dentry *ret;
250+
251+
ret = vfs_mkdir(ovl_upper_mnt_idmap(ofs), dir, dentry, mode);
252+
pr_debug("mkdir(%pd2, 0%o) = %i\n", dentry, mode, PTR_ERR_OR_ZERO(ret));
253+
return ret;
252254
}
253255

254256
static inline int ovl_do_mknod(struct ovl_fs *ofs,

fs/pidfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ static long pidfd_info(struct file *file, unsigned int cmd, unsigned long arg)
366366
kinfo.pid = task_pid_vnr(task);
367367
kinfo.mask |= PIDFD_INFO_PID;
368368

369-
if (kinfo.pid == 0 || kinfo.tgid == 0 || (kinfo.ppid == 0 && kinfo.pid != 1))
369+
if (kinfo.pid == 0 || kinfo.tgid == 0)
370370
return -ESRCH;
371371

372372
copy_out:

fs/super.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,8 +964,10 @@ void iterate_supers_type(struct file_system_type *type,
964964
spin_unlock(&sb_lock);
965965

966966
locked = super_lock_shared(sb);
967-
if (locked)
967+
if (locked) {
968968
f(sb, arg);
969+
super_unlock_shared(sb);
970+
}
969971

970972
spin_lock(&sb_lock);
971973
if (p)

fs/xattr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,7 @@ ssize_t simple_xattr_list(struct inode *inode, struct simple_xattrs *xattrs,
14791479
buffer += err;
14801480
}
14811481
remaining_size -= err;
1482+
err = 0;
14821483

14831484
read_lock(&xattrs->lock);
14841485
for (rbp = rb_first(&xattrs->rb_root); rbp; rbp = rb_next(rbp)) {

include/linux/fs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ struct readahead_control;
399399
{ IOCB_WAITQ, "WAITQ" }, \
400400
{ IOCB_NOIO, "NOIO" }, \
401401
{ IOCB_ALLOC_CACHE, "ALLOC_CACHE" }, \
402-
{ IOCB_DIO_CALLER_COMP, "CALLER_COMP" }
402+
{ IOCB_DIO_CALLER_COMP, "CALLER_COMP" }, \
403+
{ IOCB_AIO_RW, "AIO_RW" }, \
404+
{ IOCB_HAS_METADATA, "AIO_HAS_METADATA" }
403405

404406
struct kiocb {
405407
struct file *ki_filp;

0 commit comments

Comments
 (0)