Date: Tue, 14 May 2019 21:11:15 +0000 (UTC) From: Konstantin Belousov <kib@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: r347581 - stable/12/sys/kern Message-ID: <201905142111.x4ELBFsZ091371@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Tue May 14 21:11:15 2019 New Revision: 347581 URL: https://svnweb.freebsd.org/changeset/base/347581 Log: MFC r347148: imgact_elf: do not relock the text vnode if possible. Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Tue May 14 20:59:44 2019 (r347580) +++ stable/12/sys/kern/imgact_elf.c Tue May 14 21:11:15 2019 (r347581) @@ -958,9 +958,12 @@ __elfN(get_interp)(struct image_params *imgp, const El interp_name_len = phdr->p_filesz; if (phdr->p_offset > PAGE_SIZE || interp_name_len > PAGE_SIZE - phdr->p_offset) { - VOP_UNLOCK(imgp->vp, 0); - interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK); - vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + interp = malloc(interp_name_len + 1, M_TEMP, M_NOWAIT); + if (interp == NULL) { + VOP_UNLOCK(imgp->vp, 0); + interp = malloc(interp_name_len + 1, M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } error = vn_rdwr(UIO_READ, imgp->vp, interp, interp_name_len, phdr->p_offset, UIO_SYSSPACE, IO_NODELOCKED, td->td_ucred, @@ -1279,7 +1282,12 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *i /* * Construct auxargs table (used by the fixup routine) */ - elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_WAITOK); + elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_NOWAIT); + if (elf_auxargs == NULL) { + VOP_UNLOCK(imgp->vp, 0); + elf_auxargs = malloc(sizeof(Elf_Auxargs), M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } elf_auxargs->execfd = -1; elf_auxargs->phdr = proghdr + et_dyn_addr; elf_auxargs->phent = hdr->e_phentsize; @@ -2559,9 +2567,12 @@ __elfN(parse_notes)(struct image_params *imgp, Elf_Not ASSERT_VOP_LOCKED(imgp->vp, "parse_notes"); if (pnote->p_offset > PAGE_SIZE || pnote->p_filesz > PAGE_SIZE - pnote->p_offset) { - VOP_UNLOCK(imgp->vp, 0); - buf = malloc(pnote->p_filesz, M_TEMP, M_WAITOK); - vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + buf = malloc(pnote->p_filesz, M_TEMP, M_NOWAIT); + if (buf == NULL) { + VOP_UNLOCK(imgp->vp, 0); + buf = malloc(pnote->p_filesz, M_TEMP, M_WAITOK); + vn_lock(imgp->vp, LK_EXCLUSIVE | LK_RETRY); + } error = vn_rdwr(UIO_READ, imgp->vp, buf, pnote->p_filesz, pnote->p_offset, UIO_SYSSPACE, IO_NODELOCKED, curthread->td_ucred, NOCRED, NULL, curthread);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905142111.x4ELBFsZ091371>