public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683)
@ 2019-10-17 13:57 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2019-10-17 13:57 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=aee81293c19b1345cc61a74eaec92833dc87ddd1

commit aee81293c19b1345cc61a74eaec92833dc87ddd1
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sat May 9 14:20:26 2015 -0300

    nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683)
    
    This patches adds the x32 modification required for the BZ#12683.
    It basically adjust the syscall size used to pass the arguments to
    the syscall cancel wrappers by zero extending pointers type while
    preserting values for default types (such as off_t).
    
    Checked on x86_64-linux-gnu-x32.

Diff:
---
 include/libc-pointer-arith.h                | 16 +++++++++++-----
 sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 13 +++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h
index b32df71..0e5bb83 100644
--- a/include/libc-pointer-arith.h
+++ b/include/libc-pointer-arith.h
@@ -25,17 +25,23 @@
 # define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5)
 
 /* intptr_t if P is true, or T if P is false.  */
-# define __integer_if_pointer_type_sub(T, P) \
+# define __integer_if_pointer_type_sub(T, P, INTTYPE) \
   __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \
-		  : (__typeof__ (0 ? (intptr_t *) 0 : (void *) (!(P)))) 0))
+		  : (__typeof__ (0 ? (INTTYPE *) 0 : (void *) (!(P)))) 0))
 
 /* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise.  */
-# define __integer_if_pointer_type(expr) \
+# define __integer_if_pointer_type(expr, inttype) \
   __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \
-				__pointer_type (__typeof__ (expr)))
+				__pointer_type (__typeof__ (expr)), \
+				inttype)
 
 /* Cast an integer or a pointer VAL to integer with proper type.  */
-# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
+# define cast_to_integer(val) \
+  ((__integer_if_pointer_type (val, intptr_t)) (val))
+
+/* Cast an integer or a pointer VAL to unsigned integer with proper type.  */
+# define cast_to_uinteger(val) \
+  ((__integer_if_pointer_type (val, uintptr_t)) (val))
 
 /* Align a value by rounding down to closest size.
    e.g. Using size of 4096, we get this behavior:
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
index 60a144a..568ca1c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
@@ -18,6 +18,19 @@
 #ifndef _LINUX_X32_SYSDEP_H
 #define _LINUX_X32_SYSDEP_H 1
 
+#ifndef __ASSEMBLER__
+#include <libc-internal.h>
+#include <libc-diag.h>
+
+typedef long long int __syscall_arg_t;
+
+/* Syscall arguments for x32 follows x86_64 size, however pointers are 32
+   bits in size.  The idea is to zero extend pointer types while cast to
+   signed 64 bit default arguments.  */
+#define __SSC(__x) ((__syscall_arg_t) cast_to_uinteger (__x))
+
+#endif
+
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/x86_64/sysdep.h>
 #include <sysdeps/x86_64/x32/sysdep.h>


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

* [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation [BZ#12683]
@ 2020-04-07 14:04 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2020-04-07 14:04 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f43cde177323f0bdc71ec9ac78f1985984284af0

commit f43cde177323f0bdc71ec9ac78f1985984284af0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sat May 9 14:20:26 2015 -0300

    nptl: x32: Fix Race conditions in pthread cancellation [BZ#12683]
    
    This patches adds the x32 modification required for the BZ#12683.
    It follows the x86_64-x32 ABI and pointers are zero-extended.
    
    Checked on x86_64-linux-gnu-x32.

Diff:
---
 sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h | 36 ++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h b/sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h
new file mode 100644
index 0000000000..fd9f14d566
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h
@@ -0,0 +1,36 @@
+/* Types and macros used for syscall issuing.  x86_64/x32 version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SYSCALL_TYPES_H
+#define _SYSCALL_TYPES_H
+
+#include <libc-diag.h>
+
+typedef long long int __syscall_arg_t;
+
+/* Syscall arguments for x32 follows x86_64 ABI, however pointers are 32 bits
+   should be zero extended.  */
+#define __SSC(__x)						\
+  ({								\
+    __syscall_arg_t __arg = sizeof (1 ? (__x) : 0ULL) < 8	\
+      ? (unsigned long int) (uintptr_t)(__x) 			\
+      : (__syscall_arg_t) (__typeof__ ((__x) - (__x))) (__x);	\
+    __arg;							\
+  })
+
+#endif


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

* [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation [BZ#12683]
@ 2020-04-03 20:23 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2020-04-03 20:23 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4123335c03ba9b70d94e1bad8d006473f9a80d5c

commit 4123335c03ba9b70d94e1bad8d006473f9a80d5c
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sat May 9 14:20:26 2015 -0300

    nptl: x32: Fix Race conditions in pthread cancellation [BZ#12683]
    
    This patches adds the x32 modification required for the BZ#12683.
    It follows the x86_64-x32 ABI and pointers are zero-extended.
    However, compiler may not see such cases and accuse a cast from pointer
    to integer of different size and for such cases the warning is
    explict disabled.
    
    Checked on x86_64-linux-gnu-x32.

Diff:
---
 sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h | 40 ++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h b/sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h
new file mode 100644
index 0000000000..25b10a0b28
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscall_types.h
@@ -0,0 +1,40 @@
+/* Types and macros used for syscall issuing.  x86_64/x32 version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#ifndef _SYSCALL_TYPES_H
+#define _SYSCALL_TYPES_H
+
+#include <libc-diag.h>
+
+typedef long long int __syscall_arg_t;
+
+/* Syscall arguments for x32 follows x86_64 ABI, however pointers are 32 bits
+   should be zero extended.  However compiler may not see such cases and
+   accuse a cast from pointer to integer of different size.  */
+#define __SSC(__x)						\
+  ({								\
+    DIAG_PUSH_NEEDS_COMMENT;					\
+    DIAG_IGNORE_NEEDS_COMMENT (5, "-Wpointer-to-int-cast");	\
+    __syscall_arg_t __arg = sizeof (1 ? (__x) : 0ULL) < 8	\
+			    ? (unsigned long int) (__x) 	\
+			    : (long long int) ((__x));		\
+    DIAG_POP_NEEDS_COMMENT;					\
+    __arg;							\
+  })
+
+#endif


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

* [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683)
@ 2019-08-19 20:35 Adhemerval Zanella
  0 siblings, 0 replies; 4+ messages in thread
From: Adhemerval Zanella @ 2019-08-19 20:35 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b8ae61296d9d48e000adbe5e1b654dd2e3f2fb16

commit b8ae61296d9d48e000adbe5e1b654dd2e3f2fb16
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Sat May 9 14:20:26 2015 -0300

    nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683)
    
    This patches adds the x32 modification required for the BZ#12683.
    It basically adjust the syscall size used to pass the arguments to
    the syscall cancel wrappers by zero extending pointers type while
    preserting values for default types (such as off_t).
    
    Checked on x86_64-linux-gnu-x32.
    
    	[BZ #12683]
    	* sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h (__syscall_arg_t):
    	Define type for x32.
    	(__SSC): Add platform specific macro.
    	* include/libc-pointer-arith.h (__integer_if_pointer_type_sub,
    	__integer_if_pointer_type, cast_to_integer): Parametrize integer type
    	cast.
    	(cast_to_uinteger): New macro.

Diff:
---
 include/libc-pointer-arith.h                | 16 +++++++++++-----
 sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h | 13 +++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h
index c5390a9..eaa57f0 100644
--- a/include/libc-pointer-arith.h
+++ b/include/libc-pointer-arith.h
@@ -25,17 +25,23 @@
 # define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5)
 
 /* intptr_t if P is true, or T if P is false.  */
-# define __integer_if_pointer_type_sub(T, P) \
+# define __integer_if_pointer_type_sub(T, P, INTTYPE) \
   __typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \
-		  : (__typeof__ (0 ? (intptr_t *) 0 : (void *) (!(P)))) 0))
+		  : (__typeof__ (0 ? (INTTYPE *) 0 : (void *) (!(P)))) 0))
 
 /* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise.  */
-# define __integer_if_pointer_type(expr) \
+# define __integer_if_pointer_type(expr, inttype) \
   __integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \
-				__pointer_type (__typeof__ (expr)))
+				__pointer_type (__typeof__ (expr)), \
+				inttype)
 
 /* Cast an integer or a pointer VAL to integer with proper type.  */
-# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
+# define cast_to_integer(val) \
+  ((__integer_if_pointer_type (val, intptr_t)) (val))
+
+/* Cast an integer or a pointer VAL to unsigned integer with proper type.  */
+# define cast_to_uinteger(val) \
+  ((__integer_if_pointer_type (val, uintptr_t)) (val))
 
 /* Align a value by rounding down to closest size.
    e.g. Using size of 4096, we get this behavior:
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
index 1401f2d..1b7e09e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/sysdep.h
@@ -18,6 +18,19 @@
 #ifndef _LINUX_X32_SYSDEP_H
 #define _LINUX_X32_SYSDEP_H 1
 
+#ifndef __ASSEMBLER__
+#include <libc-internal.h>
+#include <libc-diag.h>
+
+typedef long long int __syscall_arg_t;
+
+/* Syscall arguments for x32 follows x86_64 size, however pointers are 32
+   bits in size.  The idea is to zero extend pointer types while cast to
+   signed 64 bit default arguments.  */
+#define __SSC(__x) ((__syscall_arg_t) cast_to_uinteger (__x))
+
+#endif
+
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/x86_64/sysdep.h>
 #include <sysdeps/x86_64/x32/sysdep.h>


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

end of thread, other threads:[~2020-04-07 14:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-17 13:57 [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2020-04-07 14:04 [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation [BZ#12683] Adhemerval Zanella
2020-04-03 20:23 Adhemerval Zanella
2019-08-19 20:35 [glibc/azanella/bz12683] nptl: x32: Fix Race conditions in pthread cancellation (BZ#12683) Adhemerval Zanella

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).