update-grub sorts custom kernel below older/lower package kernels

Bug #2041827 reported by mrvanes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
Fix Released
Low
Mate Kukri
Mantic
Won't Fix
Undecided
Unassigned
Noble
Fix Released
Low
Mate Kukri

Bug Description

Since the upgrade to 23.10 my custom built kernels do not sort on top of grub menu anymore, even though their number is higher than the packaged kernels:

See the output of grub-sort-version -r for the default kernel list on my system, as constructed by /etc/grub.d/10_linux

# for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do echo $i; list="$list $i"; done
/boot/vmlinuz-6.5.0-10-generic
/boot/vmlinuz-6.5.0-9-generic
/boot/vmlinuz-6.5.8
/boot/vmlinuz-6.5.9
/boot/vmlinuz-6.6.0
/vmlinuz-*
/boot/kernel-*

# echo $list | tr ' ' '\n' | sed -e 's/\.old$/ 1/; / 1$/! s/$/ 2/' | /usr/lib/grub/grub-sort-version -r | sed -e 's/ 1$/.old/; s/ 2$//'
/vmlinuz-*
/boot/vmlinuz-6.5.0-10-generic
/boot/vmlinuz-6.5.0-9-generic
/boot/vmlinuz-6.6.0 <!--- Used to be on top before 23.10
/boot/vmlinuz-6.5.9
/boot/vmlinuz-6.5.8
/boot/kernel-*

As can be seen from the output, /boot/vmlinuz-6.5.0-10-generic sorts above /boot/vmlinuz-6.6.0 which is a regression compared to 23.04

Related branches

CVE References

Revision history for this message
Julian Andres Klode (juliank) wrote :

Thank you for your bug report! This was quite a doozy.

Yes, this happens because your version number is missing a - and the script doesn't extract versions from the filenames, hence APT ends up parsing the version as

upstream: vmlinuz, revision: 6.6.0

whereas versions with a - in it like official ones are parsed as e.g.:

upstream: vmlinuz-6.5.0-10, revision: generic

Changed in grub2 (Ubuntu):
importance: Undecided → Low
status: New → Triaged
Revision history for this message
mrvanes (mrvanes) wrote :

I understand, the problem is that this is what I get from 'make install' after building the custom kernel.

Revision history for this message
mrvanes (mrvanes) wrote :

Found kernel option LOCALVERSION and added -mve there. After update-grub, my custom kernel now sorts on top. Thx!

tags: added: foundations-todo
Changed in grub2 (Ubuntu Noble):
assignee: nobody → Julian Andres Klode (juliank)
Changed in grub2 (Ubuntu Noble):
assignee: Julian Andres Klode (juliank) → Mate Kukri (mkukri)
Revision history for this message
Mate Kukri (mkukri) wrote :

This is now in proposed, setting to 'Fix committed'

Changed in grub2 (Ubuntu Noble):
status: Triaged → Fix Committed
Changed in grub2 (Ubuntu Mantic):
status: New → Won't Fix
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package grub2 - 2.12-1ubuntu7

---------------
grub2 (2.12-1ubuntu7) noble; urgency=medium

  * d/p/grub-sort-version.patch: Also patch grub-mkconfig to export GRUB_FLAVOUR_ORDER
  * d/grub-sort-version: Update regex to correctly match kernel flavour
  * d/grub-sort-version: Append `-0` to abi strings before passing to python-apt (Fixes LP: #2041827)
  * debian/: Add tests for grub-sort-version
  * Revert peimage to re-use GRUB's image handle (LP: #2057679) (LP: #2054127)
  * Increase SBAT level to "grub.ubuntu,2" and "grub.peimage,2"
  * d/build-efi-images: Make sure downstream didn't remove peimage SBAT entry
  * SECURITY UPDATE: Use-after-free in peimage module [LP: #2054127]
    - CVE-2024-2312

 -- Mate Kukri <email address hidden> Thu, 04 Apr 2024 11:12:35 +0100

Changed in grub2 (Ubuntu Noble):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.