public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Fix incorrect sign-extension of pointer in 32-bit acl __to_entry
@ 2020-07-09 19:30 David Allsopp
  2020-07-10  8:32 ` Corinna Vinschen
  0 siblings, 1 reply; 6+ messages in thread
From: David Allsopp @ 2020-07-09 19:30 UTC (permalink / raw)
  To: cygwin-patches

[-- Attachment #1: Type: text/plain, Size: 298 bytes --]

I have some code where the acl_t returned by get_file_acl is allocated at
0x80038248. As a result the acl_entry_t generated by acl_get_entry has an
"index" of -1, since the pointer was sign-extended to 64-bits.

My fix is trivial and simply casts the pointer to uintptr_t first.

All best,


David

[-- Attachment #2: 0001-Fix-invalid-acl_entry_t-on-32-bit-Cygwin.patch --]
[-- Type: application/octet-stream, Size: 1386 bytes --]

From c9af9cc1ecba0c716577f7fe6b380437c817de2c Mon Sep 17 00:00:00 2001
From: David Allsopp <david.allsopp@metastack.com>
Date: Thu, 9 Jul 2020 20:17:03 +0100
Subject: [PATCH] Fix invalid acl_entry_t on 32-bit Cygwin

If the acl_t struct was at or above 0x80000000 then the pointer was
sign-extended to 0xffff_ffff_8000_0000 and so the index was lost.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
---
 winsup/cygwin/release/3.1.7  | 4 ++++
 winsup/cygwin/sec_posixacl.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 winsup/cygwin/release/3.1.7

diff --git a/winsup/cygwin/release/3.1.7 b/winsup/cygwin/release/3.1.7
new file mode 100644
index 000000000..6ce316fc4
--- /dev/null
+++ b/winsup/cygwin/release/3.1.7
@@ -0,0 +1,4 @@
+Bug Fixes:
+----------
+
+- Fix acl_get_* functions in 32-bit Cygwin (pointer sign extension)
diff --git a/winsup/cygwin/sec_posixacl.h b/winsup/cygwin/sec_posixacl.h
index a3790a52b..0f9e7bde3 100644
--- a/winsup/cygwin/sec_posixacl.h
+++ b/winsup/cygwin/sec_posixacl.h
@@ -34,7 +34,7 @@ struct __acl_t
 inline acl_entry_t
 __to_entry (acl_t acl, uint16_t idx)
 {
-  return ((uint64_t) idx << 48) | (uint64_t) acl;
+  return ((uint64_t) idx << 48) | (uint64_t) ((uintptr_t) acl);
 }
 #define __to_permset(a,i)	((acl_permset_t)__to_entry((a),(i)))
 
-- 
2.19.2.windows.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-13  7:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 19:30 [PATCH] Fix incorrect sign-extension of pointer in 32-bit acl __to_entry David Allsopp
2020-07-10  8:32 ` Corinna Vinschen
2020-07-10 15:22   ` David Allsopp
2020-07-10 15:58     ` Corinna Vinschen
2020-07-10 18:31       ` David Allsopp
2020-07-13  7:18         ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).