Skip to content

Commit 807602d

Browse files
cypharbrauner
authored andcommitted
vfs: output mount_too_revealing() errors to fscontext
It makes little sense for fsmount() to output the warning message when mount_too_revealing() is violated to kmsg. Instead, the warning should be output (with a "VFS" prefix) to the fscontext log. In addition, include the same log message for mount_too_revealing() when doing a regular mount for consistency. With the newest fsopen()-based mount(8) from util-linux, the error messages now look like # mount -t proc proc /tmp mount: /tmp: fsmount() failed: VFS: Mount too revealing. dmesg(1) may have more information after failed mount system call. which could finally result in mount_too_revealing() errors being easier for users to detect and understand. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> Link: https://lore.kernel.org/20250806-errorfc-mount-too-revealing-v2-2-534b9b4d45bb@cyphar.com Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent ad7fe23 commit 807602d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fs/namespace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3724,8 +3724,10 @@ static int do_new_mount_fc(struct fs_context *fc, struct path *mountpoint,
37243724
int error;
37253725

37263726
error = security_sb_kern_mount(sb);
3727-
if (!error && mount_too_revealing(sb, &mnt_flags))
3727+
if (!error && mount_too_revealing(sb, &mnt_flags)) {
3728+
errorfcp(fc, "VFS", "Mount too revealing");
37283729
error = -EPERM;
3730+
}
37293731

37303732
if (unlikely(error)) {
37313733
fc_drop_locked(fc);
@@ -4441,7 +4443,7 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags,
44414443

44424444
ret = -EPERM;
44434445
if (mount_too_revealing(fc->root->d_sb, &mnt_flags)) {
4444-
pr_warn("VFS: Mount too revealing\n");
4446+
errorfcp(fc, "VFS", "Mount too revealing");
44454447
goto err_unlock;
44464448
}
44474449

0 commit comments

Comments
 (0)