History

Merge tag 'vfs-6.18-rc7.fixes' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs

Pull vfs fixes from Christian Brauner: - Fix unitialized variable in statmount_string() - Fix hostfs mounting when passing host root during boot - Fix dynamic lookup to fail on cell lookup failure - Fix missing file type when reading bfs inodes from disk - Enforce checking of sb_min_blocksize() calls and update all callers accordingly - Restore write access before closing files opened by open_exec() in binfmt_misc - Always freeze efivarfs during suspend/hibernate cycles - Fix statmount()'s and listmount()'s grab_requested_mnt_ns() helper to actually allow mount namespace file descriptor in addition to mount namespace ids - Fix tmpfs remount when noswap is specified - Switch Landlock to iput_not_last() to remove false-positives from might_sleep() annotations in iput() - Remove dead node_to_mnt_ns() code - Ensure that per-queue kobjects are successfully created * tag 'vfs-6.18-rc7.fixes' of gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs: landlock: fix splats from iput() after it started calling might_sleep() fs: add iput_not_last() shmem: fix tmpfs reconfiguration (remount) when noswap is set fs/namespace: correctly handle errors returned by grab_requested_mnt_ns power: always freeze efivarfs binfmt_misc: restore write access before closing files opened by open_exec() block: add __must_check attribute to sb_min_blocksize() virtio-fs: fix incorrect check for fsvq->kobj xfs: check the return value of sb_min_blocksize() in xfs_fs_fill_super isofs: check the return value of sb_min_blocksize() in isofs_fill_super exfat: check return value of sb_min_blocksize in exfat_read_boot_sector vfat: fix missing sb_min_blocksize() return value checks mnt: Remove dead code which might prevent from building bfs: Reconstruct file type when loading from disk afs: Fix dynamic lookup to fail on cell lookup failure hostfs: Fix only passing host root in boot stage with new mount fs: Fix uninitialized 'offp' in statmount_string()

Linus Torvalds committed 12 months ago

Commit e7c375b2 parents 418592a e9d50b726 files · +206 −91Browse files

Unified · Split

26 files
  1. block/bdev.c +1 −1
  2. fs/afs/cell.c +66 −12
  3. fs/afs/dynroot.c +2 −1
  4. fs/afs/internal.h +11 −1
  5. fs/afs/mntpt.c +2 −1
  6. fs/afs/proc.c +2 −1
  7. fs/afs/super.c +1 −1
  8. fs/afs/vl_alias.c +2 −1
  9. fs/bfs/inode.c +18 −1
  10. fs/binfmt_misc.c +3 −1
  11. fs/efivarfs/super.c +1 −0
  12. fs/exfat/super.c +4 −1
  13. fs/fat/inode.c +5 −1
  14. fs/fuse/virtio_fs.c +1 −1
  15. fs/hostfs/hostfs_kern.c +18 −11
  16. fs/inode.c +12 −0
  17. fs/isofs/inode.c +5 −0
  18. fs/namespace.c +18 −28
  19. fs/super.c +10 −3
  20. fs/xfs/xfs_super.c +4 −1
  21. include/linux/fs.h +5 −3
  22. include/uapi/linux/mount.h +1 −1
  23. kernel/power/hibernate.c +3 −6
  24. kernel/power/suspend.c +1 −2
  25. mm/shmem.c +7 −8
  26. security/landlock/fs.c +3 −4
block/bdev.c+1−1
@@ -231,7 +231,7 @@ int sb_set_blocksize(struct super_block *sb, int size) · 230 unmodified lines
231231
232232 EXPORT_SYMBOL(sb_set_blocksize);
233233
234−int sb_min_blocksize(struct super_block *sb, int size)
234+int __must_check sb_min_blocksize(struct super_block *sb, int size)
235235 {
236236 int minsize = bdev_logical_block_size(sb->s_bdev);
237237 if (size < minsize)
fs/afs/cell.c+66−12
@@ -229,7 +229,7 @@ error: · 228 unmodified lines
229229 * @name: The name of the cell.
230230 * @namesz: The strlen of the cell name.
231231 * @vllist: A colon/comma separated list of numeric IP addresses or NULL.
232− * @excl: T if an error should be given if the cell name already exists.
232+ * @reason: The reason we're doing the lookup
233233 * @trace: The reason to be logged if the lookup is successful.
234234 *
235235 * Look up a cell record by name and query the DNS for VL server addresses if
@@ -239,7 +239,8 @@ error: · 3 unmodified lines
239239 */
240240 struct afs_cell *afs_lookup_cell(struct afs_net *net,
241241 const char *name, unsigned int namesz,
242− const char *vllist, bool excl,
242+ const char *vllist,
243+ enum afs_lookup_cell_for reason,
243244 enum afs_cell_trace trace)
244245 {
245246 struct afs_cell *cell, *candidate, *cursor;
@@ -247,12 +248,18 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net, · 1 unmodified line
247248 enum afs_cell_state state;
248249 int ret, n;
249250
250− _enter("%s,%s", name, vllist);
251+ _enter("%s,%s,%u", name, vllist, reason);
251252
252− if (!excl) {
253+ if (reason != AFS_LOOKUP_CELL_PRELOAD) {
253254 cell = afs_find_cell(net, name, namesz, trace);
254− if (!IS_ERR(cell))
255+ if (!IS_ERR(cell)) {
256+ if (reason == AFS_LOOKUP_CELL_DYNROOT)
257+ goto no_wait;
258+ if (cell->state == AFS_CELL_SETTING_UP ||
259+ cell->state == AFS_CELL_UNLOOKED)
260+ goto lookup_cell;
255261 goto wait_for_cell;
262+ }
256263 }
257264
258265 /* Assume we're probably going to create a cell and preallocate and
@@ -298,26 +305,69 @@ struct afs_cell *afs_lookup_cell(struct afs_net *net, · 39 unmodified lines
298305 rb_insert_color(&cell->net_node, &net->cells);
299306 up_write(&net->cells_lock);
300307
301− afs_queue_cell(cell, afs_cell_trace_queue_new);
308+lookup_cell:
309+ if (reason != AFS_LOOKUP_CELL_PRELOAD &&
310+ reason != AFS_LOOKUP_CELL_ROOTCELL) {
311+ set_bit(AFS_CELL_FL_DO_LOOKUP, &cell->flags);
312+ afs_queue_cell(cell, afs_cell_trace_queue_new);
313+ }
302314
303315 wait_for_cell:
304− _debug("wait_for_cell");
305316 state = smp_load_acquire(&cell->state); /* vs error */
306− if (state != AFS_CELL_ACTIVE &&
307− state != AFS_CELL_DEAD) {
317+ switch (state) {
318+ case AFS_CELL_ACTIVE:
319+ case AFS_CELL_DEAD:
320+ break;
321+ case AFS_CELL_UNLOOKED:
322+ default:
323+ if (reason == AFS_LOOKUP_CELL_PRELOAD ||
324+ reason == AFS_LOOKUP_CELL_ROOTCELL)
325+ break;
326+ _debug("wait_for_cell");
308327 afs_see_cell(cell, afs_cell_trace_wait);
309328 wait_var_event(&cell->state,
310329 ({
311330 state = smp_load_acquire(&cell->state); /* vs error */
312331 state == AFS_CELL_ACTIVE || state == AFS_CELL_DEAD;
313332 }));
333+ _debug("waited_for_cell %d %d", cell->state, cell->error);
314334 }
315335
336+no_wait:
316337 /* Check the state obtained from the wait check. */
338+ state = smp_load_acquire(&cell->state); /* vs error */
317339 if (state == AFS_CELL_DEAD) {
318340 ret = cell->error;
319341 goto error;
320342 }
343+ if (state == AFS_CELL_ACTIVE) {
344+ switch (cell->dns_status) {
345+ case DNS_LOOKUP_NOT_DONE:
346+ if (cell->dns_source == DNS_RECORD_FROM_CONFIG) {
347+ ret = 0;
348+ break;
349+ }
350+ fallthrough;
351+ default:
352+ ret = -EIO;
353+ goto error;
354+ case DNS_LOOKUP_GOOD:
355+ case DNS_LOOKUP_GOOD_WITH_BAD:
356+ ret = 0;
357+ break;
358+ case DNS_LOOKUP_GOT_NOT_FOUND:
359+ ret = -ENOENT;
360+ goto error;
361+ case DNS_LOOKUP_BAD:
362+ ret = -EREMOTEIO;
363+ goto error;
364+ case DNS_LOOKUP_GOT_LOCAL_FAILURE:
365+ case DNS_LOOKUP_GOT_TEMP_FAILURE:
366+ case DNS_LOOKUP_GOT_NS_FAILURE:
367+ ret = -EDESTADDRREQ;
368+ goto error;
369+ }
370+ }
321371
322372 _leave(" = %p [cell]", cell);
323373 return cell;
@@ -325,7 +375,7 @@ wait_for_cell: · 1 unmodified line
325375 cell_already_exists:
326376 _debug("cell exists");
327377 cell = cursor;
328− if (excl) {
378+ if (reason == AFS_LOOKUP_CELL_PRELOAD) {
329379 ret = -EEXIST;
330380 } else {
331381 afs_use_cell(cursor, trace);
@@ -384,7 +434,8 @@ int afs_cell_init(struct afs_net *net, const char *rootcell) · 52 unmodified lines
384434 return -EINVAL;
385435
386436 /* allocate a cell record for the root/workstation cell */
387− new_root = afs_lookup_cell(net, rootcell, len, vllist, false,
437+ new_root = afs_lookup_cell(net, rootcell, len, vllist,
438+ AFS_LOOKUP_CELL_ROOTCELL,
388439 afs_cell_trace_use_lookup_ws);
389440 if (IS_ERR(new_root)) {
390441 _leave(" = %ld", PTR_ERR(new_root));
@@ -777,6 +828,7 @@ static bool afs_manage_cell(struct afs_cell *cell) · 386 unmodified lines
777828 switch (cell->state) {
778829 case AFS_CELL_SETTING_UP:
779830 goto set_up_cell;
831+ case AFS_CELL_UNLOOKED:
780832 case AFS_CELL_ACTIVE:
781833 goto cell_is_active;
782834 case AFS_CELL_REMOVING:
@@ -797,7 +849,7 @@ set_up_cell: · 14 unmodified lines
797849 goto remove_cell;
798850 }
799851
800− afs_set_cell_state(cell, AFS_CELL_ACTIVE);
852+ afs_set_cell_state(cell, AFS_CELL_UNLOOKED);
801853
802854 cell_is_active:
803855 if (afs_has_cell_expired(cell, &next_manage))
@@ -807,6 +859,8 @@ cell_is_active: · 3 unmodified lines
807859 ret = afs_update_cell(cell);
808860 if (ret < 0)
809861 cell->error = ret;
862+ if (cell->state == AFS_CELL_UNLOOKED)
863+ afs_set_cell_state(cell, AFS_CELL_ACTIVE);
810864 }
811865
812866 if (next_manage < TIME64_MAX && cell->net->live) {
fs/afs/dynroot.c+2−1
@@ -108,7 +108,8 @@ static struct dentry *afs_dynroot_lookup_cell(struct inode *dir, struct dentry * · 107 unmodified lines
108108 dotted = true;
109109 }
110110
111− cell = afs_lookup_cell(net, name, len, NULL, false,
111+ cell = afs_lookup_cell(net, name, len, NULL,
112+ AFS_LOOKUP_CELL_DYNROOT,
112113 afs_cell_trace_use_lookup_dynroot);
113114 if (IS_ERR(cell)) {
114115 ret = PTR_ERR(cell);
fs/afs/internal.h+11−1
@@ -343,6 +343,7 @@ extern const char afs_init_sysname[]; · 342 unmodified lines
343343
344344 enum afs_cell_state {
345345 AFS_CELL_SETTING_UP,
346+ AFS_CELL_UNLOOKED,
346347 AFS_CELL_ACTIVE,
347348 AFS_CELL_REMOVING,
348349 AFS_CELL_DEAD,
@@ -1049,9 +1050,18 @@ static inline bool afs_cb_is_broken(unsigned int cb_break, · 700 unmodified lines
10491050 extern int afs_cell_init(struct afs_net *, const char *);
10501051 extern struct afs_cell *afs_find_cell(struct afs_net *, const char *, unsigned,
10511052 enum afs_cell_trace);
1053+enum afs_lookup_cell_for {
1054+ AFS_LOOKUP_CELL_DYNROOT,
1055+ AFS_LOOKUP_CELL_MOUNTPOINT,
1056+ AFS_LOOKUP_CELL_DIRECT_MOUNT,
1057+ AFS_LOOKUP_CELL_PRELOAD,
1058+ AFS_LOOKUP_CELL_ROOTCELL,
1059+ AFS_LOOKUP_CELL_ALIAS_CHECK,
1060+};
10521061 struct afs_cell *afs_lookup_cell(struct afs_net *net,
10531062 const char *name, unsigned int namesz,
1054− const char *vllist, bool excl,
1063+ const char *vllist,
1064+ enum afs_lookup_cell_for reason,
10551065 enum afs_cell_trace trace);
10561066 extern struct afs_cell *afs_use_cell(struct afs_cell *, enum afs_cell_trace);
10571067 void afs_unuse_cell(struct afs_cell *cell, enum afs_cell_trace reason);
fs/afs/mntpt.c+2−1
@@ -107,7 +107,8 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt) · 106 unmodified lines
107107 if (size > AFS_MAXCELLNAME)
108108 return -ENAMETOOLONG;
109109
110− cell = afs_lookup_cell(ctx->net, p, size, NULL, false,
110+ cell = afs_lookup_cell(ctx->net, p, size, NULL,
111+ AFS_LOOKUP_CELL_MOUNTPOINT,
111112 afs_cell_trace_use_lookup_mntpt);
112113 if (IS_ERR(cell)) {
113114 pr_err("kAFS: unable to lookup cell '%pd'\n", mntpt);
fs/afs/proc.c+2−1
@@ -122,7 +122,8 @@ static int afs_proc_cells_write(struct file *file, char *buf, size_t size) · 121 unmodified lines
122122 if (strcmp(buf, "add") == 0) {
123123 struct afs_cell *cell;
124124
125− cell = afs_lookup_cell(net, name, strlen(name), args, true,
125+ cell = afs_lookup_cell(net, name, strlen(name), args,
126+ AFS_LOOKUP_CELL_PRELOAD,
126127 afs_cell_trace_use_lookup_add);
127128 if (IS_ERR(cell)) {
128129 ret = PTR_ERR(cell);
fs/afs/super.c+1−1
@@ -290,7 +290,7 @@ static int afs_parse_source(struct fs_context *fc, struct fs_parameter *param) · 289 unmodified lines
290290 /* lookup the cell record */
291291 if (cellname) {
292292 cell = afs_lookup_cell(ctx->net, cellname, cellnamesz,
293− NULL, false,
293+ NULL, AFS_LOOKUP_CELL_DIRECT_MOUNT,
294294 afs_cell_trace_use_lookup_mount);
295295 if (IS_ERR(cell)) {
296296 pr_err("kAFS: unable to lookup cell '%*.*s'\n",
fs/afs/vl_alias.c+2−1
@@ -269,7 +269,8 @@ static int yfs_check_canonical_cell_name(struct afs_cell *cell, struct key *key) · 268 unmodified lines
269269 if (!name_len || name_len > AFS_MAXCELLNAME)
270270 master = ERR_PTR(-EOPNOTSUPP);
271271 else
272− master = afs_lookup_cell(cell->net, cell_name, name_len, NULL, false,
272+ master = afs_lookup_cell(cell->net, cell_name, name_len, NULL,
273+ AFS_LOOKUP_CELL_ALIAS_CHECK,
273274 afs_cell_trace_use_lookup_canonical);
274275 kfree(cell_name);
275276 if (IS_ERR(master))
fs/bfs/inode.c+18−1
@@ -61,7 +61,19 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino) · 60 unmodified lines
6161 off = (ino - BFS_ROOT_INO) % BFS_INODES_PER_BLOCK;
6262 di = (struct bfs_inode *)bh->b_data + off;
6363
64− inode->i_mode = 0x0000FFFF & le32_to_cpu(di->i_mode);
64+ /*
65+ * https://martin.hinner.info/fs/bfs/bfs-structure.html explains that
66+ * BFS in SCO UnixWare environment used only lower 9 bits of di->i_mode
67+ * value. This means that, although bfs_write_inode() saves whole
68+ * inode->i_mode bits (which include S_IFMT bits and S_IS{UID,GID,VTX}
69+ * bits), middle 7 bits of di->i_mode value can be garbage when these
70+ * bits were not saved by bfs_write_inode().
71+ * Since we can't tell whether middle 7 bits are garbage, use only
72+ * lower 12 bits (i.e. tolerate S_IS{UID,GID,VTX} bits possibly being
73+ * garbage) and reconstruct S_IFMT bits for Linux environment from
74+ * di->i_vtype value.
75+ */
76+ inode->i_mode = 0x00000FFF & le32_to_cpu(di->i_mode);
6577 if (le32_to_cpu(di->i_vtype) == BFS_VDIR) {
6678 inode->i_mode |= S_IFDIR;
6779 inode->i_op = &bfs_dir_inops;
@@ -71,6 +83,11 @@ struct inode *bfs_iget(struct super_block *sb, unsigned long ino) · 3 unmodified lines
7183 inode->i_op = &bfs_file_inops;
7284 inode->i_fop = &bfs_file_operations;
7385 inode->i_mapping->a_ops = &bfs_aops;
86+ } else {
87+ brelse(bh);
88+ printf("Unknown vtype=%u %s:%08lx\n",
89+ le32_to_cpu(di->i_vtype), inode->i_sb->s_id, ino);
90+ goto error;
7491 }
7592
7693 BFS_I(inode)->i_sblock = le32_to_cpu(di->i_sblock);
fs/binfmt_misc.c+3−1
@@ -837,8 +837,10 @@ out: · 836 unmodified lines
837837 inode_unlock(d_inode(root));
838838
839839 if (err) {
840− if (f)
840+ if (f) {
841+ exe_file_allow_write_access(f);
841842 filp_close(f, NULL);
843+ }
842844 kfree(e);
843845 return err;
844846 }
fs/efivarfs/super.c+1−0
@@ -533,6 +533,7 @@ static struct file_system_type efivarfs_type = { · 532 unmodified lines
533533 .init_fs_context = efivarfs_init_fs_context,
534534 .kill_sb = efivarfs_kill_sb,
535535 .parameters = efivarfs_parameters,
536+ .fs_flags = FS_POWER_FREEZE,
536537 };
537538
538539 static __init int efivarfs_init(void)
fs/exfat/super.c+4−1
@@ -433,7 +433,10 @@ static int exfat_read_boot_sector(struct super_block *sb) · 432 unmodified lines
433433 struct exfat_sb_info *sbi = EXFAT_SB(sb);
434434
435435 /* set block size to read super block */
436− sb_min_blocksize(sb, 512);
436+ if (!sb_min_blocksize(sb, 512)) {
437+ exfat_err(sb, "unable to set blocksize");
438+ return -EINVAL;
439+ }
437440
438441 /* read boot sector */
439442 sbi->boot_bh = sb_bread(sb, 0);
fs/fat/inode.c+5−1
@@ -1595,8 +1595,12 @@ int fat_fill_super(struct super_block *sb, struct fs_context *fc, · 1594 unmodified lines
15951595
15961596 setup(sb); /* flavour-specific stuff that needs options */
15971597
1598+ error = -EINVAL;
1599+ if (!sb_min_blocksize(sb, 512)) {
1600+ fat_msg(sb, KERN_ERR, "unable to set blocksize");
1601+ goto out_fail;
1602+ }
15981603 error = -EIO;
1599− sb_min_blocksize(sb, 512);
16001604 bh = sb_bread(sb, 0);
16011605 if (bh == NULL) {
16021606 fat_msg(sb, KERN_ERR, "unable to read boot sector");
fs/fuse/virtio_fs.c+1−1
@@ -373,7 +373,7 @@ static int virtio_fs_add_queues_sysfs(struct virtio_fs *fs) · 372 unmodified lines
373373
374374 sprintf(buff, "%d", i);
375375 fsvq->kobj = kobject_create_and_add(buff, fs->mqs_kobj);
376− if (!fs->mqs_kobj) {
376+ if (!fsvq->kobj) {
377377 ret = -ENOMEM;
378378 goto out_del;
379379 }
fs/hostfs/hostfs_kern.c+18−11
@@ -979,7 +979,7 @@ static int hostfs_parse_param(struct fs_context *fc, struct fs_parameter *param) · 978 unmodified lines
979979 {
980980 struct hostfs_fs_info *fsi = fc->s_fs_info;
981981 struct fs_parse_result result;
982− char *host_root;
982+ char *host_root, *tmp_root;
983983 int opt;
984984
985985 opt = fs_parse(fc, hostfs_param_specs, param, &result);
@@ -990,11 +990,13 @@ static int hostfs_parse_param(struct fs_context *fc, struct fs_parameter *param) · 4 unmodified lines
990990 case Opt_hostfs:
991991 host_root = param->string;
992992 if (!*host_root)
993− host_root = "";
994− fsi->host_root_path =
995− kasprintf(GFP_KERNEL, "%s/%s", root_ino, host_root);
996− if (fsi->host_root_path == NULL)
993+ break;
994+ tmp_root = kasprintf(GFP_KERNEL, "%s%s",
995+ fsi->host_root_path, host_root);
996+ if (!tmp_root)
997997 return -ENOMEM;
998+ kfree(fsi->host_root_path);
999+ fsi->host_root_path = tmp_root;
9981000 break;
9991001 }
10001002
@@ -1004,17 +1006,17 @@ static int hostfs_parse_param(struct fs_context *fc, struct fs_parameter *param) · 3 unmodified lines
10041006 static int hostfs_parse_monolithic(struct fs_context *fc, void *data)
10051007 {
10061008 struct hostfs_fs_info *fsi = fc->s_fs_info;
1007− char *host_root = (char *)data;
1009+ char *tmp_root, *host_root = (char *)data;
10081010
10091011 /* NULL is printed as '(null)' by printf(): avoid that. */
10101012 if (host_root == NULL)
1011− host_root = "";
1013+ return 0;
10121014
1013− fsi->host_root_path =
1014− kasprintf(GFP_KERNEL, "%s/%s", root_ino, host_root);
1015− if (fsi->host_root_path == NULL)
1015+ tmp_root = kasprintf(GFP_KERNEL, "%s%s", fsi->host_root_path, host_root);
1016+ if (!tmp_root)
10161017 return -ENOMEM;
1017−
1018+ kfree(fsi->host_root_path);
1019+ fsi->host_root_path = tmp_root;
10181020 return 0;
10191021 }
10201022
@@ -1049,6 +1051,11 @@ static int hostfs_init_fs_context(struct fs_context *fc) · 28 unmodified lines
10491051 if (!fsi)
10501052 return -ENOMEM;
10511053
1054+ fsi->host_root_path = kasprintf(GFP_KERNEL, "%s/", root_ino);
1055+ if (!fsi->host_root_path) {
1056+ kfree(fsi);
1057+ return -ENOMEM;
1058+ }
10521059 fc->s_fs_info = fsi;
10531060 fc->ops = &hostfs_context_ops;
10541061 return 0;
fs/inode.c+12−0
@@ -1967,6 +1967,18 @@ retry: · 1966 unmodified lines
19671967 }
19681968 EXPORT_SYMBOL(iput);
19691969
1970+/**
1971+ * iput_not_last - put an inode assuming this is not the last reference
1972+ * @inode: inode to put
1973+ */
1974+void iput_not_last(struct inode *inode)
1975+{
1976+ VFS_BUG_ON_INODE(atomic_read(&inode->i_count) < 2, inode);
1977+
1978+ WARN_ON(atomic_sub_return(1, &inode->i_count) == 0);
1979+}
1980+EXPORT_SYMBOL(iput_not_last);
1981+
19701982 #ifdef CONFIG_BLOCK
19711983 /**
19721984 * bmap - find a block number in a file
fs/isofs/inode.c+5−0
@@ -610,6 +610,11 @@ static int isofs_fill_super(struct super_block *s, struct fs_context *fc) · 609 unmodified lines
610610 goto out_freesbi;
611611 }
612612 opt->blocksize = sb_min_blocksize(s, opt->blocksize);
613+ if (!opt->blocksize) {
614+ printk(KERN_ERR
615+ "ISOFS: unable to set blocksize\n");
616+ goto out_freesbi;
617+ }
613618
614619 sbi->s_high_sierra = 0; /* default is iso9660 */
615620 sbi->s_session = opt->session;
fs/namespace.c+18−28
@@ -132,16 +132,6 @@ EXPORT_SYMBOL_GPL(fs_kobj); · 131 unmodified lines
132132 */
133133 __cacheline_aligned_in_smp DEFINE_SEQLOCK(mount_lock);
134134
135−static inline struct mnt_namespace *node_to_mnt_ns(const struct rb_node *node)
136−{
137− struct ns_common *ns;
138−
139− if (!node)
140− return NULL;
141− ns = rb_entry(node, struct ns_common, ns_tree_node);
142− return container_of(ns, struct mnt_namespace, ns);
143−}
144−
145135 static void mnt_ns_release(struct mnt_namespace *ns)
146136 {
147137 /* keep alive for {list,stat}mount() */
@@ -151,7 +141,8 @@ static void mnt_ns_release(struct mnt_namespace *ns) · 3 unmodified lines
151141 kfree(ns);
152142 }
153143 }
154−DEFINE_FREE(mnt_ns_release, struct mnt_namespace *, if (_T) mnt_ns_release(_T))
144+DEFINE_FREE(mnt_ns_release, struct mnt_namespace *,
145+ if (!IS_ERR(_T)) mnt_ns_release(_T))
155146
156147 static void mnt_ns_release_rcu(struct rcu_head *rcu)
157148 {
@@ -5454,11 +5445,11 @@ static int statmount_string(struct kstatmount *s, u64 flag) · 5296 unmodified lines
54545445 ret = statmount_sb_source(s, seq);
54555446 break;
54565447 case STATMOUNT_MNT_UIDMAP:
5457− sm->mnt_uidmap = start;
5448+ offp = &sm->mnt_uidmap;
54585449 ret = statmount_mnt_uidmap(s, seq);
54595450 break;
54605451 case STATMOUNT_MNT_GIDMAP:
5461− sm->mnt_gidmap = start;
5452+ offp = &sm->mnt_gidmap;
54625453 ret = statmount_mnt_gidmap(s, seq);
54635454 break;
54645455 default:
@@ -5736,7 +5727,7 @@ static int copy_mnt_id_req(const struct mnt_id_req __user *req, · 271 unmodified lines
57365727 ret = copy_struct_from_user(kreq, sizeof(*kreq), req, usize);
57375728 if (ret)
57385729 return ret;
5739− if (kreq->spare != 0)
5730+ if (kreq->mnt_ns_fd != 0 && kreq->mnt_ns_id)
57405731 return -EINVAL;
57415732 /* The first valid unique mount id is MNT_UNIQUE_ID_OFFSET + 1. */
57425733 if (kreq->mnt_id <= MNT_UNIQUE_ID_OFFSET)
@@ -5753,16 +5744,12 @@ static struct mnt_namespace *grab_requested_mnt_ns(const struct mnt_id_req *kreq · 10 unmodified lines
57535744 {
57545745 struct mnt_namespace *mnt_ns;
57555746
5756− if (kreq->mnt_ns_id && kreq->spare)
5757− return ERR_PTR(-EINVAL);
5758−
5759− if (kreq->mnt_ns_id)
5760− return lookup_mnt_ns(kreq->mnt_ns_id);
5761−
5762− if (kreq->spare) {
5747+ if (kreq->mnt_ns_id) {
5748+ mnt_ns = lookup_mnt_ns(kreq->mnt_ns_id);
5749+ } else if (kreq->mnt_ns_fd) {
57635750 struct ns_common *ns;
57645751
5765− CLASS(fd, f)(kreq->spare);
5752+ CLASS(fd, f)(kreq->mnt_ns_fd);
57665753 if (fd_empty(f))
57675754 return ERR_PTR(-EBADF);
57685755
@@ -5777,6 +5764,8 @@ static struct mnt_namespace *grab_requested_mnt_ns(const struct mnt_id_req *kreq · 8 unmodified lines
57775764 } else {
57785765 mnt_ns = current->nsproxy->mnt_ns;
57795766 }
5767+ if (!mnt_ns)
5768+ return ERR_PTR(-ENOENT);
57805769
57815770 refcount_inc(&mnt_ns->passive);
57825771 return mnt_ns;
@@ -5801,8 +5790,8 @@ SYSCALL_DEFINE4(statmount, const struct mnt_id_req __user *, req, · 18 unmodified lines
58015790 return ret;
58025791
58035792 ns = grab_requested_mnt_ns(&kreq);
5804− if (!ns)
5805− return -ENOENT;
5793+ if (IS_ERR(ns))
5794+ return PTR_ERR(ns);
58065795
58075796 if (kreq.mnt_ns_id && (ns != current->nsproxy->mnt_ns) &&
58085797 !ns_capable_noaudit(ns->user_ns, CAP_SYS_ADMIN))
@@ -5912,8 +5901,8 @@ static void __free_klistmount_free(const struct klistmount *kls) · 103 unmodified lines
59125901 static inline int prepare_klistmount(struct klistmount *kls, struct mnt_id_req *kreq,
59135902 size_t nr_mnt_ids)
59145903 {
5915−
59165904 u64 last_mnt_id = kreq->param;
5905+ struct mnt_namespace *ns;
59175906
59185907 /* The first valid unique mount id is MNT_UNIQUE_ID_OFFSET + 1. */
59195908 if (last_mnt_id != 0 && last_mnt_id <= MNT_UNIQUE_ID_OFFSET)
@@ -5927,9 +5916,10 @@ static inline int prepare_klistmount(struct klistmount *kls, struct mnt_id_req * · 7 unmodified lines
59275916 if (!kls->kmnt_ids)
59285917 return -ENOMEM;
59295918
5930− kls->ns = grab_requested_mnt_ns(kreq);
5931− if (!kls->ns)
5932− return -ENOENT;
5919+ ns = grab_requested_mnt_ns(kreq);
5920+ if (IS_ERR(ns))
5921+ return PTR_ERR(ns);
5922+ kls->ns = ns;
59335923
59345924 kls->mnt_parent_id = kreq->mnt_id;
59355925 return 0;
fs/super.c+10−3
@@ -1183,11 +1183,14 @@ static inline bool get_active_super(struct super_block *sb) · 1182 unmodified lines
11831183
11841184 static const char *filesystems_freeze_ptr = "filesystems_freeze";
11851185
1186−static void filesystems_freeze_callback(struct super_block *sb, void *unused)
1186+static void filesystems_freeze_callback(struct super_block *sb, void *freeze_all_ptr)
11871187 {
11881188 if (!sb->s_op->freeze_fs && !sb->s_op->freeze_super)
11891189 return;
11901190
1191+ if (freeze_all_ptr && !(sb->s_type->fs_flags & FS_POWER_FREEZE))
1192+ return;
1193+
11911194 if (!get_active_super(sb))
11921195 return;
11931196
@@ -1201,9 +1204,13 @@ static void filesystems_freeze_callback(struct super_block *sb, void *unused) · 7 unmodified lines
12011204 deactivate_super(sb);
12021205 }
12031206
1204−void filesystems_freeze(void)
1207+void filesystems_freeze(bool freeze_all)
12051208 {
1206− __iterate_supers(filesystems_freeze_callback, NULL,
1209+ void *freeze_all_ptr = NULL;
1210+
1211+ if (freeze_all)
1212+ freeze_all_ptr = &freeze_all;
1213+ __iterate_supers(filesystems_freeze_callback, freeze_all_ptr,
12071214 SUPER_ITER_UNLOCKED | SUPER_ITER_REVERSE);
12081215 }
12091216
fs/xfs/xfs_super.c+4−1
@@ -1693,7 +1693,10 @@ xfs_fs_fill_super( · 1692 unmodified lines
16931693 if (error)
16941694 return error;
16951695
1696− sb_min_blocksize(sb, BBSIZE);
1696+ if (!sb_min_blocksize(sb, BBSIZE)) {
1697+ xfs_err(mp, "unable to set blocksize");
1698+ return -EINVAL;
1699+ }
16971700 sb->s_xattr = xfs_xattr_handlers;
16981701 sb->s_export_op = &xfs_export_operations;
16991702 #ifdef CONFIG_XFS_QUOTA
include/linux/fs.h+5−3
@@ -2689,6 +2689,7 @@ struct file_system_type { · 2688 unmodified lines
26892689 #define FS_ALLOW_IDMAP 32 /* FS has been updated to handle vfs idmappings. */
26902690 #define FS_MGTIME 64 /* FS uses multigrain timestamps */
26912691 #define FS_LBS 128 /* FS supports LBS */
2692+#define FS_POWER_FREEZE 256 /* Always freeze on suspend/hibernate */
26922693 #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
26932694 int (*init_fs_context)(struct fs_context *);
26942695 const struct fs_parameter_spec *parameters;
@@ -2823,6 +2824,7 @@ extern int current_umask(void); · 128 unmodified lines
28232824
28242825 extern void ihold(struct inode * inode);
28252826 extern void iput(struct inode *);
2827+void iput_not_last(struct inode *);
28262828 int inode_update_timestamps(struct inode *inode, int flags);
28272829 int generic_update_time(struct inode *, int);
28282830
@@ -3423,8 +3425,8 @@ static inline void remove_inode_hash(struct inode *inode) · 594 unmodified lines
34233425 extern void inode_sb_list_add(struct inode *inode);
34243426 extern void inode_add_lru(struct inode *inode);
34253427
3426−extern int sb_set_blocksize(struct super_block *, int);
3427−extern int sb_min_blocksize(struct super_block *, int);
3428+int sb_set_blocksize(struct super_block *sb, int size);
3429+int __must_check sb_min_blocksize(struct super_block *sb, int size);
34283430
34293431 int generic_file_mmap(struct file *, struct vm_area_struct *);
34303432 int generic_file_mmap_prepare(struct vm_area_desc *desc);
@@ -3606,7 +3608,7 @@ extern void drop_super_exclusive(struct super_block *sb); · 175 unmodified lines
36063608 extern void iterate_supers(void (*f)(struct super_block *, void *), void *arg);
36073609 extern void iterate_supers_type(struct file_system_type *,
36083610 void (*)(struct super_block *, void *), void *);
3609−void filesystems_freeze(void);
3611+void filesystems_freeze(bool freeze_all);
36103612 void filesystems_thaw(void);
36113613
36123614 extern int dcache_dir_open(struct inode *, struct file *);
include/uapi/linux/mount.h+1−1
@@ -197,7 +197,7 @@ struct statmount { · 196 unmodified lines
197197 */
198198 struct mnt_id_req {
199199 __u32 size;
200− __u32 spare;
200+ __u32 mnt_ns_fd;
201201 __u64 mnt_id;
202202 __u64 param;
203203 __u64 mnt_ns_id;
kernel/power/hibernate.c+3−6
@@ -821,8 +821,7 @@ int hibernate(void) · 820 unmodified lines
821821 goto Restore;
822822
823823 ksys_sync_helper();
824− if (filesystem_freeze_enabled)
825− filesystems_freeze();
824+ filesystems_freeze(filesystem_freeze_enabled);
826825
827826 error = freeze_processes();
828827 if (error)
@@ -928,8 +927,7 @@ int hibernate_quiet_exec(int (*func)(void *data), void *data) · 99 unmodified lines
928927 if (error)
929928 goto restore;
930929
931− if (filesystem_freeze_enabled)
932− filesystems_freeze();
930+ filesystems_freeze(filesystem_freeze_enabled);
933931
934932 error = freeze_processes();
935933 if (error)
@@ -1079,8 +1077,7 @@ static int software_resume(void) · 143 unmodified lines
10791077 if (error)
10801078 goto Restore;
10811079
1082− if (filesystem_freeze_enabled)
1083− filesystems_freeze();
1080+ filesystems_freeze(filesystem_freeze_enabled);
10841081
10851082 pm_pr_dbg("Preparing processes for hibernation restore.\n");
10861083 error = freeze_processes();
kernel/power/suspend.c+1−2
@@ -375,8 +375,7 @@ static int suspend_prepare(suspend_state_t state) · 374 unmodified lines
375375 if (error)
376376 goto Restore;
377377
378− if (filesystem_freeze_enabled)
379− filesystems_freeze();
378+ filesystems_freeze(filesystem_freeze_enabled);
380379 trace_suspend_resume(TPS("freeze_processes"), 0, true);
381380 error = suspend_freeze_processes();
382381 trace_suspend_resume(TPS("freeze_processes"), 0, false);
mm/shmem.c+7−8
@@ -131,8 +131,7 @@ struct shmem_options { · 130 unmodified lines
131131 #define SHMEM_SEEN_INODES 2
132132 #define SHMEM_SEEN_HUGE 4
133133 #define SHMEM_SEEN_INUMS 8
134−#define SHMEM_SEEN_NOSWAP 16
135−#define SHMEM_SEEN_QUOTA 32
134+#define SHMEM_SEEN_QUOTA 16
136135 };
137136
138137 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
@@ -4680,7 +4679,6 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) · 4541 unmodified lines
46804679 "Turning off swap in unprivileged tmpfs mounts unsupported");
46814680 }
46824681 ctx->noswap = true;
4683− ctx->seen |= SHMEM_SEEN_NOSWAP;
46844682 break;
46854683 case Opt_quota:
46864684 if (fc->user_ns != &init_user_ns)
@@ -4830,14 +4828,15 @@ static int shmem_reconfigure(struct fs_context *fc) · 143 unmodified lines
48304828 err = "Current inum too high to switch to 32-bit inums";
48314829 goto out;
48324830 }
4833− if ((ctx->seen & SHMEM_SEEN_NOSWAP) && ctx->noswap && !sbinfo->noswap) {
4831+
4832+ /*
4833+ * "noswap" doesn't use fsparam_flag_no, i.e. there's no "swap"
4834+ * counterpart for (re-)enabling swap.
4835+ */
4836+ if (ctx->noswap && !sbinfo->noswap) {
48344837 err = "Cannot disable swap on remount";
48354838 goto out;
48364839 }
4837− if (!(ctx->seen & SHMEM_SEEN_NOSWAP) && !ctx->noswap && sbinfo->noswap) {
4838− err = "Cannot enable swap on remount if it was disabled on first mount";
4839− goto out;
4840− }
48414840
48424841 if (ctx->seen & SHMEM_SEEN_QUOTA &&
48434842 !sb_any_quota_loaded(fc->root->d_sb)) {
security/landlock/fs.c+3−4
@@ -1335,11 +1335,10 @@ static void hook_sb_delete(struct super_block *const sb) · 1334 unmodified lines
13351335 * At this point, we own the ihold() reference that was
13361336 * originally set up by get_inode_object() and the
13371337 * __iget() reference that we just set in this loop
1338− * walk. Therefore the following call to iput() will
1339− * not sleep nor drop the inode because there is now at
1340− * least two references to it.
1338+ * walk. Therefore there are at least two references
1339+ * on the inode.
13411340 */
1342− iput(inode);
1341+ iput_not_last(inode);
13431342 } else {
13441343 spin_unlock(&object->lock);
13451344 rcu_read_unlock();

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t