Skip to content

Commit 76313c7

Browse files
committed
uml: Create a private mount of proc for mconsole
The mconsole code only ever accesses proc for the initial pid namespace. Instead of depending upon the proc_mnt which is for proc_flush_task have uml create it's own mount of proc instead. This allows proc_flush_task to evolve and remove the need for having a proc_mnt to do it's job. Cc: Jeff Dike <[email protected]> Cc: Richard Weinberger <[email protected]> Cc: Anton Ivanov <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent af1abab commit 76313c7

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

arch/um/drivers/mconsole_kern.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include "mconsole_kern.h"
3737
#include <os.h>
3838

39+
static struct vfsmount *proc_mnt = NULL;
40+
3941
static int do_unlink_socket(struct notifier_block *notifier,
4042
unsigned long what, void *data)
4143
{
@@ -123,7 +125,7 @@ void mconsole_log(struct mc_request *req)
123125

124126
void mconsole_proc(struct mc_request *req)
125127
{
126-
struct vfsmount *mnt = init_pid_ns.proc_mnt;
128+
struct vfsmount *mnt = proc_mnt;
127129
char *buf;
128130
int len;
129131
struct file *file;
@@ -134,6 +136,10 @@ void mconsole_proc(struct mc_request *req)
134136
ptr += strlen("proc");
135137
ptr = skip_spaces(ptr);
136138

139+
if (!mnt) {
140+
mconsole_reply(req, "Proc not available", 1, 0);
141+
goto out;
142+
}
137143
file = file_open_root(mnt->mnt_root, mnt, ptr, O_RDONLY, 0);
138144
if (IS_ERR(file)) {
139145
mconsole_reply(req, "Failed to open file", 1, 0);
@@ -683,6 +689,24 @@ void mconsole_stack(struct mc_request *req)
683689
with_console(req, stack_proc, to);
684690
}
685691

692+
static int __init mount_proc(void)
693+
{
694+
struct file_system_type *proc_fs_type;
695+
struct vfsmount *mnt;
696+
697+
proc_fs_type = get_fs_type("proc");
698+
if (!proc_fs_type)
699+
return -ENODEV;
700+
701+
mnt = kern_mount(proc_fs_type);
702+
put_filesystem(proc_fs_type);
703+
if (IS_ERR(mnt))
704+
return PTR_ERR(mnt);
705+
706+
proc_mnt = mnt;
707+
return 0;
708+
}
709+
686710
/*
687711
* Changed by mconsole_setup, which is __setup, and called before SMP is
688712
* active.
@@ -696,6 +720,8 @@ static int __init mconsole_init(void)
696720
int err;
697721
char file[UNIX_PATH_MAX];
698722

723+
mount_proc();
724+
699725
if (umid_file_name("mconsole", file, sizeof(file)))
700726
return -1;
701727
snprintf(mconsole_socket_name, sizeof(file), "%s", file);

0 commit comments

Comments
 (0)