diff mbox series

[2/2] sysdeps: tst-bz21269: handle ENOSYS & skip appropriately

Message ID 20230805000005.2427213-2-sam@gentoo.org
State New
Headers show
Series [1/2] sysdeps: tst-bz21269: fix test parameter | expand

Commit Message

Sam James Aug. 5, 2023, midnight UTC
SYS_modify_ldt requires CONFIG_MODIFY_LDT_SYSCALL to be set in the kernel, which
some distributions may disable for hardening. Check if that's the case (unset)
and mark the test as UNSUPPORTED if so.

Signed-off-by: Sam James <sam@gentoo.org>
---
 sysdeps/unix/sysv/linux/i386/tst-bz21269.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Gabriel Ravier Aug. 5, 2023, 3:41 p.m. UTC | #1
On 8/5/23 02:00, Sam James via Libc-alpha wrote:
> SYS_modify_ldt requires CONFIG_MODIFY_LDT_SYSCALL to be set in the kernel, which
> some distributions may disable for hardening. Check if that's the case (unset)
> and mark the test as UNSUPPORTED if so.
>
> Signed-off-by: Sam James <sam@gentoo.org>
> ---
>   sysdeps/unix/sysv/linux/i386/tst-bz21269.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
> index f508ef8f16..345b4ebc45 100644
> --- a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
> +++ b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
> @@ -52,7 +52,16 @@ xset_thread_area (struct user_desc *u_info)
>   static void
>   xmodify_ldt (int func, const void *ptr, unsigned long bytecount)
>   {
> -  TEST_VERIFY_EXIT (syscall (SYS_modify_ldt, func, ptr, bytecount) == 0);
> +  long ret = syscall (SYS_modify_ldt, func, ptr, bytecount);
> +
> +  if (ret == -1)
> +    {
> +      if (errno == ENOSYS)
> +	FAIL_UNSUPPORTED ("modify_ldt not supported");
> +      FAIL_EXIT1 ("semget failed (errno=%d)", errno);
...How are semget and modify_ldt related here ?
> +    }
> +
> +  return 0;
>   }
>   
>   static int
Sam James Aug. 5, 2023, 3:53 p.m. UTC | #2
> On 5 Aug 2023, at 16:41, Gabriel Ravier <gabravier@gmail.com> wrote:
> 
> On 8/5/23 02:00, Sam James via Libc-alpha wrote:
>> SYS_modify_ldt requires CONFIG_MODIFY_LDT_SYSCALL to be set in the kernel, which
>> some distributions may disable for hardening. Check if that's the case (unset)
>> and mark the test as UNSUPPORTED if so.
>> 
>> Signed-off-by: Sam James <sam@gentoo.org>
>> ---
>>  sysdeps/unix/sysv/linux/i386/tst-bz21269.c | 11 ++++++++++-
>>  1 file changed, 10 insertions(+), 1 deletion(-)
>> 
>> diff --git a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
>> index f508ef8f16..345b4ebc45 100644
>> --- a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
>> +++ b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
>> @@ -52,7 +52,16 @@ xset_thread_area (struct user_desc *u_info)
>>  static void
>>  xmodify_ldt (int func, const void *ptr, unsigned long bytecount)
>>  {
>> -  TEST_VERIFY_EXIT (syscall (SYS_modify_ldt, func, ptr, bytecount) == 0);
>> +  long ret = syscall (SYS_modify_ldt, func, ptr, bytecount);
>> +
>> +  if (ret == -1)
>> +    {
>> +      if (errno == ENOSYS)
>> +    FAIL_UNSUPPORTED ("modify_ldt not supported");
>> +      FAIL_EXIT1 ("semget failed (errno=%d)", errno);
> ...How are semget and modify_ldt related here ?
>> +    }
>> +

Copy-paste error last night I didn't clean up ;)

Thanks!

>> +  return 0;
>>  }
>>    static int
> 
>
diff mbox series

Patch

diff --git a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
index f508ef8f16..345b4ebc45 100644
--- a/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
+++ b/sysdeps/unix/sysv/linux/i386/tst-bz21269.c
@@ -52,7 +52,16 @@  xset_thread_area (struct user_desc *u_info)
 static void
 xmodify_ldt (int func, const void *ptr, unsigned long bytecount)
 {
-  TEST_VERIFY_EXIT (syscall (SYS_modify_ldt, func, ptr, bytecount) == 0);
+  long ret = syscall (SYS_modify_ldt, func, ptr, bytecount);
+
+  if (ret == -1)
+    {
+      if (errno == ENOSYS)
+	FAIL_UNSUPPORTED ("modify_ldt not supported");
+      FAIL_EXIT1 ("semget failed (errno=%d)", errno);
+    }
+
+  return 0;
 }
 
 static int