[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] Load modules by absolute path in busybox modprobe
From:       Richard Yao <ryao () gentoo ! org>
Date:       2015-08-29 22:05:23
Message-ID: 1440885923-13984-1-git-send-email-ryao () gentoo ! org
[Download RAW message or body]

Loading the ZFS modules with busybox modprobe was found to be broken
last year. At the time, strace analysis strongly suggested that loading
two modules corrupts busybox's current working directory inside the
kernel. Subsequent tests where absolute paths were used instead of
relative ones made the problem disappear.

https://gitweb.gentoo.org/proj/genkernel.git/commit/patches/busybox/1.20.2/busybox-1.20.2-modprobe.patch?id=006a5d6d56e622b5ef82e5a066ca7af7b8c2aeed


Gentoo's genkernel has been carrying a version of this patch for 18
months. I would like to upstream it. The only difference between this
patch and the genkernel one is that this uses xasprintf instead of
xmalloc()/sprintf() as per Mike Frysinger's suggestion.

Signed-off-by: Richard Yao <ryao@gentoo.org>
---
 modutils/modprobe.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index 996de40..825d8ea 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -417,7 +417,7 @@ static int do_modprobe(struct module_entry *m)
 	rc = 0;
 	while (m->deps) {
 		struct module_entry *m2;
-		char *fn, *options;
+		char *fn, *options, *path;
 
 		rc = 0;
 		fn = llist_pop(&m->deps); /* we leak it */
@@ -464,7 +464,10 @@ static int do_modprobe(struct module_entry *m)
 			continue;
 		}
 
-		rc = bb_init_module(fn, options);
+		path = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, G.uts.release, fn);
+
+		rc = bb_init_module(path, options);
+		free(path);
 		DBG("loaded %s '%s', rc:%d", fn, options, rc);
 		if (rc == EEXIST)
 			rc = 0;
-- 
2.4.6

_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic