1 --- a/arch/um/drivers/mconsole_kern.c 2008-07-13 23:51:29.000000000 +0200
2 +++ b/arch/um/drivers/mconsole_kern.c 2008-07-15 15:41:54.000000000 +0200
4 * Licensed under the GPL
7 +#include "linux/kmod.h"
8 #include <linux/console.h>
9 #include <linux/ctype.h>
10 #include <linux/interrupt.h>
12 #include <linux/utsname.h>
13 #include <linux/workqueue.h>
14 #include <linux/mutex.h>
15 +#include <linux/file.h>
16 #include <asm/uaccess.h>
23 +void mconsole_exec(struct mc_request *req)
27 + char buf[MCONSOLE_MAX_DATA];
30 + "HOME=/", "TERM=linux",
31 + "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin",
36 + req->request.data + strlen("exec "),
39 + res = call_usermodehelper_pipe("/bin/sh", argv, envp, NULL, &out);
42 + mconsole_reply(req, "call_usermodehelper_pipe failed", 1, 0);
47 + len = out->f_op->read(out, buf, sizeof(buf), 0);
49 + mconsole_reply(req, "reading output failed", 1, 0);
53 + mconsole_reply_len(req, buf, len, 0, 0);
56 + mconsole_reply_len(req, buf, len, 0, 1);
61 void mconsole_proc(struct mc_request *req)
65 stop - pause the UML; it will do nothing until it receives a 'go' \n\
66 go - continue the UML after a 'stop' \n\
67 log <string> - make UML enter <string> into the kernel log\n\
68 + exec <string> - pass <string> to /bin/sh -c synchronously\n\
69 proc <file> - returns the contents of the UML's /proc/<file>\n\
70 stack <pid> - returns the stack of the specified pid\n\
72 --- a/arch/um/drivers/mconsole_user.c 2008-07-13 23:51:29.000000000 +0200
73 +++ b/arch/um/drivers/mconsole_user.c 2008-07-15 15:41:54.000000000 +0200
75 { "stop", mconsole_stop, MCONSOLE_PROC },
76 { "go", mconsole_go, MCONSOLE_INTR },
77 { "log", mconsole_log, MCONSOLE_INTR },
78 + { "exec", mconsole_exec, MCONSOLE_PROC },
79 { "proc", mconsole_proc, MCONSOLE_PROC },
80 { "stack", mconsole_stack, MCONSOLE_INTR },
82 --- a/arch/um/include/mconsole.h 2008-07-13 23:51:29.000000000 +0200
83 +++ b/arch/um/include/mconsole.h 2008-07-15 15:41:54.000000000 +0200
85 extern void mconsole_stop(struct mc_request *req);
86 extern void mconsole_go(struct mc_request *req);
87 extern void mconsole_log(struct mc_request *req);
88 +extern void mconsole_exec(struct mc_request *req);
89 extern void mconsole_proc(struct mc_request *req);
90 extern void mconsole_stack(struct mc_request *req);
92 --- a/kernel/kmod.c 2008-07-13 23:51:29.000000000 +0200
93 +++ b/kernel/kmod.c 2008-07-15 15:41:54.000000000 +0200
98 + struct file *stdout;
99 void (*cleanup)(char **argv, char **envp);
103 FD_SET(0, fdt->open_fds);
104 FD_CLR(0, fdt->close_on_exec);
105 spin_unlock(&f->file_lock);
107 - /* and disallow core files too */
109 + if (sub_info->stdout) {
110 + struct files_struct *f = current->files;
111 + struct fdtable *fdt;
115 + get_file(sub_info->stdout);
116 + fd_install(1, sub_info->stdout);
117 + fd_install(2, sub_info->stdout);
118 + spin_lock(&f->file_lock);
119 + fdt = files_fdtable(f);
120 + FD_SET(1, fdt->open_fds);
121 + FD_CLR(1, fdt->close_on_exec);
122 + FD_SET(2, fdt->open_fds);
123 + FD_CLR(2, fdt->close_on_exec);
124 + spin_unlock(&f->file_lock);
126 + if (sub_info->stdin || sub_info->stdout) {
127 + /* disallow core files */
128 current->signal->rlim[RLIMIT_CORE] = (struct rlimit){0, 0};
133 EXPORT_SYMBOL(call_usermodehelper_stdinpipe);
135 +int call_usermodehelper_stdoutpipe(struct subprocess_info *sub_info,
136 + struct file **filp)
140 + f = create_write_pipe();
143 + sub_info->stdout = f;
145 + f = create_read_pipe(f);
147 + free_write_pipe(sub_info->stdout);
148 + sub_info->stdout = NULL;
155 +EXPORT_SYMBOL(call_usermodehelper_stdoutpipe);
159 * call_usermodehelper_exec - start a usermode application
160 * @sub_info: information about the subprocessa
162 * lower-level call_usermodehelper_* functions.
164 int call_usermodehelper_pipe(char *path, char **argv, char **envp,
165 - struct file **filp)
166 + struct file **in, struct file **out)
168 struct subprocess_info *sub_info;
171 if (sub_info == NULL)
174 - ret = call_usermodehelper_stdinpipe(sub_info, filp);
178 + ret = call_usermodehelper_stdinpipe(sub_info, in);
184 + ret = call_usermodehelper_stdoutpipe(sub_info, out);
189 return call_usermodehelper_exec(sub_info, UMH_WAIT_EXEC);
191 --- a/include/linux/kmod.h 2008-07-13 23:51:29.000000000 +0200
192 +++ b/include/linux/kmod.h 2008-07-15 15:41:54.000000000 +0200
196 extern int call_usermodehelper_pipe(char *path, char *argv[], char *envp[],
197 - struct file **filp);
198 + struct file **in, struct file **out);
200 #endif /* __LINUX_KMOD_H__ */
201 --- a/fs/exec.c 2008-07-13 23:51:29.000000000 +0200
202 +++ b/fs/exec.c 2008-07-15 15:41:54.000000000 +0200
203 @@ -1741,7 +1741,7 @@
205 /* SIGPIPE can happen, but it's just never processed */
206 if (call_usermodehelper_pipe(corename+1, helper_argv, NULL,
209 printk(KERN_INFO "Core dump to %s pipe failed\n",
212 --- a/arch/um/Makefile 2008-07-13 23:51:29.000000000 +0200
213 +++ b/arch/um/Makefile 2008-07-15 16:27:02.000000000 +0200
215 KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
216 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
217 KBUILD_CFLAGS += $(KERNEL_DEFINES)
218 +KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
222 --- a/arch/um/Makefile-i386 2008-07-13 23:51:29.000000000 +0200
223 +++ b/arch/um/Makefile-i386 2008-07-15 16:23:57.000000000 +0200
225 # an unresolved reference.
226 cflags-y += -ffreestanding
228 -# Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
229 -# a lot more stack due to the lack of sharing of stacklots. Also, gcc
230 -# 4.3.0 needs -funit-at-a-time for extern inline functions.
231 -KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then \
232 - echo $(call cc-option,-fno-unit-at-a-time); \
233 - else echo $(call cc-option,-funit-at-a-time); fi ;)
235 KBUILD_CFLAGS += $(cflags-y)
236 --- a/arch/um/Makefile-x86_64 2008-07-13 23:51:29.000000000 +0200
237 +++ b/arch/um/Makefile-x86_64 2008-07-15 16:24:20.000000000 +0200
240 LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib64
243 -# Do unit-at-a-time unconditionally on x86_64, following the host
244 -KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)