diff mbox series

[v3] Make any 32-bit time based syscalls unavailable for TIMESIZE==64

Message ID 20200331214717.23902-1-vgupta@synopsys.com
State New
Headers show
Series [v3] Make any 32-bit time based syscalls unavailable for TIMESIZE==64 | expand

Commit Message

Vineet Gupta March 31, 2020, 9:47 p.m. UTC
From: Vineet Gupta via Libc-alpha <libc-alpha@sourceware.org>

An older asm-generic syscall ABI may have kernel provide 32-bit
time syscalls, so undef them to not mix 32/64 in 64-bit time regime.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
Changes since v2
  - Made x32 safe

Changes since v1
  - don't redirect these to 64-bit variants
---
 sysdeps/unix/sysv/linux/generic/sysdep.h | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

Comments

Vineet Gupta April 6, 2020, 6:54 p.m. UTC | #1
On 3/31/20 2:47 PM, Vineet Gupta via Libc-alpha wrote:
> From: Vineet Gupta via Libc-alpha <libc-alpha@sourceware.org>
> 
> An older asm-generic syscall ABI may have kernel provide 32-bit
> time syscalls, so undef them to not mix 32/64 in 64-bit time regime.
> 
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

ping !

> ---
> Changes since v2
>   - Made x32 safe
> 
> Changes since v1
>   - don't redirect these to 64-bit variants
> ---
>  sysdeps/unix/sysv/linux/generic/sysdep.h | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
> index 40b4b955ca1b..b83e17e1c9d1 100644
> --- a/sysdeps/unix/sysv/linux/generic/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
> @@ -17,6 +17,7 @@
>     <https://www.gnu.org/licenses/>.  */
>  
>  #include <bits/wordsize.h>
> +#include <bits/timesize.h>
>  #include <kernel-features.h>
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
> @@ -25,3 +26,26 @@
>  #ifdef __NR_llseek
>  # define __NR__llseek __NR_llseek
>  #endif
> +
> +#if (__TIMESIZE == 64 && __WORDSIZE == 32 \
> +     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
> +
> +/* Don't provide 32-bit time syscalls even if the kernel ABI provides
> +   them (Older variants of asm-generic ABIs e.g. ARC).  */
> +
> +# undef __NR_futex
> +# undef __NR_rt_sigtimedwait
> +# undef __NR_ppoll
> +# undef __NR_utimensat
> +# undef __NR_pselect6
> +# undef __NR_recvmmsg
> +# undef __NR_semtimedop
> +# undef __NR_mq_timedreceive
> +# undef __NR_mq_timedsend
> +# undef __NR_clock_getres
> +# undef __NR_timerfd_settime
> +# undef __NR_timerfd_gettime
> +# undef __NR_sched_rr_get_interval
> +# undef __NR_clock_adjtime
> +
> +#endif
>
Vineet Gupta April 13, 2020, 9:12 p.m. UTC | #2
On 4/6/20 11:54 AM, Vineet Gupta wrote:
> On 3/31/20 2:47 PM, Vineet Gupta via Libc-alpha wrote:
>> From: Vineet Gupta via Libc-alpha <libc-alpha@sourceware.org>
>>
>> An older asm-generic syscall ABI may have kernel provide 32-bit
>> time syscalls, so undef them to not mix 32/64 in 64-bit time regime.
>>
>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
> 
> ping !

ping ^2 !


> 
>> ---
>> Changes since v2
>>   - Made x32 safe
>>
>> Changes since v1
>>   - don't redirect these to 64-bit variants
>> ---
>>  sysdeps/unix/sysv/linux/generic/sysdep.h | 24 ++++++++++++++++++++++++
>>  1 file changed, 24 insertions(+)
>>
>> diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
>> index 40b4b955ca1b..b83e17e1c9d1 100644
>> --- a/sysdeps/unix/sysv/linux/generic/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
>> @@ -17,6 +17,7 @@
>>     <https://www.gnu.org/licenses/>.  */
>>  
>>  #include <bits/wordsize.h>
>> +#include <bits/timesize.h>
>>  #include <kernel-features.h>
>>  #include <sysdeps/unix/sysdep.h>
>>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>> @@ -25,3 +26,26 @@
>>  #ifdef __NR_llseek
>>  # define __NR__llseek __NR_llseek
>>  #endif
>> +
>> +#if (__TIMESIZE == 64 && __WORDSIZE == 32 \
>> +     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
>> +
>> +/* Don't provide 32-bit time syscalls even if the kernel ABI provides
>> +   them (Older variants of asm-generic ABIs e.g. ARC).  */
>> +
>> +# undef __NR_futex
>> +# undef __NR_rt_sigtimedwait
>> +# undef __NR_ppoll
>> +# undef __NR_utimensat
>> +# undef __NR_pselect6
>> +# undef __NR_recvmmsg
>> +# undef __NR_semtimedop
>> +# undef __NR_mq_timedreceive
>> +# undef __NR_mq_timedsend
>> +# undef __NR_clock_getres
>> +# undef __NR_timerfd_settime
>> +# undef __NR_timerfd_gettime
>> +# undef __NR_sched_rr_get_interval
>> +# undef __NR_clock_adjtime
>> +
>> +#endif
>>
Vineet Gupta April 18, 2020, 12:28 a.m. UTC | #3
On 4/13/20 2:12 PM, Vineet Gupta via Libc-alpha wrote:
> On 4/6/20 11:54 AM, Vineet Gupta wrote:
>> On 3/31/20 2:47 PM, Vineet Gupta via Libc-alpha wrote:
>>> From: Vineet Gupta via Libc-alpha <libc-alpha@sourceware.org>
>>>
>>> An older asm-generic syscall ABI may have kernel provide 32-bit
>>> time syscalls, so undef them to not mix 32/64 in 64-bit time regime.
>>>
>>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
>>
>> ping !
> 
> ping ^2 !

