[git commit] Added kernel patch for /proc/self/exe to examples

Denys Vlasenko vda.linux at googlemail.com
Thu Jul 2 10:04:50 UTC 2009


commit: http://git.busybox.net/busybox/commit/?id=cf4e503875814ce6e4ff8666fb4a0350ca72c6e4
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master


Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 examples/linux-2.6.30_proc_self_exe.patch |   34 +++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)
 create mode 100644 examples/linux-2.6.30_proc_self_exe.patch

diff --git a/examples/linux-2.6.30_proc_self_exe.patch b/examples/linux-2.6.30_proc_self_exe.patch
new file mode 100644
index 0000000..a36581b
--- /dev/null
+++ b/examples/linux-2.6.30_proc_self_exe.patch
@@ -0,0 +1,34 @@
+This patch makes /proc/self/exe executable even if proc
+is not mounted. It is especially useful on NOMMU arches.
+
+diff -urp ../linux-2.6.30.org/fs/exec.c linux-2.6.30/fs/exec.c
+--- ../linux-2.6.30.org/fs/exec.c	2009-06-10 05:05:27.000000000 +0200
++++ linux-2.6.30/fs/exec.c	2009-06-25 00:20:13.000000000 +0200
+@@ -652,9 +652,25 @@ struct file *open_exec(const char *name)
+ 	file = do_filp_open(AT_FDCWD, name,
+ 				O_LARGEFILE | O_RDONLY | FMODE_EXEC, 0,
+ 				MAY_EXEC | MAY_OPEN);
+-	if (IS_ERR(file))
+-		goto out;
++	if (IS_ERR(file)) {
++		if ((PTR_ERR(file) == -ENOENT || PTR_ERR(file) == -EACCES)
++		 && strcmp(name, "/proc/self/exe") == 0
++		) {
++			struct file *sv = file;
++			struct mm_struct *mm;
+ 
++			mm = get_task_mm(current);
++			if (!mm)
++				goto out;
++			file = get_mm_exe_file(mm);
++			mmput(mm);
++			if (file)
++				goto ok;
++			file = sv;
++		}
++		goto out;
++	}
++ok:
+ 	err = -EACCES;
+ 	if (!S_ISREG(file->f_path.dentry->d_inode->i_mode))
+ 		goto exit;
-- 
1.6.3.3


More information about the busybox-cvs mailing list