Bug 242955 - kld loading broken inside chroot
Summary: kld loading broken inside chroot
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Edward Tomasz Napierala
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-29 11:15 UTC by Edward Tomasz Napierala
Modified: 2024-11-25 04:17 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Edward Tomasz Napierala freebsd_committer freebsd_triage 2019-12-29 11:15:22 UTC
It seems loading kernel modules is broken when triggered inside a chroot.  This includes both loading them using kldload(8), and autoloading triggered by eg mount(8).
Comment 1 Conrad Meyer freebsd_committer freebsd_triage 2019-12-31 02:24:05 UTC
Why would you want to load kernel modules in a chrooted filesystem namespace?
Comment 2 Edward Tomasz Napierala freebsd_committer freebsd_triage 2019-12-31 08:20:45 UTC
Same reason as outside - in my particular case to make “mount -t ext2fs” work.

Note that I’m not talking about loading modules somehow located in a file inside the chroot, I’m talking about triggering the load of the module at its usual, non-chrooted path, from inside the chroot.
Comment 3 commit-hook freebsd_committer freebsd_triage 2021-04-21 11:59:27 UTC
A commit in branch main references this bug:

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

commit 45aec46246fe61a3f45cf7da1c80850dc226f609
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-21 11:54:29 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-04-21 11:54:37 +0000

    rc: make the 'linux' script explicitly load filesystem modules

    This removes a minor annoyance with Linux jails, where you often
    want linux_mounts_enable="NO", yet you want those filesystems
    available for mounting in jails; normally mount(8) would result
    in kernel automatically loading the KLD, but this doesn't work
    inside jails or chroots.

    PR:             242955
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D29725

 libexec/rc/rc.d/linux | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-02-17 13:47:30 UTC
A commit in branch stable/13 references this bug:

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

commit 2ffd6857cca0a022620fb0ee6eec6dc17be5831d
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-21 11:54:29 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2022-02-13 23:20:29 +0000

    rc: make the 'linux' script explicitly load filesystem modules

    This removes a minor annoyance with Linux jails, where you often
    want linux_mounts_enable="NO", yet you want those filesystems
    available for mounting in jails; normally mount(8) would result
    in kernel automatically loading the KLD, but this doesn't work
    inside jails or chroots.

    PR:             242955
    Sponsored By:   EPSRC
    Differential Revision:  https://reviews.freebsd.org/D29725

    (cherry picked from commit 45aec46246fe61a3f45cf7da1c80850dc226f609)

 libexec/rc/rc.d/linux | 6 ++++++
 1 file changed, 6 insertions(+)
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2024-11-25 04:17:57 UTC
^Triage: committed and MFCed back in 2021.