public inbox for [email protected]
 help / color / mirror / Atom feed
From: Ammar Faizi <[email protected]>
To: Jens Axboe <[email protected]>
Cc: Ammar Faizi <[email protected]>,
	Pavel Begunkov <[email protected]>,
	io-uring Mailing List <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH liburing v1 6/6] test/double-poll-crash: Skip this test if the `mmap()` fails
Date: Sat, 23 Apr 2022 03:35:42 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

From: Ammar Faizi <[email protected]>

This test is very prone to hiting a SIGSEGV signal due to missing error
handling on mmap() calls. This especially often happens when executing
`runtests-parallel`. Let's just skip this test if those calls fail
instead of having a random segfault with no clear resolution.

Signed-off-by: Ammar Faizi <[email protected]>
---
 test/double-poll-crash.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/test/double-poll-crash.c b/test/double-poll-crash.c
index 5bfce09..231c7da 100644
--- a/test/double-poll-crash.c
+++ b/test/double-poll-crash.c
@@ -52,10 +52,14 @@ static long syz_io_uring_setup(volatile long a0, volatile long a1,
   *ring_ptr_out = mmap(vma1, ring_sz, PROT_READ | PROT_WRITE,
                        MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd_io_uring,
                        IORING_OFF_SQ_RING);
+  if (*ring_ptr_out == MAP_FAILED)
+    exit(0);
   uint32_t sqes_sz = setup_params->sq_entries * SIZEOF_IO_URING_SQE;
   *sqes_ptr_out =
       mmap(vma2, sqes_sz, PROT_READ | PROT_WRITE,
            MAP_SHARED | MAP_POPULATE | MAP_FIXED, fd_io_uring, IORING_OFF_SQES);
+  if (*sqes_ptr_out == MAP_FAILED)
+    exit(0);
   return fd_io_uring;
 }
 
@@ -108,6 +112,7 @@ uint64_t r[4] = {0xffffffffffffffff, 0x0, 0x0, 0xffffffffffffffff};
 
 int main(int argc, char *argv[])
 {
+  void *mmap_ret;
 #if !defined(__i386) && !defined(__x86_64__)
   return 0;
 #endif
@@ -115,8 +120,12 @@ int main(int argc, char *argv[])
   if (argc > 1)
     return 0;
 
-  mmap((void *)0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
-  mmap((void *)0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+  mmap_ret = mmap((void *)0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
+  if (mmap_ret == MAP_FAILED)
+    return 0;
+  mmap_ret = mmap((void *)0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+  if (mmap_ret == MAP_FAILED)
+    return 0;
   intptr_t res = 0;
   *(uint32_t*)0x20000484 = 0;
   *(uint32_t*)0x20000488 = 0;
-- 
Ammar Faizi


  parent reply	other threads:[~2022-04-22 21:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-22 20:35 [PATCH liburing v1 0/6] liburing fixes and cleanups Ammar Faizi
2022-04-22 20:35 ` [PATCH liburing v1 1/6] test/runtests-quiet.sh: Fixup redirection Ammar Faizi
2022-04-22 20:35 ` [PATCH liburing v1 2/6] Makefile: Make sure we build everything before runtests Ammar Faizi
2022-04-22 20:35 ` [PATCH liburing v1 3/6] test/Makefile: Remove `.PHONY` variable Ammar Faizi
2022-04-22 20:35 ` [PATCH liburing v1 4/6] test/Makefile: Sort the test file list alphabetically Ammar Faizi
2022-04-22 20:35 ` [PATCH liburing v1 5/6] .github/workflows: Run the nolibc build for x86 32-bit Ammar Faizi
2022-04-22 20:35 ` Ammar Faizi [this message]
2022-04-22 21:15 ` [PATCH liburing v1 0/6] liburing fixes and cleanups Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox