dracut icon indicating copy to clipboard operation
dracut copied to clipboard

Darcut found a fuzzy match when using the parameter --omit-drivers

Open zhrf2020 opened this issue 3 years ago • 4 comments

Describe the bug darcut found a fuzzy match when using the parameter --omit-drivers

Distribution used darcut --omit-drivers " aaxx "
At this point, there is a module (ko) on the system: aaxxwwcc.ko , this module will also be removed synchronously, because aaxxwwcc contains the characters aaxx

Dracut version latest version

Init system linux OS , eg: centos

To Reproduce none

Expected behavior Run: darcut --omit-drivers " aaxx "
At this point there is a module (ko) on the system: aaxxwwcc.ko , this module( aaxxwwcc.ko) will not be removed synchronously, only aaxx.ko will be removed

Additional context I suspect that similar regular matching is done in the code, such as a wildcard: aaxx operation, I have not found the abnormal code so far, I will continue to work hard to analyze ...... At the same time, I hope the master can give guidance,thanks very much.

zhrf2020 avatar Apr 26 '22 15:04 zhrf2020

This is an annoying regression. omit-drivers option is expected to be names of modules. And it works as expected on CentOS 7 (dracut-033-554.el7.x86_64).

But on CentOS 9 (dracut-055-30.git20220216.el9.x86_64), omit-drivers is found actually interpreted as regexp. Dracut may omit more than one module when given only one omit-drivers option.

To Reproduce

  1. Run a CentOS 9 system with an ext4 /boot
  2. Install a kernel with ext4, mbache and bache built as modules. (ext4 depends on mbcache.)
  3. dracut --omit-drivers bcache /tmp/initramfs
  4. Check ext4 in initramfs: lsinitrd /tmp/initramfs |grep ext4
  5. Check both mbcache and bcache not in initramfs: lsinitrd /tmp/initramfs |grep bcache
    • Expected mbcache is in initramfs and bcache is not

cheese avatar Jul 23 '22 14:07 cheese

Related commits

  • Change omit_drivers to support regexp expressions (in dracut-017) - https://github.com/dracutdevs/dracut/commit/34248c926cef4adeb0c73b2f89c1ba992edccd19
  • Commit introducing this functionality in dracut-install (in dracut-045). https://github.com/dracutdevs/dracut/commit/794b2d2c753489635b922457a5ccb06669f37268

Expected mbcache is in initramfs and bcache is not

I think this is a good example. It shows that the name of one kernel module could be a substring of another completely unrelated kernel module. Another example is (mc and async_memcpy).

Perhaps best to keep the dracut-install behavior as is and pass in as argument anchored regexp to do exact match.

Sadly currently we have no tests using the "omit-drivers" option.

LaszloGombos avatar Aug 24 '22 15:08 LaszloGombos

@champtar @cheese @zhrf2020 - would you be able to test the following one line change locally to verify if this works in your environment ?

https://github.com/dracutdevs/dracut/pull/1947/commits/ceae1339064adf55be3074c117706ebb60f75aab#diff-99bfb8fe311d6a59318f685a5e3401b59293b577968aa08cc4ff7320a163bb28L1348

LaszloGombos avatar Aug 24 '22 20:08 LaszloGombos

I think ^(a|b)$ is equivalent to ^a$|^b$, but your change works (tm). Side note when using configuration file, we don't have the '-' to '_' substitution, so some kmods are not excluded, don't know if you want to fix it in this PR.

champtar avatar Aug 25 '22 12:08 champtar