Bug 293654 - boot loader kernels_autodetect no longer follows symlinks after 14.4-RELEASE
Summary: boot loader kernels_autodetect no longer follows symlinks after 14.4-RELEASE
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 14.4-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Craig Leres
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2026-03-07 21:52 UTC by Craig Leres
Modified: 2026-08-26 16:48 UTC (History)
2 users (show)

See Also:
leres: mfc-stable15+
leres: mfc-stable14+
leres: needs_errata+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Leres freebsd_committer freebsd_triage 2026-03-07 21:52:08 UTC
While d04415c520b03 fixed PR 292232, the code in core.kernelList() was testing for directories in a way that prevented symlinks from being followed. This prevents a kernel symlink from being considered "bootable" which results in a random kernel not named "kernel" being booted. (Random because the list of potentially bootable kernels is in unsorted/filesystem order.)

This means when I attempt to boot kernel/kernel.LBL in the above example, I get kernel.GENERIC instead.

core.kernelList() has two checks to see if a candidate file is a "directory", first is the ftype returned by lfs.dir() (which doesn't follow symlinks) and the other is via lfs.attributes() (which does follow symlinks):

        for file, ftype in lfs.dir("/boot") do
                local fname = "/boot/" .. file

                if file == "." or file == ".." then
                        goto continue
                end

                if ftype then
                        if ftype ~= lfs.DT_DIR then
                                goto continue
                        end
                elseif lfs.attributes(fname, "mode") ~= "directory" then
                        goto continue
                end

The fix is to remove the first check. Here's a differential that solves this by my testing:

    https://reviews.freebsd.org/D55713
Comment 1 commit-hook freebsd_committer freebsd_triage 2026-03-09 21:48:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e6d579be42550f366cc85188b15c6eb0cad27367

commit e6d579be42550f366cc85188b15c6eb0cad27367
Author:     Craig Leres <leres@FreeBSD.org>
AuthorDate: 2026-03-09 21:47:10 +0000
Commit:     Craig Leres <leres@FreeBSD.org>
CommitDate: 2026-03-09 21:47:47 +0000

    core.lua: follow symlinks when looking for bootable kernels

    PR: 293654
    Reviewed by:    kevans
    Approved by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55713

 stand/lua/core.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 2 Kyle Evans freebsd_committer freebsd_triage 2026-03-13 04:03:29 UTC
This is a good candidate for MFC to both stable/15 and stable/14 -- would you like to do it, or would you like me to just take it with bc531a96c9b28b1cabcd5d that modified lfs?
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2026-03-13 04:28:12 UTC
The fact that this hit 14.4 didn't really settle in until after I made that last comment- symlinked /boot/kernel probably isn't /that/ common of a setup, but I don't like the idea of leaving it broken.

Taking for the moment as I'll write up the errata notice, then pass it over to secteam@ for consideration.
Comment 5 Craig Leres freebsd_committer freebsd_triage 2026-03-13 04:33:24 UTC
(In reply to Kyle Evans from comment #2)
Sure, it makes sense to bundle the two fixes. Plus it's an opportunity to remove the magic number from core.lua.
Comment 6 Kyle Evans freebsd_committer freebsd_triage 2026-03-13 05:25:31 UTC
(In reply to Craig Leres from comment #5)

> Sure, it makes sense to bundle the two fixes.

It will be done.

> Plus it's an opportunity to remove the magic number from core.lua.

Unfortunately, the magic number likely has a 2-3 year lifespan.  We don't auto-update loader on the ESP, so we've had some problems with the disconnect caused by folks not doing it themselves (the documentation around this is admittedly not great, last I checked).
Comment 7 Craig Leres freebsd_committer freebsd_triage 2026-03-13 06:08:07 UTC
(In reply to Kyle Evans from comment #6)
Is the loaders-update port a good way to keep boot loaders up to date?
Comment 8 commit-hook freebsd_committer freebsd_triage 2026-06-16 23:49:34 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1841091eaa0b2e1f71600c892d3ce041a57bae3c

commit 1841091eaa0b2e1f71600c892d3ce041a57bae3c
Author:     Craig Leres <leres@FreeBSD.org>
AuthorDate: 2026-03-09 21:47:10 +0000
Commit:     Craig Leres <leres@FreeBSD.org>
CommitDate: 2026-06-16 23:48:16 +0000

    core.lua: follow symlinks when looking for bootable kernels

    PR: 293654
    Reviewed by:    kevans
    Approved by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55713

    (cherry picked from commit e6d579be42550f366cc85188b15c6eb0cad27367)

 stand/lua/core.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2026-06-16 23:50:35 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c78774107a7f0434791efd3f99397cb5562a70d

commit 8c78774107a7f0434791efd3f99397cb5562a70d
Author:     Craig Leres <leres@FreeBSD.org>
AuthorDate: 2026-03-09 21:47:10 +0000
Commit:     Craig Leres <leres@FreeBSD.org>
CommitDate: 2026-06-16 23:49:30 +0000

    core.lua: follow symlinks when looking for bootable kernels

    PR: 293654
    Reviewed by:    kevans
    Approved by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55713

    (cherry picked from commit e6d579be42550f366cc85188b15c6eb0cad27367)

 stand/lua/core.lua | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)