From 1732ca8fb3ba38286da5f1f93f722b70d4cede90 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 31 May 2010 21:57:31 +0000 Subject: [PATCH] Merge r203410 from head to stable/8: Only audit pathnames in namei(9) if copying the directory string completes successfully. Continue to do this before the empty path check so that the ENOENT returned in that case gets an empty string token in the BSM record. Approved by: re (kib) --- sys/kern/vfs_lookup.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 51985622079d..6f10b49c4181 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -162,11 +162,16 @@ namei(struct nameidata *ndp) error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, (size_t *)&ndp->ni_pathlen); - /* If we are auditing the kernel pathname, save the user pathname. */ - if (cnp->cn_flags & AUDITVNODE1) - AUDIT_ARG_UPATH1(td, cnp->cn_pnbuf); - if (cnp->cn_flags & AUDITVNODE2) - AUDIT_ARG_UPATH2(td, cnp->cn_pnbuf); + if (error == 0) { + /* + * If we are auditing the kernel pathname, save the user + * pathname. + */ + if (cnp->cn_flags & AUDITVNODE1) + AUDIT_ARG_UPATH1(td, cnp->cn_pnbuf); + if (cnp->cn_flags & AUDITVNODE2) + AUDIT_ARG_UPATH2(td, cnp->cn_pnbuf); + } /* * Don't allow empty pathnames.