From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id E023F3858416; Wed, 12 Jan 2022 09:11:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E023F3858416 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin/cygwin-3_3-branch] Cygwin: ACLs: ignore *_INHERIT flags in file ACLs X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/cygwin-3_3-branch X-Git-Oldrev: 987689a3ba8e822dacbf0bee2fdbccc3b4ae7af3 X-Git-Newrev: 2537b3134b3239f5e7ebb45b15a684255e2c8e49 Message-Id: <20220112091151.E023F3858416@sourceware.org> Date: Wed, 12 Jan 2022 09:11:51 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 09:11:52 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2537b3134b3239f5e7ebb45b15a684255e2c8e49 commit 2537b3134b3239f5e7ebb45b15a684255e2c8e49 Author: Corinna Vinschen Date: Tue Jan 11 22:20:47 2022 +0100 Cygwin: ACLs: ignore *_INHERIT flags in file ACLs get_posix_access() creates DEF_*_OBJ aclent_t entries from Windows ACEs with INHERIT flags set, independent of the file type. These flags only make sense on directory objects, but certain Windows functions don't check the file type and allow INHERIT ACE flags even on non-directories. As a fix, make sure to ignore the INHERIT flags on non-directory ACLs and don't propagate the matching DEF_*_OBJ aclent_t entries to callers. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/3.3.4 | 3 +++ winsup/cygwin/sec_acl.cc | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/release/3.3.4 b/winsup/cygwin/release/3.3.4 index 048426942..1982df0cf 100644 --- a/winsup/cygwin/release/3.3.4 +++ b/winsup/cygwin/release/3.3.4 @@ -17,3 +17,6 @@ Bug Fixes - Avoid a crash when NtQueryInformationProcess returns invalid handle data. Addresses: https://cygwin.com/pipermail/cygwin-patches/2021q4/011611.html + +- Ignore INHERIT ACEs when reading the DACL of non-directory files. + Addresses: https://cygwin.com/pipermail/cygwin/2022-January/250363.html diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index 90969b639..98d2391b1 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -811,7 +811,8 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, class_perm = lacl[pos].a_perm; } } - if (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) + if (S_ISDIR (attr) + && (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) != 0) { if ((pos = searchace (lacl, MAX_ACL_ENTRIES, DEF_CLASS_OBJ)) >= 0) @@ -952,7 +953,8 @@ get_posix_access (PSECURITY_DESCRIPTOR psd, standard_ACEs_only = false; } } - if ((ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT)) + if (S_ISDIR (attr) + && (ace->Header.AceFlags & SUB_CONTAINERS_AND_OBJECTS_INHERIT) != 0) { if (type == USER_OBJ) { @@ -1197,10 +1199,11 @@ int getacl (HANDLE handle, path_conv &pc, int nentries, aclent_t *aclbufp) { security_descriptor sd; + mode_t attr = pc.isdir () ? S_IFDIR : 0; if (get_file_sd (handle, pc, sd, false)) return -1; - int pos = get_posix_access (sd, NULL, NULL, NULL, aclbufp, nentries); + int pos = get_posix_access (sd, &attr, NULL, NULL, aclbufp, nentries); syscall_printf ("%R = getacl(%S)", pos, pc.get_nt_native_path ()); return pos; }