git: a2f57656620d - stable/13 - 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:14:02 UTC
The branch stable/13 has been updated by zlei: 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(+) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index bc2f477997e0..8f83fc4c474f 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1207,6 +1207,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);