diff mbox series

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

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

Commit Message

Sam James Aug. 16, 2023, 6:29 a.m. 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>
---
Fix the FAIL_EXIT1 error.

 sysdeps/unix/sysv/linux/i386/tst-bz21269.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Sam James Aug. 16, 2023, 8:13 p.m. UTC | #1
DJ Delorie <dj@redhat.com> writes:

> Sam James via Libc-alpha <libc-alpha@sourceware.org> writes:
>> 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.
>
> LGTM
> Reviewed-by: DJ Delorie <dj@redhat.com>


Thanks DJ! Pushed.
Andreas Schwab Aug. 17, 2023, 7:07 a.m. UTC | #2
../sysdeps/unix/sysv/linux/i386/tst-bz21269.c: In function 'xmodify_ldt':
../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:64:10: error: 'return' with a value, in function returning void [-Werror=return-type]
   64 |   return 0;
      |          ^
../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:53:1: note: declared here
   53 | xmodify_ldt (int func, const void *ptr, unsigned long bytecount)
      | ^~~~~~~~~~~
cc1: all warnings being treated as errors
Sam James Aug. 17, 2023, 8:31 a.m. UTC | #3
Andreas Schwab <schwab@suse.de> writes:

> ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c: In function 'xmodify_ldt':
> ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:64:10: error: 'return' with a value, in function returning void [-Werror=return-type]
>    64 |   return 0;
>       |          ^
> ../sysdeps/unix/sysv/linux/i386/tst-bz21269.c:53:1: note: declared here
>    53 | xmodify_ldt (int func, const void *ptr, unsigned long bytecount)
>       | ^~~~~~~~~~~
> cc1: all warnings being treated as errors

Fixed, thanks.
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..28f5359bea 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 ("modify_ldt failed (errno=%d)", errno);
+    }
+
+  return 0;
 }
 
 static int