diff options
Diffstat (limited to 'modutils/modprobe.c')
-rw-r--r-- | modutils/modprobe.c | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index f0904285b..aedde5c90 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -229,26 +229,20 @@ static ALWAYS_INLINE struct module_entry *get_or_add_modentry(const char *module | |||
229 | { | 229 | { |
230 | return helper_get_module(module, 1); | 230 | return helper_get_module(module, 1); |
231 | } | 231 | } |
232 | static ALWAYS_INLINE struct module_entry *get_modentry(const char *module) | 232 | /* So far this function always gets a module pathname, never an alias name. |
233 | * The crucial difference is that pathname needs dirname stripping, | ||
234 | * while alias name must NOT do it! | ||
235 | * Testcase where dirname stripping is likely to go wrong: "modprobe devname:snd/timer" | ||
236 | */ | ||
237 | static ALWAYS_INLINE struct module_entry *get_modentry(const char *pathname) | ||
233 | { | 238 | { |
234 | return helper_get_module(module, 0); | 239 | return helper_get_module(bb_get_last_path_component_nostrip(pathname), 0); |
235 | } | 240 | } |
236 | 241 | ||
237 | static void add_probe(const char *name) | 242 | static void add_probe(const char *name) |
238 | { | 243 | { |
239 | struct module_entry *m; | 244 | struct module_entry *m; |
240 | 245 | ||
241 | /* | ||
242 | * get_or_add_modentry() strips path from name and works | ||
243 | * on remaining basename. | ||
244 | * This would make "rmmod dir/name" and "modprobe dir/name" | ||
245 | * to work like "rmmod name" and "modprobe name", | ||
246 | * which is wrong, and can be abused via implicit modprobing: | ||
247 | * "ifconfig /usbserial up" tries to modprobe netdev-/usbserial. | ||
248 | */ | ||
249 | if (strchr(name, '/')) | ||
250 | bb_error_msg_and_die("malformed module name '%s'", name); | ||
251 | |||
252 | m = get_or_add_modentry(name); | 246 | m = get_or_add_modentry(name); |
253 | if (!(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS)) | 247 | if (!(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS)) |
254 | && (m->flags & MODULE_FLAG_LOADED) | 248 | && (m->flags & MODULE_FLAG_LOADED) |
@@ -428,7 +422,7 @@ static int do_modprobe(struct module_entry *m) | |||
428 | 422 | ||
429 | rc = 0; | 423 | rc = 0; |
430 | fn = llist_pop(&m->deps); /* we leak it */ | 424 | fn = llist_pop(&m->deps); /* we leak it */ |
431 | m2 = get_or_add_modentry(fn); | 425 | m2 = get_or_add_modentry(bb_get_last_path_component_nostrip(fn)); |
432 | 426 | ||
433 | if (option_mask32 & OPT_REMOVE) { | 427 | if (option_mask32 & OPT_REMOVE) { |
434 | /* modprobe -r */ | 428 | /* modprobe -r */ |
@@ -510,7 +504,7 @@ static void load_modules_dep(void) | |||
510 | colon = last_char_is(tokens[0], ':'); | 504 | colon = last_char_is(tokens[0], ':'); |
511 | if (colon == NULL) | 505 | if (colon == NULL) |
512 | continue; | 506 | continue; |
513 | *colon = 0; | 507 | *colon = '\0'; |
514 | 508 | ||
515 | m = get_modentry(tokens[0]); | 509 | m = get_modentry(tokens[0]); |
516 | if (m == NULL) | 510 | if (m == NULL) |
@@ -557,7 +551,6 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) | |||
557 | 551 | ||
558 | if (opt & OPT_LIST_ONLY) { | 552 | if (opt & OPT_LIST_ONLY) { |
559 | int i; | 553 | int i; |
560 | char name[MODULE_NAME_LEN]; | ||
561 | char *colon, *tokens[2]; | 554 | char *colon, *tokens[2]; |
562 | parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read); | 555 | parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read); |
563 | 556 | ||
@@ -569,10 +562,14 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv) | |||
569 | if (!colon) | 562 | if (!colon) |
570 | continue; | 563 | continue; |
571 | *colon = '\0'; | 564 | *colon = '\0'; |
572 | filename2modname(tokens[0], name); | ||
573 | if (!argv[0]) | 565 | if (!argv[0]) |
574 | puts(tokens[0]); | 566 | puts(tokens[0]); |
575 | else { | 567 | else { |
568 | char name[MODULE_NAME_LEN]; | ||
569 | filename2modname( | ||
570 | bb_get_last_path_component_nostrip(tokens[0]), | ||
571 | name | ||
572 | ); | ||
576 | for (i = 0; argv[i]; i++) { | 573 | for (i = 0; argv[i]; i++) { |
577 | if (fnmatch(argv[i], name, 0) == 0) { | 574 | if (fnmatch(argv[i], name, 0) == 0) { |
578 | puts(tokens[0]); | 575 | puts(tokens[0]); |