Skip to content

Commit 45a43ac

Browse files
committed
Merge tag 'vfs-7.0-rc1.misc.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull more misc vfs updates from Christian Brauner: "Features: - Optimize close_range() from O(range size) to O(active FDs) by using find_next_bit() on the open_fds bitmap instead of linearly scanning the entire requested range. This is a significant improvement for large-range close operations on sparse file descriptor tables. - Add FS_XFLAG_VERITY file attribute for fs-verity files, retrievable via FS_IOC_FSGETXATTR and file_getattr(). The flag is read-only. Add tracepoints for fs-verity enable and verify operations, replacing the previously removed debug printk's. - Prevent nfsd from exporting special kernel filesystems like pidfs and nsfs. These filesystems have custom ->open() and ->permission() export methods that are designed for open_by_handle_at(2) only and are incompatible with nfsd. Update the exportfs documentation accordingly. Fixes: - Fix KMSAN uninit-value in ovl_fill_real() where strcmp() was used on a non-null-terminated decrypted directory entry name from fscrypt. This triggered on encrypted lower layers when the decrypted name buffer contained uninitialized tail data. The fix also adds VFS-level name_is_dot(), name_is_dotdot(), and name_is_dot_dotdot() helpers, replacing various open-coded "." and ".." checks across the tree. - Fix read-only fsflags not being reset together with xflags in vfs_fileattr_set(). Currently harmless since no read-only xflags overlap with flags, but this would cause inconsistencies for any future shared read-only flag - Return -EREMOTE instead of -ESRCH from PIDFD_GET_INFO when the target process is in a different pid namespace. This lets userspace distinguish "process exited" from "process in another namespace", matching glibc's pidfd_getpid() behavior Cleanups: - Use C-string literals in the Rust seq_file bindings, replacing the kernel::c_str!() macro (available since Rust 1.77) - Fix typo in d_walk_ret enum comment, add porting notes for the readlink_copy() calling convention change" * tag 'vfs-7.0-rc1.misc.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs: fs: add porting notes about readlink_copy() pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns nfsd: do not allow exporting of special kernel filesystems exportfs: clarify the documentation of open()/permission() expotrfs ops fsverity: add tracepoints fs: add FS_XFLAG_VERITY for fs-verity files rust: seq_file: replace `kernel::c_str!` with C-Strings fs: dcache: fix typo in enum d_walk_ret comment ovl: use name_is_dot* helpers in readdir code fs: add helpers name_is_dot{,dot,_dotdot} ovl: Fix uninit-value in ovl_fill_real fs: reset read-only fsflags together with xflags fs/file: optimize close_range() complexity from O(N) to O(Sparse)
2 parents 543b9b6 + dedfae7 commit 45a43ac

26 files changed

Lines changed: 274 additions & 57 deletions

File tree

Documentation/filesystems/fsverity.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,22 @@ the file has fs-verity enabled. This can perform better than
341341
FS_IOC_GETFLAGS and FS_IOC_MEASURE_VERITY because it doesn't require
342342
opening the file, and opening verity files can be expensive.
343343

344+
FS_IOC_FSGETXATTR
345+
-----------------
346+
347+
Since Linux v7.0, the FS_IOC_FSGETXATTR ioctl sets FS_XFLAG_VERITY (0x00020000)
348+
in the returned flags when the file has verity enabled. Note that this attribute
349+
cannot be set with FS_IOC_FSSETXATTR as enabling verity requires input
350+
parameters. See FS_IOC_ENABLE_VERITY.
351+
352+
file_getattr
353+
------------
354+
355+
Since Linux v7.0, the file_getattr() syscall sets FS_XFLAG_VERITY (0x00020000)
356+
in the returned flags when the file has verity enabled. Note that this attribute
357+
cannot be set with file_setattr() as enabling verity requires input parameters.
358+
See FS_IOC_ENABLE_VERITY.
359+
344360
.. _accessing_verity_files:
345361

346362
Accessing verity files

Documentation/filesystems/porting.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,3 +1351,13 @@ and do_rmdir()) are gone; they are replaced with non-consuming analogues
13511351
(filename_renameat2(), etc.)
13521352
Callers are adjusted - responsibility for dropping the filenames belongs
13531353
to them now.
1354+
1355+
---
1356+
1357+
**mandatory**
1358+
1359+
readlink_copy() now requires link length as the 4th argument. Said length needs
1360+
to match what strlen() would return if it was ran on the string.
1361+
1362+
However, if the string is freely accessible for the duration of inode's
1363+
lifetime, consider using inode_set_cached_link() instead.

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10415,6 +10415,7 @@ T: git https://git.kernel.org/pub/scm/fs/fsverity/linux.git
1041510415
F: Documentation/filesystems/fsverity.rst
1041610416
F: fs/verity/
1041710417
F: include/linux/fsverity.h
10418+
F: include/trace/events/fsverity.h
1041810419
F: include/uapi/linux/fsverity.h
1041910420

1042010421
FT260 FTDI USB-HID TO I2C BRIDGE DRIVER

fs/crypto/fname.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct fscrypt_nokey_name {
7676

7777
static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
7878
{
79-
return is_dot_dotdot(str->name, str->len);
79+
return name_is_dot_dotdot(str->name, str->len);
8080
}
8181

8282
/**

fs/dcache.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1298,8 +1298,8 @@ void shrink_dcache_sb(struct super_block *sb)
12981298
EXPORT_SYMBOL(shrink_dcache_sb);
12991299

13001300
/**
1301-
* enum d_walk_ret - action to talke during tree walk
1302-
* @D_WALK_CONTINUE: contrinue walk
1301+
* enum d_walk_ret - action to take during tree walk
1302+
* @D_WALK_CONTINUE: continue walk
13031303
* @D_WALK_QUIT: quit walk
13041304
* @D_WALK_NORETRY: quit when retry is needed
13051305
* @D_WALK_SKIP: skip this dentry and its children
@@ -1722,7 +1722,7 @@ void d_invalidate(struct dentry *dentry)
17221722
EXPORT_SYMBOL(d_invalidate);
17231723

17241724
/**
1725-
* __d_alloc - allocate a dcache entry
1725+
* __d_alloc - allocate a dcache entry
17261726
* @sb: filesystem it will belong to
17271727
* @name: qstr of the name
17281728
*
@@ -1806,7 +1806,7 @@ static struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
18061806
}
18071807

18081808
/**
1809-
* d_alloc - allocate a dcache entry
1809+
* d_alloc - allocate a dcache entry
18101810
* @parent: parent of entry to allocate
18111811
* @name: qstr of the name
18121812
*
@@ -2546,7 +2546,7 @@ static void __d_rehash(struct dentry *entry)
25462546
}
25472547

25482548
/**
2549-
* d_rehash - add an entry back to the hash
2549+
* d_rehash - add an entry back to the hash
25502550
* @entry: dentry to add to the hash
25512551
*
25522552
* Adds a dentry to the hash according to its name.

fs/ecryptfs/crypto.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ int ecryptfs_decode_and_decrypt_filename(char **plaintext_name,
19041904

19051905
if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) &&
19061906
!(mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)) {
1907-
if (is_dot_dotdot(name, name_size)) {
1907+
if (name_is_dot_dotdot(name, name_size)) {
19081908
rc = ecryptfs_copy_filename(plaintext_name,
19091909
plaintext_name_size,
19101910
name, name_size);

fs/exportfs/expfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ static bool filldir_one(struct dir_context *ctx, const char *name, int len,
253253
container_of(ctx, struct getdents_callback, ctx);
254254

255255
buf->sequence++;
256-
if (buf->ino == ino && len <= NAME_MAX && !is_dot_dotdot(name, len)) {
256+
if (buf->ino == ino && len <= NAME_MAX &&
257+
!name_is_dot_dotdot(name, len)) {
257258
memcpy(buf->name, name, len);
258259
buf->name[len] = '\0';
259260
buf->found = 1;

fs/f2fs/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int f2fs_init_casefolded_name(const struct inode *dir,
6868
int len;
6969

7070
if (IS_CASEFOLDED(dir) &&
71-
!is_dot_dotdot(fname->usr_fname->name, fname->usr_fname->len)) {
71+
!name_is_dot_dotdot(fname->usr_fname->name, fname->usr_fname->len)) {
7272
buf = f2fs_kmem_cache_alloc(f2fs_cf_name_slab,
7373
GFP_NOFS, false, F2FS_SB(sb));
7474
if (!buf)

fs/f2fs/hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void f2fs_hash_filename(const struct inode *dir, struct f2fs_filename *fname)
100100

101101
WARN_ON_ONCE(!name);
102102

103-
if (is_dot_dotdot(name, len)) {
103+
if (name_is_dot_dotdot(name, len)) {
104104
fname->hash = 0;
105105
return;
106106
}

fs/file.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,23 +777,29 @@ static inline void __range_close(struct files_struct *files, unsigned int fd,
777777
unsigned int max_fd)
778778
{
779779
struct file *file;
780+
struct fdtable *fdt;
780781
unsigned n;
781782

782783
spin_lock(&files->file_lock);
783-
n = last_fd(files_fdtable(files));
784+
fdt = files_fdtable(files);
785+
n = last_fd(fdt);
784786
max_fd = min(max_fd, n);
785787

786-
for (; fd <= max_fd; fd++) {
788+
for (fd = find_next_bit(fdt->open_fds, max_fd + 1, fd);
789+
fd <= max_fd;
790+
fd = find_next_bit(fdt->open_fds, max_fd + 1, fd + 1)) {
787791
file = file_close_fd_locked(files, fd);
788792
if (file) {
789793
spin_unlock(&files->file_lock);
790794
filp_close(file, files);
791795
cond_resched();
792796
spin_lock(&files->file_lock);
797+
fdt = files_fdtable(files);
793798
} else if (need_resched()) {
794799
spin_unlock(&files->file_lock);
795800
cond_resched();
796801
spin_lock(&files->file_lock);
802+
fdt = files_fdtable(files);
797803
}
798804
}
799805
spin_unlock(&files->file_lock);

0 commit comments

Comments
 (0)