Bug 274986 - False positive to unload module dependencies
Summary: False positive to unload module dependencies
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 15.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Zhenlei Huang
URL: https://reviews.freebsd.org/D42527
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-09 09:50 UTC by Zhenlei Huang
Modified: 2024-04-09 04:17 UTC (History)
0 users

See Also:
zlei: mfc-stable14+
zlei: mfc-stable13+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenlei Huang freebsd_committer freebsd_triage 2023-11-09 09:50:23 UTC
Steps to repeat:

```
# kldload bridgestp
# kldload if_bridge
# kldunload bridgestp && echo OK
OK
```

Try the second time:
```
# kldunload bridgestp
kldunload: can't unload file: Device busy
```

Expected behavior: since bridgestp.ko is dependency of if_bridge.ko , it makes no senses to unload it with **SUCCESS** .
Comment 1 commit-hook freebsd_committer freebsd_triage 2024-03-26 03:57:53 UTC
A commit in branch main references this bug:

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

commit f43ff3e15c8b4b161ce09c8ab008abc4222db26b
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-03-26 03:55:45 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-03-26 03:55:45 +0000

    kern linker: Do not unload a module if it has dependants

    Despite the name, linker_file_unload() will drop a reference and return
    success when the module file has dependants, i.e. it has more than one
    reference. When user request to unload such modules then the kernel
    should reject unambiguously and immediately.

    PR:             274986
    Reviewed by:    dfr, dab, jhb
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D42527

 sys/kern/kern_linker.c | 2 ++
 1 file changed, 2 insertions(+)
Comment 2 commit-hook freebsd_committer freebsd_triage 2024-04-09 04:11:23 UTC
A commit in branch stable/14 references this bug:

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

commit f1994d1eb215a2b7cb644329797dc623ec883120
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-03-26 03:55:45 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-04-09 04:10:07 +0000

    kern linker: Do not unload a module if it has dependants

    Despite the name, linker_file_unload() will drop a reference and return
    success when the module file has dependants, i.e. it has more than one
    reference. When user request to unload such modules then the kernel
    should reject unambiguously and immediately.

    PR:             274986
    Reviewed by:    dfr, dab, jhb
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D42527

    (cherry picked from commit f43ff3e15c8b4b161ce09c8ab008abc4222db26b)

 sys/kern/kern_linker.c | 2 ++
 1 file changed, 2 insertions(+)
Comment 3 commit-hook freebsd_committer freebsd_triage 2024-04-09 04:14:24 UTC
A commit in branch stable/13 references this bug:

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

commit a2f57656620d2ffbb8b79789de34a6fc657286d5
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-03-26 03:55:45 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-04-09 04:13:08 +0000

    kern linker: Do not unload a module if it has dependants

    Despite the name, linker_file_unload() will drop a reference and return
    success when the module file has dependants, i.e. it has more than one
    reference. When user request to unload such modules then the kernel
    should reject unambiguously and immediately.

    PR:             274986
    Reviewed by:    dfr, dab, jhb
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D42527

    (cherry picked from commit f43ff3e15c8b4b161ce09c8ab008abc4222db26b)
    (cherry picked from commit f1994d1eb215a2b7cb644329797dc623ec883120)

 sys/kern/kern_linker.c | 2 ++
 1 file changed, 2 insertions(+)