From owner-svn-src-head@freebsd.org Fri Mar 31 14:17:16 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27E52D276F8; Fri, 31 Mar 2017 14:17:16 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D1B90F3; Fri, 31 Mar 2017 14:17:15 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2VEHEpI086737; Fri, 31 Mar 2017 14:17:14 GMT (envelope-from rwatson@FreeBSD.org) Received: (from rwatson@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2VEHE5o086736; Fri, 31 Mar 2017 14:17:14 GMT (envelope-from rwatson@FreeBSD.org) Message-Id: <201703311417.v2VEHE5o086736@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: rwatson set sender to rwatson@FreeBSD.org using -f From: Robert Watson Date: Fri, 31 Mar 2017 14:17:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r316334 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Mar 2017 14:17:16 -0000 Author: rwatson Date: Fri Mar 31 14:17:14 2017 New Revision: 316334 URL: https://svnweb.freebsd.org/changeset/base/316334 Log: Audit arguments to posix_fallocate(2) and posix_fadvise(2) system calls. As posix_fadvise() does not lock the vnode argument, don't capture detailed vnode information for the time being. Obtained from: TrustedBSD Project MFC after: 3 weeks Sponsored by: DARPA, AFRL Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Fri Mar 31 14:13:13 2017 (r316333) +++ head/sys/kern/vfs_syscalls.c Fri Mar 31 14:17:14 2017 (r316334) @@ -4452,15 +4452,21 @@ kern_posix_fallocate(struct thread *td, cap_rights_t rights; off_t olen, ooffset; int error; +#ifdef AUDIT + int audited_vnode1 = 0; +#endif + AUDIT_ARG_FD(fd); if (offset < 0 || len <= 0) return (EINVAL); /* Check for wrap. */ if (offset > OFF_MAX - len) return (EFBIG); + AUDIT_ARG_FD(fd); error = fget(td, fd, cap_rights_init(&rights, CAP_WRITE), &fp); if (error != 0) return (error); + AUDIT_ARG_FILE(td->td_proc, fp); if ((fp->f_ops->fo_flags & DFLAG_SEEKABLE) == 0) { error = ESPIPE; goto out; @@ -4494,6 +4500,12 @@ kern_posix_fallocate(struct thread *td, vn_finished_write(mp); break; } +#ifdef AUDIT + if (!audited_vnode1) { + AUDIT_ARG_VNODE1(vp); + audited_vnode1 = 1; + } +#endif #ifdef MAC error = mac_vnode_check_write(td->td_ucred, fp->f_cred, vp); if (error == 0) @@ -4544,6 +4556,7 @@ kern_posix_fadvise(struct thread *td, in if (offset < 0 || len < 0 || offset > OFF_MAX - len) return (EINVAL); + AUDIT_ARG_VALUE(advice); switch (advice) { case POSIX_FADV_SEQUENTIAL: case POSIX_FADV_RANDOM: @@ -4559,9 +4572,11 @@ kern_posix_fadvise(struct thread *td, in return (EINVAL); } /* XXX: CAP_POSIX_FADVISE? */ + AUDIT_ARG_FD(fd); error = fget(td, fd, cap_rights_init(&rights), &fp); if (error != 0) goto out; + AUDIT_ARG_FILE(td->td_proc, fp); if ((fp->f_ops->fo_flags & DFLAG_SEEKABLE) == 0) { error = ESPIPE; goto out;