From f1d2d3052a381730813ccee600768fcbb6dba022 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 2 Oct 2010 16:04:50 +0000 Subject: [PATCH] Release the vnode lock and close the linker file vnode earlier in the linker_load_file methods. The change is that the consequent linker_file_unload() call is not under the vnode lock anymore. This prevents the LOR between kernel linker sx xlock and vnode lock, because linker_file_unload() relocks kernel linker lock. MFC after: 2 weeks --- sys/kern/link_elf.c | 6 +++--- sys/kern/link_elf_obj.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index b389ace5bd49..eaaefde95222 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -967,15 +967,15 @@ nosyms: *result = lf; out: + VOP_UNLOCK(nd.ni_vp, 0); + vn_close(nd.ni_vp, FREAD, td->td_ucred, td); + VFS_UNLOCK_GIANT(vfslocked); if (error && lf) linker_file_unload(lf, LINKER_UNLOAD_FORCE); if (shdr) free(shdr, M_LINKER); if (firstpage) free(firstpage, M_LINKER); - VOP_UNLOCK(nd.ni_vp, 0); - vn_close(nd.ni_vp, FREAD, td->td_ucred, td); - VFS_UNLOCK_GIANT(vfslocked); return error; } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index b0df57dcbacf..c18885218691 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -885,13 +885,13 @@ link_elf_load_file(linker_class_t cls, const char *filename, *result = lf; out: + VOP_UNLOCK(nd.ni_vp, 0); + vn_close(nd.ni_vp, FREAD, td->td_ucred, td); + VFS_UNLOCK_GIANT(vfslocked); if (error && lf) linker_file_unload(lf, LINKER_UNLOAD_FORCE); if (hdr) free(hdr, M_LINKER); - VOP_UNLOCK(nd.ni_vp, 0); - vn_close(nd.ni_vp, FREAD, td->td_ucred, td); - VFS_UNLOCK_GIANT(vfslocked); return error; }