PR: 241639
MFC after: 1 week
Sponsored by: Mellanox Technologies
Details
Details
- Reviewers
kib - Commits
- rS355170: Factor out check for mounted root file system.
Diff Detail
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/compat/linuxkpi/common/include/linux/kmod.h | ||
---|---|---|
46 ↗ | (On Diff #64938) | Should you check if p_fd != NULL ? |
Comment Actions
I wonder if this check should be factored out? It is not only the LinuxKPI which access these code paths too early, but USB drivers loading firmware .ko's can also do the same??
Comment Actions
Index: sys/kern/kern_linker.c =================================================================== --- sys/kern/kern_linker.c (revision 355108) +++ sys/kern/kern_linker.c (working copy) @@ -2067,6 +2067,7 @@ struct linker_file *parent, const struct mod_depend *verinfo, struct linker_file **lfpp) { + struct proc *cp = curproc; linker_file_t lfdep; const char *filename; char *pathname; @@ -2079,13 +2080,13 @@ */ KASSERT(verinfo == NULL, ("linker_load_module: verinfo" " is not NULL")); - if (rootvnode == NULL) + if (rootvnode == NULL || cp->p_fd == NULL || cp->p_fd->fd_rdir == NULL) return (ENXIO); pathname = linker_search_kld(kldname); } else { if (modlist_lookup2(modname, verinfo) != NULL) return (EEXIST); - if (rootvnode == NULL) + if (rootvnode == NULL || cp->p_fd == NULL || cp->p_fd->fd_rdir == NULL) return (ENXIO); if (kldname != NULL) pathname = strdup(kldname, M_LINKER);
Why not like this? Or remove the rootvnode == NULL and only test fd_rdir ?
--HPS
Comment Actions
Check for p_fd == NULL is really not needed, because we initalize it even for proc0 with valid file descriptor table.
I think that keeping rootvnode check is still needed/useful.
Comment Actions
Keep the rootvnode check in case the root file system gets unmounted.
Update comment.
Comment Actions
In fact, I do not see much need in introducing 'p': you reference curproc only once in each branch, so caching the pointer does not save anything.