Bug 265471 - /boot/lua/menu.lua boots kernel from incorrect bootenv when bootenv is changed
Summary: /boot/lua/menu.lua boots kernel from incorrect bootenv when bootenv is changed
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.2-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Kyle Evans
URL:
Keywords: loader
Depends on:
Blocks:
 
Reported: 2022-07-27 23:47 UTC by crahman
Modified: 2023-04-20 04:41 UTC (History)
3 users (show)

See Also:
kevans: mfc-stable13?
kevans: mfc-stable12-


Attachments
Unload any previously loaded kernel when changing boot environment. (389 bytes, patch)
2022-07-27 23:47 UTC, crahman
no flags Details | Diff
Unload any previously loaded kernel when changing boot environment. (395 bytes, patch)
2022-07-28 00:19 UTC, crahman
no flags Details | Diff
Unload any previously loaded kernel when changing boot environment. (412 bytes, patch)
2023-04-09 08:09 UTC, crahman
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description crahman 2022-07-27 23:47:44 UTC
Created attachment 235516 [details]
Unload any previously loaded kernel when changing boot environment.

Related to a bug fixed by Kyle Evans <kevans@FreeBSD.org> in commit e414851f3eb7a9dd2af8209eac4ada307cb6ff8e, if a password is set for the loader, when the boot environment is changed in the lua menu, the kernel originally loaded before the menu was brought up is booted in the new boot environment.

Since the kernel directory isn't mounted, this prevents modules from being loaded during boot.  In addition, if the reason for using the boot environment is to provide a known good kernel and environment, well...

I've attached a patch.
Comment 1 crahman 2022-07-28 00:19:44 UTC
Created attachment 235518 [details]
Unload any previously loaded kernel when changing boot environment.

Too much C, not enough Lua.
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:34:12 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
Comment 3 crahman 2023-04-09 08:09:05 UTC
Created attachment 241367 [details]
Unload any previously loaded kernel when changing boot environment.

Update to 13.2-RELEASE
Comment 4 Kyle Evans freebsd_committer freebsd_triage 2023-04-09 13:35:44 UTC
Can you please provide me with a string suitable for --author attribution for one of these patches? This is typically "name <email>"
Comment 5 crahman 2023-04-09 17:30:12 UTC
Cyrus Rahman <crahman@gmail.com> would be fine.

Thanks
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-04-16 02:40:59 UTC
A commit in branch main references this bug:

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

commit d7584aa09fcf8d96544e5bfb3ea78f50d7720c0c
Author:     Cyrus Rahman <crahman@gmail.com>
AuthorDate: 2023-04-16 02:27:53 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-04-16 02:39:52 +0000

    loader: lua: unload the kernel when changing BEs

    Usually the kernel is loaded later, but there are circumstances where it
    could have been loaded earlier than changing BEs.  Unload anything that
    is already there so that we know we're using artifacts from the proper
    environment.

    PR:             265471
    Reviewed by:    kevans
    MFC after:      3 days

 stand/lua/menu.lua | 3 +++
 1 file changed, 3 insertions(+)
Comment 7 Kyle Evans freebsd_committer freebsd_triage 2023-04-16 02:41:58 UTC
Sorry for the delay, thanks for the patches! I'll MFC these to stable/13 within a week or so.
Comment 8 commit-hook freebsd_committer freebsd_triage 2023-04-20 04:15:44 UTC
A commit in branch stable/13 references this bug:

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

commit 7e5811f76bb0df289b32144849331a2db83ac718
Author:     Cyrus Rahman <crahman@gmail.com>
AuthorDate: 2023-04-16 02:27:53 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2023-04-20 04:15:15 +0000

    loader: lua: unload the kernel when changing BEs

    Usually the kernel is loaded later, but there are circumstances where it
    could have been loaded earlier than changing BEs.  Unload anything that
    is already there so that we know we're using artifacts from the proper
    environment.

    PR:             265471
    Reviewed by:    kevans
    MFC after:      3 days

    (cherry picked from commit d7584aa09fcf8d96544e5bfb3ea78f50d7720c0c)

 stand/lua/menu.lua | 3 +++
 1 file changed, 3 insertions(+)
Comment 9 Kyle Evans freebsd_committer freebsd_triage 2023-04-20 04:41:28 UTC
Thanks for the patch!