Date: Fri, 21 Feb 2020 01:44:31 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358192 - head/sys/kern Message-ID: <202002210144.01L1iVF3065076@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Fri Feb 21 01:44:31 2020 New Revision: 358192 URL: https://svnweb.freebsd.org/changeset/base/358192 Log: vfs: stop duplicating vnode work in audit during path lookup Duplicating the work was putting an avoidable requirement that the filedesc lock is held across the entire operation (otherwise by the time audit reads vnode pointers another thread in the same process can chdir somewhere else, making audit log things using different vnode than the one which will be used for actual lookup). Do the obvious thing and pass down vnodes which will be used. Modified: head/sys/kern/vfs_lookup.c Modified: head/sys/kern/vfs_lookup.c ============================================================================== --- head/sys/kern/vfs_lookup.c Fri Feb 21 01:40:49 2020 (r358191) +++ head/sys/kern/vfs_lookup.c Fri Feb 21 01:44:31 2020 (r358192) @@ -403,14 +403,6 @@ namei(struct nameidata *ndp) ndp->ni_rootdir = fdp->fd_rdir; ndp->ni_topdir = fdp->fd_jdir; - /* - * If we are auditing the kernel pathname, save the user pathname. - */ - if (cnp->cn_flags & AUDITVNODE1) - AUDIT_ARG_UPATH1(td, ndp->ni_dirfd, cnp->cn_pnbuf); - if (cnp->cn_flags & AUDITVNODE2) - AUDIT_ARG_UPATH2(td, ndp->ni_dirfd, cnp->cn_pnbuf); - startdir_used = 0; dp = NULL; cnp->cn_nameptr = cnp->cn_pnbuf; @@ -505,6 +497,13 @@ namei(struct nameidata *ndp) ndp->ni_lcf |= NI_LCF_LATCH; } FILEDESC_SUNLOCK(fdp); + /* + * If we are auditing the kernel pathname, save the user pathname. + */ + if (cnp->cn_flags & AUDITVNODE1) + AUDIT_ARG_UPATH1_VP(td, ndp->ni_rootdir, dp, cnp->cn_pnbuf); + if (cnp->cn_flags & AUDITVNODE2) + AUDIT_ARG_UPATH2_VP(td, ndp->ni_rootdir, dp, cnp->cn_pnbuf); if (ndp->ni_startdir != NULL && !startdir_used) vrele(ndp->ni_startdir); if (error != 0) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002210144.01L1iVF3065076>