From owner-svn-src-head@freebsd.org Wed Oct 2 02:37:35 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CC29AFEE8A; Wed, 2 Oct 2019 02:37:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46jgKC4c0Lz3C5J; Wed, 2 Oct 2019 02:37:35 +0000 (UTC) (envelope-from kevans@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 63D5A24D61; Wed, 2 Oct 2019 02:37:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x922bZ1u060436; Wed, 2 Oct 2019 02:37:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x922bZb2060434; Wed, 2 Oct 2019 02:37:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910020237.x922bZb2060434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Wed, 2 Oct 2019 02:37:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352952 - in head: sys/kern tests/sys/posixshm X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in head: sys/kern tests/sys/posixshm X-SVN-Commit-Revision: 352952 X-SVN-Commit-Repository: base 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.29 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: Wed, 02 Oct 2019 02:37:35 -0000 Author: kevans Date: Wed Oct 2 02:37:34 2019 New Revision: 352952 URL: https://svnweb.freebsd.org/changeset/base/352952 Log: shm_open2(2): completely unbreak kern_shm_open2(), since conception, completely fails to pass the mode along to kern_shm_open(). This breaks most uses of it. Add tests alongside this that actually check the mode of the returned files. PR: 240934 [pulseaudio breakage] Reported by: ler, Andrew Gierth [postgres breakage] Diagnosed by: Andrew Gierth (great catch) Tested by: ler, tmunro Pointy hat to: kevans Modified: head/sys/kern/uipc_shm.c head/tests/sys/posixshm/posixshm_test.c Modified: head/sys/kern/uipc_shm.c ============================================================================== --- head/sys/kern/uipc_shm.c Wed Oct 2 01:27:50 2019 (r352951) +++ head/sys/kern/uipc_shm.c Wed Oct 2 02:37:34 2019 (r352952) @@ -1484,7 +1484,7 @@ kern_shm_open2(struct thread *td, const char *path, in initial_seals = F_SEAL_SEAL; if ((shmflags & SHM_ALLOW_SEALING) != 0) initial_seals &= ~F_SEAL_SEAL; - return (kern_shm_open(td, path, flags, 0, NULL, initial_seals)); + return (kern_shm_open(td, path, flags, mode, NULL, initial_seals)); } /* Modified: head/tests/sys/posixshm/posixshm_test.c ============================================================================== --- head/tests/sys/posixshm/posixshm_test.c Wed Oct 2 01:27:50 2019 (r352951) +++ head/tests/sys/posixshm/posixshm_test.c Wed Oct 2 02:37:34 2019 (r352952) @@ -881,7 +881,41 @@ ATF_TC_BODY(cloexec, tc) close(fd); } +ATF_TC_WITHOUT_HEAD(mode); +ATF_TC_BODY(mode, tc) +{ + struct stat st; + int fd; + mode_t restore_mask; + gen_test_path(); + + /* Remove inhibitions from umask */ + restore_mask = umask(0); + fd = shm_open(test_path, O_CREAT | O_RDWR, 0600); + ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno); + ATF_REQUIRE(fstat(fd, &st) == 0); + ATF_REQUIRE((st.st_mode & ACCESSPERMS) == 0600); + close(fd); + ATF_REQUIRE(shm_unlink(test_path) == 0); + + fd = shm_open(test_path, O_CREAT | O_RDWR, 0660); + ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno); + ATF_REQUIRE(fstat(fd, &st) == 0); + ATF_REQUIRE((st.st_mode & ACCESSPERMS) == 0660); + close(fd); + ATF_REQUIRE(shm_unlink(test_path) == 0); + + fd = shm_open(test_path, O_CREAT | O_RDWR, 0666); + ATF_REQUIRE_MSG(fd >= 0, "shm_open failed; errno=%d", errno); + ATF_REQUIRE(fstat(fd, &st) == 0); + ATF_REQUIRE((st.st_mode & ACCESSPERMS) == 0666); + close(fd); + ATF_REQUIRE(shm_unlink(test_path) == 0); + + umask(restore_mask); +} + ATF_TP_ADD_TCS(tp) { @@ -914,6 +948,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, unlink_path_too_long); ATF_TP_ADD_TC(tp, object_resize); ATF_TP_ADD_TC(tp, cloexec); + ATF_TP_ADD_TC(tp, mode); return (atf_no_error()); }