[Bug 2084071] [NEW] grub-mkconfig mistakingly adds a devicetree command when the dtb file is actually a directory

Michaƫl Blanc 2084071 at bugs.launchpad.net
Wed Oct 9 15:58:18 UTC 2024


Public bug reported:

grub-mkconfig adds a "devicetree /boot/dtb" command even if /boot/dtb is
a directory, causing grub to complain at bootup with "Not a regular
file", which may prevent automatic bootup, as user interaction is needed
to acknowledge this warning.

/etc/grub.d/10_linux is responsible for detecting and adding the
command:

    if test -n "${dtb}" ; then
      if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
        message="$(gettext_printf "Loading device tree blob...")"
        sed "s/^/$submenu_indentation/" << EOF
        echo    '$(echo "$message" | grub_quote)'
EOF
      fi
      sed "s/^/$submenu_indentation/" << EOF 
        devicetree      ${rel_dirname}/${dtb}
EOF 
    fi
[...]
  dtb=
  for i in "dtb-${version}" "dtb-${alt_version}" "dtb"; do
    if test -e "${dirname}/${i}" ; then
      dtb="$i"
      break
    fi
  done

Since "dtb" exists in /boot, the dtb variable is not empty and the
command gets added. The test command is wrong, it catches directories,
so the command should be added only if the file exists (-e) AND if it's
not a directory (! -d). This piece of code comes from ubuntu-add-
devicetree-command-support.patch, see my patch for a potential fix.

** Affects: grub2 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: patch

** Patch added: "dtb_test.patch"
   https://bugs.launchpad.net/bugs/2084071/+attachment/5826490/+files/dtb_test.patch

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to grub2 in Ubuntu.
https://bugs.launchpad.net/bugs/2084071

Title:
  grub-mkconfig mistakingly adds a devicetree command when the dtb file
  is actually a directory

Status in grub2 package in Ubuntu:
  New

Bug description:
  grub-mkconfig adds a "devicetree /boot/dtb" command even if /boot/dtb
  is a directory, causing grub to complain at bootup with "Not a regular
  file", which may prevent automatic bootup, as user interaction is
  needed to acknowledge this warning.

  /etc/grub.d/10_linux is responsible for detecting and adding the
  command:

      if test -n "${dtb}" ; then
        if [ x"$quiet_boot" = x0 ] || [ x"$type" != xsimple ]; then
          message="$(gettext_printf "Loading device tree blob...")"
          sed "s/^/$submenu_indentation/" << EOF
          echo    '$(echo "$message" | grub_quote)'
  EOF
        fi
        sed "s/^/$submenu_indentation/" << EOF 
          devicetree      ${rel_dirname}/${dtb}
  EOF 
      fi
  [...]
    dtb=
    for i in "dtb-${version}" "dtb-${alt_version}" "dtb"; do
      if test -e "${dirname}/${i}" ; then
        dtb="$i"
        break
      fi
    done

  Since "dtb" exists in /boot, the dtb variable is not empty and the
  command gets added. The test command is wrong, it catches directories,
  so the command should be added only if the file exists (-e) AND if
  it's not a directory (! -d). This piece of code comes from ubuntu-add-
  devicetree-command-support.patch, see my patch for a potential fix.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/2084071/+subscriptions




More information about the foundations-bugs mailing list