-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
specification of strstr in dracut-lib #15
Comments
Rename to strglob() and introduce a new strstr() is fine. I will then announce this change on the mailing list, so that module writers, which rely on the glob could change their code. |
runsisi
added a commit
to runsisi/dracut
that referenced
this issue
Aug 6, 2022
in install_dependent_modules we use &path[kerneldirlen] as the key for inserting, let's do the same for checking. otherwise installing kernel module has circular dependency from a custom kernel module directory will cause infinite recursion and segfault. $ grep ipmi kbuilt/lib/modules/5.10.121/modules.dep kernel/drivers/char/ipmi/ipmi_msghandler.ko: kernel/drivers/char/ipmi/ipmi_devintf.ko: kernel/drivers/char/ipmi/ipmi_msghandler.ko $ grep ipmi kbuilt/lib/modules/5.10.121/modules.softdep softdep ipmi_msghandler post: ipmi_devintf $ ./dracut-install -D /tmp --kerneldir ~/working/kernel/linux-5.10.121/kbuilt/lib/modules/5.10.121 -m ipmi-devintf Segmentation fault (core dumped) (gdb) b install_dependent_modules Breakpoint 1 at 0x7db0: file src/install/dracut-install.c, line 1513. (gdb) bt #0 install_dependent_modules (modlist=0x0) at src/install/dracut-install.c:1513 dracutdevs#1 0x000055555555c027 in install_dependent_modules (modlist=modlist@entry=0x555555579e90) at src/install/dracut-install.c:1553 dracutdevs#2 0x000055555555bf1c in install_dependent_modules (modlist=0x5555555799d0) at src/install/dracut-install.c:1548 dracutdevs#3 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557a3f0) at src/install/dracut-install.c:1554 dracutdevs#4 0x000055555555bf1c in install_dependent_modules (modlist=0x555555579d60) at src/install/dracut-install.c:1548 dracutdevs#5 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557b170) at src/install/dracut-install.c:1554 dracutdevs#6 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557a0f0) at src/install/dracut-install.c:1548 dracutdevs#7 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555575320) at src/install/dracut-install.c:1554 dracutdevs#8 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557ab30) at src/install/dracut-install.c:1548 dracutdevs#9 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557dd60) at src/install/dracut-install.c:1554 dracutdevs#10 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557b640) at src/install/dracut-install.c:1548 dracutdevs#11 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557e0f0) at src/install/dracut-install.c:1554 dracutdevs#12 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557b9d0) at src/install/dracut-install.c:1548 dracutdevs#13 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555574340) at src/install/dracut-install.c:1554 dracutdevs#14 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557cf70) at src/install/dracut-install.c:1548 dracutdevs#15 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x5555555768d0) at src/install/dracut-install.c:1554 dracutdevs#16 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557d750) at src/install/dracut-install.c:1548 dracutdevs#17 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557e700) at src/install/dracut-install.c:1554 dracutdevs#18 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557de90) at src/install/dracut-install.c:1548 dracutdevs#19 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555581c90) at src/install/dracut-install.c:1554 dracutdevs#20 0x000055555555bf1c in install_dependent_modules (modlist=0x555555571e60) at src/install/dracut-install.c:1548 dracutdevs#21 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555556b620) at src/install/dracut-install.c:1554 dracutdevs#22 0x000055555555bf1c in install_dependent_modules (modlist=0x555555583000) at src/install/dracut-install.c:1548 dracutdevs#23 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555556b640) at src/install/dracut-install.c:1554 dracutdevs#24 0x000055555555bf1c in install_dependent_modules (modlist=0x555555571b40) at src/install/dracut-install.c:1548 dracutdevs#25 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555574100) at src/install/dracut-install.c:1554 dracutdevs#26 0x000055555555c4b0 in install_module (mod=mod@entry=0x555555573bc0) at src/install/dracut-install.c:1617 dracutdevs#27 0x000055555555c93d in install_modules (argc=argc@entry=1, argv=argv@entry=0x7fffffffd6e0) at src/install/dracut-install.c:1952 dracutdevs#28 0x000055555555862a in main (argc=<optimized out>, argv=0x7fffffffd6a8) at src/install/dracut-install.c:2090 Signed-off-by: runsisi <runsisi@hust.edu.cn>
johannbg
pushed a commit
that referenced
this issue
Aug 15, 2022
in install_dependent_modules we use &path[kerneldirlen] as the key for inserting, let's do the same for checking. otherwise installing kernel module has circular dependency from a custom kernel module directory will cause infinite recursion and segfault. $ grep ipmi kbuilt/lib/modules/5.10.121/modules.dep kernel/drivers/char/ipmi/ipmi_msghandler.ko: kernel/drivers/char/ipmi/ipmi_devintf.ko: kernel/drivers/char/ipmi/ipmi_msghandler.ko $ grep ipmi kbuilt/lib/modules/5.10.121/modules.softdep softdep ipmi_msghandler post: ipmi_devintf $ ./dracut-install -D /tmp --kerneldir ~/working/kernel/linux-5.10.121/kbuilt/lib/modules/5.10.121 -m ipmi-devintf Segmentation fault (core dumped) (gdb) b install_dependent_modules Breakpoint 1 at 0x7db0: file src/install/dracut-install.c, line 1513. (gdb) bt #0 install_dependent_modules (modlist=0x0) at src/install/dracut-install.c:1513 #1 0x000055555555c027 in install_dependent_modules (modlist=modlist@entry=0x555555579e90) at src/install/dracut-install.c:1553 #2 0x000055555555bf1c in install_dependent_modules (modlist=0x5555555799d0) at src/install/dracut-install.c:1548 #3 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557a3f0) at src/install/dracut-install.c:1554 #4 0x000055555555bf1c in install_dependent_modules (modlist=0x555555579d60) at src/install/dracut-install.c:1548 #5 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557b170) at src/install/dracut-install.c:1554 #6 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557a0f0) at src/install/dracut-install.c:1548 #7 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555575320) at src/install/dracut-install.c:1554 #8 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557ab30) at src/install/dracut-install.c:1548 #9 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557dd60) at src/install/dracut-install.c:1554 #10 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557b640) at src/install/dracut-install.c:1548 #11 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557e0f0) at src/install/dracut-install.c:1554 #12 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557b9d0) at src/install/dracut-install.c:1548 #13 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555574340) at src/install/dracut-install.c:1554 #14 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557cf70) at src/install/dracut-install.c:1548 #15 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x5555555768d0) at src/install/dracut-install.c:1554 #16 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557d750) at src/install/dracut-install.c:1548 #17 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555557e700) at src/install/dracut-install.c:1554 #18 0x000055555555bf1c in install_dependent_modules (modlist=0x55555557de90) at src/install/dracut-install.c:1548 #19 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555581c90) at src/install/dracut-install.c:1554 #20 0x000055555555bf1c in install_dependent_modules (modlist=0x555555571e60) at src/install/dracut-install.c:1548 #21 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555556b620) at src/install/dracut-install.c:1554 #22 0x000055555555bf1c in install_dependent_modules (modlist=0x555555583000) at src/install/dracut-install.c:1548 #23 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x55555556b640) at src/install/dracut-install.c:1554 #24 0x000055555555bf1c in install_dependent_modules (modlist=0x555555571b40) at src/install/dracut-install.c:1548 #25 0x000055555555c034 in install_dependent_modules (modlist=modlist@entry=0x555555574100) at src/install/dracut-install.c:1554 #26 0x000055555555c4b0 in install_module (mod=mod@entry=0x555555573bc0) at src/install/dracut-install.c:1617 #27 0x000055555555c93d in install_modules (argc=argc@entry=1, argv=argv@entry=0x7fffffffd6e0) at src/install/dracut-install.c:1952 #28 0x000055555555862a in main (argc=<optimized out>, argv=0x7fffffffd6a8) at src/install/dracut-install.c:2090 Signed-off-by: runsisi <runsisi@hust.edu.cn>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In C, the
strstr()
function is a literal substring match, not a pattern match; in dracut-lib, there is astrstr()
function, but it will perform a pattern match if the search argument contains shell glob characters*?[...]
. The comments in dracut-lib do not say it is a pattern match, and perhaps it was not intended to be. My first instinct would be to call it a bug, and fix it to be a literal substring match. As it is, modules may be prone to unwanted behavior if certain characters are present in input, if the module authors assumed it was a safe substring match.However, there are about 100 uses of
strstr
throughout the dracut source tree. Most of them use it as a literal string match (as far as I can see from a lazy grep). But there are about eleven places where code actually depends onstrstr
being a pattern match:So there's a dilemma. Fixing
strstr
to be a literal string match would definitely break about 11% of uses in the dracut source tree (and some unknown number of uses in modules that might be maintained elsewhere) - but it would protect the other 89% from possible breakage by unexpected input (and some unknown number maintained out-of-tree).Leaving it as is, and documenting that it is a glob match, would avoid breaking the 12% that use it that way, and eventually people could inspect the other 88% for the risk of misbehavior with strange input.
Either way, people who maintain modules (especially out of the dracut source tree) would need to know the decision, so they could inspect or update their code.
My proposal would probably be to rename the existing
strstr
to something likestrglob
, and change the known existing sites that use it that way to usestrglob
, and define a newstrstr
that is a literal match.That's probably what I would do, but I won't presume to make the call.
There are also
str_starts
andstr_ends
that are glob matches but do not say so, but I did not find any instances of them being used that way, so it is probably an easier call to simply fix them to do literal matching.I have a start on patches in a topic branch, but before making a pull request I wanted to check what the preferred approach would be.
The text was updated successfully, but these errors were encountered: