summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-06-21 13:41:32 +0000
committerkib <kib@FreeBSD.org>2009-06-21 13:41:32 +0000
commit171c37f865ca934d583ae77a7edb3e6818a364bb (patch)
tree548a61c5fc4bd14c03a515783550b0e6868c9c0b /sys/kern
parentb91bec2bd9b4fd4d1c040ca5254dc4b95c6c9ee1 (diff)
downloadFreeBSD-src-171c37f865ca934d583ae77a7edb3e6818a364bb.zip
FreeBSD-src-171c37f865ca934d583ae77a7edb3e6818a364bb.tar.gz
Add another flags argument to vn_open_cred. Use it to specify that some
vn_open_cred invocations shall not audit namei path. In particular, specify VN_OPEN_NOAUDIT for dotdot lookup performed by default implementation of vop_vptocnp, and for the open done for core file. vn_fullpath is called from the audit code, and vn_open there need to disable audit to avoid infinite recursion. Core file is created on return to user mode, that, in particular, happens during syscall return. The creation of the core file is audited by direct calls, and we do not want to overwrite audit information for syscall. Reported, reviewed and tested by: rwatson
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_alq.c2
-rw-r--r--sys/kern/kern_sig.c3
-rw-r--r--sys/kern/vfs_default.c2
-rw-r--r--sys/kern/vfs_vnops.c17
4 files changed, 13 insertions, 11 deletions
diff --git a/sys/kern/kern_alq.c b/sys/kern/kern_alq.c
index 5296928..a4ece79 100644
--- a/sys/kern/kern_alq.c
+++ b/sys/kern/kern_alq.c
@@ -351,7 +351,7 @@ alq_open(struct alq **alqp, const char *file, struct ucred *cred, int cmode,
NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, file, td);
flags = FWRITE | O_NOFOLLOW | O_CREAT;
- error = vn_open_cred(&nd, &flags, cmode, cred, NULL);
+ error = vn_open_cred(&nd, &flags, cmode, 0, cred, NULL);
if (error)
return (error);
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 5c1d553..57afc23 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -2940,7 +2940,8 @@ coredump(struct thread *td)
restart:
NDINIT(&nd, LOOKUP, NOFOLLOW | MPSAFE, UIO_SYSSPACE, name, td);
flags = O_CREAT | FWRITE | O_NOFOLLOW;
- error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR, NULL);
+ error = vn_open_cred(&nd, &flags, S_IRUSR | S_IWUSR, VN_OPEN_NOAUDIT,
+ NULL, NULL);
if (error) {
#ifdef AUDIT
audit_proc_coredump(td, name, error);
diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c
index 7b82a96..c98dad0 100644
--- a/sys/kern/vfs_default.c
+++ b/sys/kern/vfs_default.c
@@ -723,7 +723,7 @@ vop_stdvptocnp(struct vop_vptocnp_args *ap)
NDINIT_ATVP(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_SYSSPACE,
"..", vp, td);
flags = FREAD;
- error = vn_open(&nd, &flags, 0, NULL);
+ error = vn_open_cred(&nd, &flags, 0, VN_OPEN_NOAUDIT, NULL, NULL);
if (error) {
vn_lock(vp, locked | LK_RETRY);
return (error);
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 9ffb6a6..bef2804 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -91,7 +91,7 @@ vn_open(ndp, flagp, cmode, fp)
{
struct thread *td = ndp->ni_cnd.cn_thread;
- return (vn_open_cred(ndp, flagp, cmode, td->td_ucred, fp));
+ return (vn_open_cred(ndp, flagp, cmode, 0, td->td_ucred, fp));
}
/*
@@ -102,11 +102,8 @@ vn_open(ndp, flagp, cmode, fp)
* due to the NDINIT being done elsewhere.
*/
int
-vn_open_cred(ndp, flagp, cmode, cred, fp)
- struct nameidata *ndp;
- int *flagp, cmode;
- struct ucred *cred;
- struct file *fp;
+vn_open_cred(struct nameidata *ndp, int *flagp, int cmode, u_int vn_open_flags,
+ struct ucred *cred, struct file *fp)
{
struct vnode *vp;
struct mount *mp;
@@ -124,9 +121,11 @@ restart:
if (fmode & O_CREAT) {
ndp->ni_cnd.cn_nameiop = CREATE;
ndp->ni_cnd.cn_flags = ISOPEN | LOCKPARENT | LOCKLEAF |
- MPSAFE | AUDITVNODE1;
+ MPSAFE;
if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0)
ndp->ni_cnd.cn_flags |= FOLLOW;
+ if (!(vn_open_flags & VN_OPEN_NOAUDIT))
+ ndp->ni_cnd.cn_flags |= AUDITVNODE1;
bwillwrite();
if ((error = namei(ndp)) != 0)
return (error);
@@ -181,9 +180,11 @@ restart:
ndp->ni_cnd.cn_nameiop = LOOKUP;
ndp->ni_cnd.cn_flags = ISOPEN |
((fmode & O_NOFOLLOW) ? NOFOLLOW : FOLLOW) |
- LOCKLEAF | MPSAFE | AUDITVNODE1;
+ LOCKLEAF | MPSAFE;
if (!(fmode & FWRITE))
ndp->ni_cnd.cn_flags |= LOCKSHARED;
+ if (!(vn_open_flags & VN_OPEN_NOAUDIT))
+ ndp->ni_cnd.cn_flags |= AUDITVNODE1;
if ((error = namei(ndp)) != 0)
return (error);
if (!mpsafe)
OpenPOWER on IntegriCloud