Date: Thu, 5 Dec 2019 14:50:46 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r355417 - stable/12/sys/kern Message-ID: <201912051450.xB5Eokl2028393@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Thu Dec 5 14:50:46 2019 New Revision: 355417 URL: https://svnweb.freebsd.org/changeset/base/355417 Log: MFC r355108 and r355170: Fix panic when loading kernel modules before root file system is mounted. Make sure the rootvnode is always NULL checked. Differential Revision: https://reviews.freebsd.org/D22545 PR: 241639 Sponsored by: Mellanox Technologies Modified: stable/12/sys/kern/kern_linker.c stable/12/sys/kern/subr_firmware.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_linker.c ============================================================================== --- stable/12/sys/kern/kern_linker.c Thu Dec 5 13:43:44 2019 (r355416) +++ stable/12/sys/kern/kern_linker.c Thu Dec 5 14:50:46 2019 (r355417) @@ -2061,14 +2061,18 @@ linker_load_module(const char *kldname, const char *mo */ KASSERT(verinfo == NULL, ("linker_load_module: verinfo" " is not NULL")); + /* check if root file system is not mounted */ + if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL) + return (ENXIO); pathname = linker_search_kld(kldname); } else { if (modlist_lookup2(modname, verinfo) != NULL) return (EEXIST); + /* check if root file system is not mounted */ + if (rootvnode == NULL || curproc->p_fd->fd_rdir == NULL) + return (ENXIO); if (kldname != NULL) pathname = strdup(kldname, M_LINKER); - else if (rootvnode == NULL) - pathname = NULL; else /* * Need to find a KLD with required module Modified: stable/12/sys/kern/subr_firmware.c ============================================================================== --- stable/12/sys/kern/subr_firmware.c Thu Dec 5 13:43:44 2019 (r355416) +++ stable/12/sys/kern/subr_firmware.c Thu Dec 5 14:50:46 2019 (r355417) @@ -257,7 +257,6 @@ firmware_unregister(const char *imagename) static void loadimage(void *arg, int npending) { - struct thread *td = curthread; char *imagename = arg; struct priv_fw *fp; linker_file_t result; @@ -267,11 +266,6 @@ loadimage(void *arg, int npending) mtx_lock(&firmware_mtx); mtx_unlock(&firmware_mtx); - if (td->td_proc->p_fd->fd_rdir == NULL) { - printf("%s: root not mounted yet, no way to load image\n", - imagename); - goto done; - } error = linker_reference_module(imagename, NULL, &result); if (error != 0) { printf("%s: could not load firmware image, error %d\n",
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912051450.xB5Eokl2028393>