From owner-svn-src-head@FreeBSD.ORG Tue Sep 25 20:48:50 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4CC84106566C; Tue, 25 Sep 2012 20:48:50 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 390428FC0A; Tue, 25 Sep 2012 20:48:50 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8PKmoWp092944; Tue, 25 Sep 2012 20:48:50 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8PKmoUP092942; Tue, 25 Sep 2012 20:48:50 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201209252048.q8PKmoUP092942@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Tue, 25 Sep 2012 20:48:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240927 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Tue, 25 Sep 2012 20:48:50 -0000 Author: pjd Date: Tue Sep 25 20:48:49 2012 New Revision: 240927 URL: http://svn.freebsd.org/changeset/base/240927 Log: O_EXEC flag is not part of the O_ACCMODE mask, check it separately. If O_EXEC is provided don't require CAP_READ/CAP_WRITE, as O_EXEC is mutually exclusive to O_RDONLY/O_WRONLY/O_RDWR. Without this change CAP_FEXECVE capability right is not enforced. Sponsored by: FreeBSD Foundation MFC after: 3 days Modified: head/sys/kern/vfs_syscalls.c Modified: head/sys/kern/vfs_syscalls.c ============================================================================== --- head/sys/kern/vfs_syscalls.c Tue Sep 25 20:41:43 2012 (r240926) +++ head/sys/kern/vfs_syscalls.c Tue Sep 25 20:48:49 2012 (r240927) @@ -1006,22 +1006,20 @@ flags_to_rights(int flags) { cap_rights_t rights = 0; - switch ((flags & O_ACCMODE)) { - case O_RDONLY: - rights |= CAP_READ; - break; - - case O_RDWR: - rights |= CAP_READ; - /* fall through */ - - case O_WRONLY: - rights |= CAP_WRITE; - break; - - case O_EXEC: + if (flags & O_EXEC) { rights |= CAP_FEXECVE; - break; + } else { + switch ((flags & O_ACCMODE)) { + case O_RDONLY: + rights |= CAP_READ; + break; + case O_RDWR: + rights |= CAP_READ; + /* FALLTHROUGH */ + case O_WRONLY: + rights |= CAP_WRITE; + break; + } } if (flags & O_CREAT)