git: f1994d1eb215 - stable/14 - kern linker: Do not unload a module if it has dependants
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 09 Apr 2024 04:11:15 UTC
The branch stable/14 has been updated by zlei:
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(+)
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 2b220295f78e..69c746fe376d 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -1222,6 +1222,8 @@ kern_kldunload(struct thread *td, int fileid, int flags)
printf("kldunload: attempt to unload file that was"
" loaded by the kernel\n");
error = EBUSY;
+ } else if (lf->refs > 1) {
+ error = EBUSY;
} else {
lf->userrefs--;
error = linker_file_unload(lf, flags);