If this is not suitable for common code, I'd still like to add this as part of ARC
port to safe guard against future snafus.

>>> ---
>>> Changes since v2
>>>   - Made x32 safe
>>>
>>> Changes since v1
>>>   - don't redirect these to 64-bit variants
>>> ---
>>>  sysdeps/unix/sysv/linux/generic/sysdep.h | 24 ++++++++++++++++++++++++
>>>  1 file changed, 24 insertions(+)
>>>
>>> diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
>>> index 40b4b955ca1b..b83e17e1c9d1 100644
>>> --- a/sysdeps/unix/sysv/linux/generic/sysdep.h
>>> +++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
>>> @@ -17,6 +17,7 @@
>>>     <https://www.gnu.org/licenses/>.  */
>>>  
>>>  #include <bits/wordsize.h>
>>> +#include <bits/timesize.h>
>>>  #include <kernel-features.h>
>>>  #include <sysdeps/unix/sysdep.h>
>>>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>>> @@ -25,3 +26,26 @@
>>>  #ifdef __NR_llseek
>>>  # define __NR__llseek __NR_llseek
>>>  #endif
>>> +
>>> +#if (__TIMESIZE == 64 && __WORDSIZE == 32 \
>>> +     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
>>> +
>>> +/* Don't provide 32-bit time syscalls even if the kernel ABI provides
>>> +   them (Older variants of asm-generic ABIs e.g. ARC).  */
>>> +
>>> +# undef __NR_futex
>>> +# undef __NR_rt_sigtimedwait
>>> +# undef __NR_ppoll
>>> +# undef __NR_utimensat
>>> +# undef __NR_pselect6
>>> +# undef __NR_recvmmsg
>>> +# undef __NR_semtimedop
>>> +# undef __NR_mq_timedreceive
>>> +# undef __NR_mq_timedsend
>>> +# undef __NR_clock_getres
>>> +# undef __NR_timerfd_settime
>>> +# undef __NR_timerfd_gettime
>>> +# undef __NR_sched_rr_get_interval
>>> +# undef __NR_clock_adjtime
>>> +
>>> +#endif
>>>
>
Florian Weimer April 18, 2020, 4:50 p.m. UTC | #4
* Vineet Gupta via Libc-alpha:

> On 4/13/20 2:12 PM, Vineet Gupta via Libc-alpha wrote:
>> On 4/6/20 11:54 AM, Vineet Gupta wrote:
>>> On 3/31/20 2:47 PM, Vineet Gupta via Libc-alpha wrote:
>>>> From: Vineet Gupta via Libc-alpha <libc-alpha@sourceware.org>
>>>>
>>>> An older asm-generic syscall ABI may have kernel provide 32-bit
>>>> time syscalls, so undef them to not mix 32/64 in 64-bit time regime.
>>>>
>>>> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
>>>
>>> ping !
>> 
>> ping ^2 !
>
> If this is not suitable for common code, I'd still like to add this
> as part of ARC port to safe guard against future snafus.

Have you tried to add the #undefs to fixup-asm-unistd.h?
See sysdeps/unix/sysv/linux/arm/fixup-asm-unistd.h for an example.

I have not tried if #undefs work there, but they should.  If not, we
can fix that.
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/generic/sysdep.h b/sysdeps/unix/sysv/linux/generic/sysdep.h
index 40b4b955ca1b..b83e17e1c9d1 100644
--- a/sysdeps/unix/sysv/linux/generic/sysdep.h
+++ b/sysdeps/unix/sysv/linux/generic/sysdep.h
@@ -17,6 +17,7 @@ 
    <https://www.gnu.org/licenses/>.  */
 
 #include <bits/wordsize.h>
+#include <bits/timesize.h>
 #include <kernel-features.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
@@ -25,3 +26,26 @@ 
 #ifdef __NR_llseek
 # define __NR__llseek __NR_llseek
 #endif
+
+#if (__TIMESIZE == 64 && __WORDSIZE == 32 \
+     && (!defined __SYSCALL_WORDSIZE || __SYSCALL_WORDSIZE == 32))
+
+/* Don't provide 32-bit time syscalls even if the kernel ABI provides
+   them (Older variants of asm-generic ABIs e.g. ARC).  */
+
+# undef __NR_futex
+# undef __NR_rt_sigtimedwait
+# undef __NR_ppoll
+# undef __NR_utimensat
+# undef __NR_pselect6
+# undef __NR_recvmmsg
+# undef __NR_semtimedop
+# undef __NR_mq_timedreceive
+# undef __NR_mq_timedsend
+# undef __NR_clock_getres
+# undef __NR_timerfd_settime
+# undef __NR_timerfd_gettime
+# undef __NR_sched_rr_get_interval
+# undef __NR_clock_adjtime
+
+#endif