summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2022-02-21 05:07:46 -0700
committerJens Axboe <axboe@kernel.dk>2022-02-21 05:11:29 -0700
commitfd1d6cfafb4e9fb4d826175247527c7d1ca4ffc1 (patch)
tree4614b9c57d2b70953846f11e612ec1ff56f9bdc7
parent89b35ac142460401316979a36cde1d9bb5dcb4e1 (diff)
downloadliburing-fd1d6cfafb4e9fb4d826175247527c7d1ca4ffc1.tar.gz
liburing-fd1d6cfafb4e9fb4d826175247527c7d1ca4ffc1.tar.bz2
test/pollfree: use mmap(2) instead of a manual syscall
A lot of the syzkaller tests aren't really applicable on non-x86, or just simply assume x86. Replace the syscall(__NR_mmap, ...) usage with a regular mmap(2) call, and check for failure. Looks like some of these assume 4k pages as well, so just bail if we fail mapping. Fixes: https://github.com/axboe/liburing/issues/532 Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/pollfree.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/test/pollfree.c b/test/pollfree.c
index cdc7af0..4ef259c 100644
--- a/test/pollfree.c
+++ b/test/pollfree.c
@@ -391,12 +391,24 @@ void execute_call(int call)
int main(int argc, char *argv[])
{
+ void *ret;
+
+#if !defined(__i386) && !defined(__x86_64__)
+ return 0;
+#endif
+
if (argc > 1)
return 0;
- syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
- syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
- syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+ ret = mmap((void *)0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+ if (ret == MAP_FAILED)
+ return 0;
+ mmap((void *)0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
+ if (ret == MAP_FAILED)
+ return 0;
+ mmap((void *)0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
+ if (ret == MAP_FAILED)
+ return 0;
loop();
return 0;
}