[bug #66827] `grub-mount' hang with 100% CPU usage on `ls' operations with wildcards

Mingcong Bai <[email protected]> Fri, 21 Feb 2025 11:00:29 -0500 (EST)
Newsgroups gmane.comp.boot-loaders.grub.bugs
Message-ID <[email protected]>
URL:
  <https://savannah.gnu.org/bugs/?66827>

                 Summary: `grub-mount' hang with 100% CPU usage on `ls'
operations with wildcards
                   Group: GNU GRUB
               Submitter: mingcongbai
               Submitted: Fri 21 Feb 2025 04:00:26 PM UTC
                Category: Filesystem
                Severity: Major
                Priority: 5 - Normal
              Item Group: Software Error
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name:
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any
                 Release: other
                 Release:
         Reproducibility: Every Time
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Fri 21 Feb 2025 04:00:26 PM UTC By: Mingcong Bai <mingcongbai>
(GRUB 2.12)

---

If a system partition was mounted via grub-mount, whenever any script or user
calls a `ls' command with wildcards, the command would never complete.

For instance, if /dev/nvme0n1p6 was mounted at /mnt via `grub-mount
/dev/nvme0n1p6 /mnt' and if someone calls `ls /mnt/bin/bash*', the command
would hang. With `ls /mnt/bin/bash[Tab]`, the same hang would occur. At this
point, neither ^C or ^Z would be able to interrupt/suspend that command, only
a SIGKILL on the `grub-mount' process would terminate the command.

However, with any `ls' command that does not involve a wildcard, say, `ls
/mnt/bin/bash', the aforementioned issue would not occur.

---

Incidentally (and how I found out about this issue), in os-prober's
90linux-distro scriptlet, the `if' condition tests for certain ld.so patterns
with wildcards:

  /usr/lib/os-probes/mounted/90linux-distro:

  if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls
"$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then
      ...

A user indicated that their `update-grub' invocations would hang at the
os-prober stage. With some script debugging I was able to locate this issue. 

As such, this will cause os-prober to hang as it probes Linux system roots.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?66827>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCZ7ijHQAKCRCqLAuaBUf3
TiA6AQCaDhBoB4mDCwECSPHwzq6aouftRIRNEo0+lqEAmuCC9QD/Req2+qQri+Lg
IcOxruJ63KxJrnIX44+RyGRLL3o2EAs=
=S6/M
-----END PGP SIGNATURE-----