Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: fix incorrect lflags value in the move_mount syscall

The lflags value used to look up from_path was overwritten by the one used
to look up to_path.

In other words, from_path was looked up with the wrong lflags value. Fix it.

Fixes: f9fde814de37 ("fs: support getname_maybe_null() in move_mount()")
Signed-off-by: Yuntao Wang <yuntao.wang@linux.dev>
Link: https://lore.kernel.org/20250811052426.129188-1-yuntao.wang@linux.dev
[Christian Brauner <brauner@kernel.org>: massage patch]
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Yuntao Wang and committed by
Christian Brauner
593d9e4c 2319f9d0

+20 -12
+20 -12
fs/namespace.c
··· 4551 4551 if (flags & MOVE_MOUNT_SET_GROUP) mflags |= MNT_TREE_PROPAGATION; 4552 4552 if (flags & MOVE_MOUNT_BENEATH) mflags |= MNT_TREE_BENEATH; 4553 4553 4554 - lflags = 0; 4555 - if (flags & MOVE_MOUNT_F_SYMLINKS) lflags |= LOOKUP_FOLLOW; 4556 - if (flags & MOVE_MOUNT_F_AUTOMOUNTS) lflags |= LOOKUP_AUTOMOUNT; 4557 4554 uflags = 0; 4558 - if (flags & MOVE_MOUNT_F_EMPTY_PATH) uflags = AT_EMPTY_PATH; 4559 - from_name = getname_maybe_null(from_pathname, uflags); 4560 - if (IS_ERR(from_name)) 4561 - return PTR_ERR(from_name); 4555 + if (flags & MOVE_MOUNT_T_EMPTY_PATH) 4556 + uflags = AT_EMPTY_PATH; 4562 4557 4563 - lflags = 0; 4564 - if (flags & MOVE_MOUNT_T_SYMLINKS) lflags |= LOOKUP_FOLLOW; 4565 - if (flags & MOVE_MOUNT_T_AUTOMOUNTS) lflags |= LOOKUP_AUTOMOUNT; 4566 - uflags = 0; 4567 - if (flags & MOVE_MOUNT_T_EMPTY_PATH) uflags = AT_EMPTY_PATH; 4568 4558 to_name = getname_maybe_null(to_pathname, uflags); 4569 4559 if (IS_ERR(to_name)) 4570 4560 return PTR_ERR(to_name); ··· 4567 4577 to_path = fd_file(f_to)->f_path; 4568 4578 path_get(&to_path); 4569 4579 } else { 4580 + lflags = 0; 4581 + if (flags & MOVE_MOUNT_T_SYMLINKS) 4582 + lflags |= LOOKUP_FOLLOW; 4583 + if (flags & MOVE_MOUNT_T_AUTOMOUNTS) 4584 + lflags |= LOOKUP_AUTOMOUNT; 4570 4585 ret = filename_lookup(to_dfd, to_name, lflags, &to_path, NULL); 4571 4586 if (ret) 4572 4587 return ret; 4573 4588 } 4589 + 4590 + uflags = 0; 4591 + if (flags & MOVE_MOUNT_F_EMPTY_PATH) 4592 + uflags = AT_EMPTY_PATH; 4593 + 4594 + from_name = getname_maybe_null(from_pathname, uflags); 4595 + if (IS_ERR(from_name)) 4596 + return PTR_ERR(from_name); 4574 4597 4575 4598 if (!from_name && from_dfd >= 0) { 4576 4599 CLASS(fd_raw, f_from)(from_dfd); ··· 4593 4590 return vfs_move_mount(&fd_file(f_from)->f_path, &to_path, mflags); 4594 4591 } 4595 4592 4593 + lflags = 0; 4594 + if (flags & MOVE_MOUNT_F_SYMLINKS) 4595 + lflags |= LOOKUP_FOLLOW; 4596 + if (flags & MOVE_MOUNT_F_AUTOMOUNTS) 4597 + lflags |= LOOKUP_AUTOMOUNT; 4596 4598 ret = filename_lookup(from_dfd, from_name, lflags, &from_path, NULL); 4597 4599 if (ret) 4598 4600 return ret;