Prevent linker issues in lapi/io_uring.h
PATCH v2 1/4 Prevent linker issues in lapi/io_uring.h
Fallback io_uring syscall wrappers were not defined as static inline. This will lead to linker issues when safe function variants get added to LTP library.
Also add check for <linux/io_uring.h> to configure script and #include it in the LAPI header if it's available.
---
Changes since v1:
- None (changes only in patch 4)
configure.ac | 1 + include/lapi/io_uring.h | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-)
configure.ac +1 -0
@@ -49,6 +49,7 @@ AC_CHECK_HEADERS_ONCE([ \ linux/if_alg.h \ linux/if_ether.h \ linux/if_packet.h \ + linux/io_uring.h \ linux/keyctl.h \ linux/mempolicy.h \ linux/module.h \
include/lapi/io_uring.h +11 -6
@@ -18,6 +18,10 @@#include "lapi/syscalls.h" +#ifdef HAVE_LINUX_IO_URING_H +#include <linux/io_uring.h> +#endif +#ifndef IOSQE_FIXED_FILE #ifndef __kernel_rwf_t
@@ -260,8 +264,8 @@ struct io_uring_probe {#ifndef HAVE_IO_URING_REGISTER -int io_uring_register (int fd,unsigned int opcode,void *arg, -unsigned int nr_args) +static inline int io_uring_register (int fd,unsigned int opcode,void *arg, +unsigned int nr_args) {return tst_syscall (__NR_io_uring_register, fd, opcode, arg, nr_args); }
@@ -269,22 +273,23 @@ int io_uring_register(int fd, unsigned int opcode, void *arg,#ifndef HAVE_IO_URING_SETUP -int io_uring_setup (unsigned int entries,struct io_uring_params *p) +static inline int io_uring_setup (unsigned int entries, +struct io_uring_params *p) {return tst_syscall (__NR_io_uring_setup, entries, p); }#endif /* HAVE_IO_URING_SETUP */ #ifndef HAVE_IO_URING_ENTER -int io_uring_enter (int fd,unsigned int to_submit,unsigned int min_complete, -unsigned int flags,sigset_t *sig) +static inline int io_uring_enter (int fd,unsigned int to_submit, +unsigned int min_complete,unsigned int flags,sigset_t *sig) {return tst_syscall (__NR_io_uring_enter, fd, to_submit, min_complete, flags, sig, _NSIG /8 ); }#endif /* HAVE_IO_URING_ENTER */ -void io_uring_setup_supported_by_kernel (void ) +static inline void io_uring_setup_supported_by_kernel (void ) {if ((tst_kvercmp (5 ,1 ,0 )) <0 ) {TEST (syscall (__NR_io_uring_setup,NULL ,0 ));
Signature · 1 line
2.30.0
PATCH v2 2/4 Add safe functions for io_uring to LTP library
--- include/tst_safe_io_uring.h | 63 +++++++++++++++++++++ lib/tst_safe_io_uring.c | 108 ++++++++++++++++++++++++++++++++++++ 2 files changed, 171 insertions(+) create mode 100644 include/tst_safe_io_uring.h create mode 100644 lib/tst_safe_io_uring.c
include/tst_safe_io_uring.h new file +63 -0
@@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (c) Linux Test Project, 2021 +*/ + +#ifndef TST_IO_URING_H__ +#define TST_IO_URING_H__ + +#include "config.h" +#include "lapi/io_uring.h" + +struct tst_io_uring { +int fd; +void *sqr_base, *cqr_base; +/* buffer sizes in bytes for unmapping */ +size_t sqr_mapsize, cqr_mapsize; + +/* Number of entries in the ring buffers */ +uint32_t sqr_size, cqr_size; + +/* Submission queue pointers */ +struct io_uring_sqe *sqr_entries; +const uint32_t *sqr_head, *sqr_mask, *sqr_flags, *sqr_dropped; +uint32_t *sqr_tail, *sqr_array; + +/* Completion queue pointers */ +const struct io_uring_cqe *cqr_entries; +const uint32_t *cqr_tail, *cqr_mask, *cqr_overflow; +uint32_t *cqr_head; + +}; + +/* +* Call io_uring_setup() with given arguments and prepare memory mappings +* into the tst_io_uring structure passed in the third argument. +*/ +#define SAFE_IO_URING_INIT (entries, params, uring) \ + safe_io_uring_init(__FILE__, __LINE__, (entries), (params), (uring)) +int safe_io_uring_init (const char *file,const int lineno, +unsigned int entries,struct io_uring_params *params, +struct tst_io_uring *uring); + +/* +* Release io_uring mappings and close the file descriptor. uring->fd will +* be set to -1 after close. +*/ +#define SAFE_IO_URING_CLOSE (uring) \ + safe_io_uring_close(__FILE__, __LINE__, (uring)) +int safe_io_uring_close (const char *file,const int lineno, +struct tst_io_uring *uring); + +/* +* Call io_uring_enter() and check for errors. The "strict" argument controls +* pedantic check whether return value is equal to "to_submit" argument. +*/ +#define SAFE_IO_URING_ENTER (strict, fd, to_submit, min_complete, flags, sig) \ + safe_io_uring_enter(__FILE__, __LINE__, (strict), (fd), (to_submit), \ + (min_complete), (flags), (sig)) +int safe_io_uring_enter (const char *file,const int lineno,int strict, +int fd,unsigned int to_submit,unsigned int min_complete, +unsigned int flags,sigset_t *sig); + +#endif /* TST_IO_URING_H__ */
lib/tst_safe_io_uring.c new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.30.0
PATCH v2 2/4 Add safe functions for io_uring to LTP library
Hi Martin,
Quoted 22 lines
+++
b/include/tst_safe_io_uring.hinclude/tst_safe_io_uring.h new file +20
-0@@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (c) Linux Test Project, 2021 +*/ + +#ifndef TST_IO_URING_H__ +#define TST_IO_URING_H__ + +#include "config.h" +#include "lapi/io_uring.h" + +struct tst_io_uring { + int fd; + void *sqr_base, *cqr_base; + /* buffer sizes in bytes for unmapping */ + size_t sqr_mapsize, cqr_mapsize; + + /* Number of entries in the ring buffers */ + uint32_t sqr_size, cqr_size; +
include/tst_safe_io_uring.h line 30
Quoted 10 lines
include/tst_safe_io_uring.h new file +10
-0+/* Submission queue pointers */ +struct io_uring_sqe *sqr_entries; +const uint32_t *sqr_head, *sqr_mask, *sqr_flags, *sqr_dropped; +uint32_t *sqr_tail, *sqr_array; + +/* Completion queue pointers */ +const struct io_uring_cqe *cqr_entries; +const uint32_t *cqr_tail, *cqr_mask, *cqr_overflow; +uint32_t *cqr_head; +
nit: blank line.
Quoted 1 line
include/tst_safe_io_uring.h new file +1
-0+};
...
Quoted 1 line
+++
b/lib/tst_safe_io_uring.c
...
lib/tst_safe_io_uring.c line 40
Quoted 6 lines
lib/tst_safe_io_uring.c new file +6
-0+ uring->sqr_base =safe_mmap (file, lineno,NULL , uring->sqr_mapsize, +PROT_READ |PROT_WRITE ,MAP_SHARED |MAP_POPULATE , uring->fd, +IORING_OFF_SQ_RING ); + +if (uring->sqr_base ==MAP_FAILED ) +return -1 ;
IMHO this is not needed, safe_mmap() breaks on rval == MAP_FAILED.
lib/tst_safe_io_uring.c line 48
Quoted 8 lines
lib/tst_safe_io_uring.c new file +8
-0+ + uring->sqr_entries =safe_mmap (file, lineno,NULL , + params->sq_entries *sizeof (struct io_uring_sqe ), +PROT_READ |PROT_WRITE ,MAP_SHARED |MAP_POPULATE , uring->fd, +IORING_OFF_SQES ); + +if (uring->sqr_entries ==MAP_FAILED ) +return -1 ;
And here.
lib/tst_safe_io_uring.c line 55
Quoted 7 lines
lib/tst_safe_io_uring.c new file +7
-0+ + uring->cqr_base =safe_mmap (file, lineno,NULL , uring->cqr_mapsize, +PROT_READ |PROT_WRITE ,MAP_SHARED |MAP_POPULATE , uring->fd, +IORING_OFF_CQ_RING ); + +if (uring->cqr_base ==MAP_FAILED ) +return -1 ;
And here.
No need to repost, these two can be removed before merge. The rest LGTM.
Kind regards,
Petr
PATCH v2 2/4 Add safe functions for io_uring to LTP library
Quoted 11 lines · Petr Vorel
Hi Martin,
Quoted 1 line
+++
b/lib/tst_safe_io_uring.c...
lib/tst_safe_io_uring.c line 40
Quoted 6 lines
lib/tst_safe_io_uring.c new file +6
-0+ uring->sqr_base =safe_mmap (file, lineno,NULL , uring->sqr_mapsize, +PROT_READ |PROT_WRITE ,MAP_SHARED |MAP_POPULATE , uring->fd, +IORING_OFF_SQ_RING ); + +if (uring->sqr_base ==MAP_FAILED ) +return -1 ;IMHO this is not needed,
safe_mmap()breaks on rval ==MAP_FAILED.
Except when called in cleanup() where it prints a warning and returns as usual. That's why safe_io_uring_init() returns int instead of void in the first place.
I don't expect that safe_io_uring_init() will be used in cleanup() very often but I've made all the other SAFE_*() functions cleanup()-safe and I want to stick with that here as well.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH v2 2/4 Add safe functions for io_uring to LTP library
Hi Martin,
Quoted 10 lines
Quoted 9 lines
Quoted 1 line
+++
b/lib/tst_safe_io_uring.c...
lib/tst_safe_io_uring.c line 40
Quoted 6 lines
lib/tst_safe_io_uring.c new file +6
-0+ uring->sqr_base =safe_mmap (file, lineno,NULL , uring->sqr_mapsize, +PROT_READ |PROT_WRITE ,MAP_SHARED |MAP_POPULATE , uring->fd, +IORING_OFF_SQ_RING ); + +if (uring->sqr_base ==MAP_FAILED ) +return -1 ;IMHO this is not needed,
safe_mmap()breaks on rval ==MAP_FAILED.
Quoted 7 lines
Except when called in
cleanup()where it prints a warning and returns as usual. That's whysafe_io_uring_init()returns int instead of void in the first place.I don't expect that
safe_io_uring_init()will be used incleanup()very often but I've made all the other SAFE_*() functions cleanup()-safe and I want to stick with that here as well.
Good point, makes sense. Thanks for an explanation.
Kind regards,
Petr
PATCH v2 3/4 Add CAP_SYS_CHROOT to lapi/capability.h
In reply to Martin Doucha--- include/lapi/capability.h | 4 ++++ 1 file changed, 4 insertions(+)
include/lapi/capability.h +4 -0
@@ -24,6 +24,10 @@# define CAP_NET_RAW 13#endif +#ifndef CAP_SYS_CHROOT +# define CAP_SYS_CHROOT 18 +#endif +#ifndef CAP_SYS_ADMIN # define CAP_SYS_ADMIN 21#endif
Signature · 1 line
2.30.0
PATCH v2 4/4 Add test for CVE 2020-29373
In reply to Martin DouchaFixes #770
---
Changes since v1:
- Added another patch reference
runtest/cve | 1 + runtest/syscalls | 1 + .../kernel/syscalls/io_uring/io_uring02.c | 204 ++++++++++++++++++ 3 files changed, 206 insertions(+) create mode 100644 testcases/kernel/syscalls/io_uring/io_uring02.c
runtest/cve +1 -0
@@ -60,3 +60,4 @@ cve-2019-8912 af_alg07 cve-2020-11494 pty04 cve-2020-14386 sendto03 cve-2020-14416 pty03 +cve-2020-29373 io_uring02
runtest/syscalls +1 -0
@@ -1712,3 +1712,4 @@ statx07 statx07 membarrier01 membarrier01 io_uring01 io_uring01 +io_uring02 io_uring02
testcases/kernel/syscalls/io_uring/io_uring02.c new file +204 -0
204 lines not on this page · raw message
Signature · 1 line
2.30.0
PATCH v2 4/4 Add test for CVE 2020-29373
Hi Martin,
Quoted 1 line
Fixes #770
Nice port thanks!
Few questions below.
...
Quoted 13 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +13
-0+static void run (void ) +{ +uint32_t i, count, tail; +int beef_found =0 ; +struct io_uring_sqe *sqe_ptr; +const struct io_uring_cqe *cqe_ptr; + +SAFE_SOCKETPAIR (AF_UNIX ,SOCK_DGRAM ,0 , sockpair); +SAFE_SETSOCKOPT_INT (sockpair[0 ],SOL_SOCKET ,SO_SNDBUF , +32 +sizeof (buf)); +SAFE_FCNTL (sockpair[0 ],F_SETFL ,O_NONBLOCK ); + +SAFE_IO_URING_INIT (512 , ¶ms, &uring);
testcases/kernel/syscalls/io_uring/io_uring02.c line 104
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ sqe_ptr = uring.sqr_entries; + +/* Add spam requests to force async processing of the real test */ +for (i =0 , tail = *uring.sqr_tail; i <255 ; i++, tail++, sqe_ptr++) { +memset (sqe_ptr,0 ,sizeof (*sqe_ptr)); + sqe_ptr->opcode =IORING_OP_SENDMSG ; + sqe_ptr->flags =IOSQE_IO_DRAIN ; + sqe_ptr->fd = sockpair[0 ]; + sqe_ptr->addr = (__u64)&spam_header; + sqe_ptr->user_data =SPAM_MARK ;
Interesting, original reproducer uses here i
testcases/kernel/syscalls/io_uring/io_uring02.c line 114
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ uring.sqr_array[tail & *uring.sqr_mask] = i; + } + +/* Add the real test to queue */ +memset (sqe_ptr,0 ,sizeof (*sqe_ptr)); + sqe_ptr->opcode =IORING_OP_SENDMSG ; + sqe_ptr->flags =IOSQE_IO_DRAIN ; + sqe_ptr->fd = sendsock; + sqe_ptr->addr = (__u64)&beef_header; + sqe_ptr->user_data =BEEF_MARK ;
and here also 255, you use much higher 0xbeef.
You probably have a good reason to use here 0xfa7 (higher value). But maybe explaining why?
Quoted 11 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +11
-0+ uring.sqr_array[tail & *uring.sqr_mask] = i; + count = ++i; + tail++; + +__atomic_store (uring.sqr_tail, &tail, __ATOMIC_RELEASE); +SAFE_IO_URING_ENTER (1 , uring.fd, count, count,IORING_ENTER_GETEVENTS , +NULL ); + +/* Check test results */ +__atomic_load (uring.cqr_tail, &tail, __ATOMIC_ACQUIRE); +
testcases/kernel/syscalls/io_uring/io_uring02.c line 135
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+for (i = *uring.cqr_head; i != tail; i++, count--) { + cqe_ptr = uring.cqr_entries + (i & *uring.cqr_mask); +TST_ERR = -cqe_ptr->res; + +if (cqe_ptr->user_data ==SPAM_MARK ) { +if (cqe_ptr->res >=0 || cqe_ptr->res == -EAGAIN ) +continue ; + +tst_res (TFAIL |TTERRNO , +"Spam request failed unexpectedly" );
I'm sorry, I'm lost to which TEST*() call this TTERRNO refers (there are mostly SAFE_*() macros.
Quoted 5 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +5
-0+continue ; + } + +if (cqe_ptr->user_data !=BEEF_MARK ) { +tst_res (TFAIL ,"Unexpected entry in completion queue" );
testcases/kernel/syscalls/io_uring/io_uring02.c line 150
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ count++; +continue ; + } + + beef_found =1 ; + +if (cqe_ptr->res >=0 ) { +tst_res (TFAIL ,"Write outside chroot succeeded." ); + }else if (cqe_ptr->res != -ENOENT ) { + tst_res(TFAIL | TTERRNO,
And here.
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ "Write outside chroot failed unexpectedly"); + }else { +tst_res (TPASS , +"Write outside chroot failed as expected" ); + } + } + +__atomic_store (uring.cqr_head, &i, __ATOMIC_RELEASE); + +if (!beef_found)
testcases/kernel/syscalls/io_uring/io_uring02.c line 170
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+tst_res (TFAIL ,"Write outside chroot result not found" ); + +if (count) +tst_res (TFAIL ,"Wrong number of entries in completion queue" ); + +/* iteration cleanup */ +SAFE_IO_URING_CLOSE (&uring); +SAFE_CLOSE (sockpair[0 ]); +SAFE_CLOSE (sockpair[1 ]); +}
Kind regards,
Petr
PATCH v2 4/4 Add test for CVE 2020-29373
Quoted 48 lines · Petr Vorel
Hi Martin,
Quoted 1 line
Fixes #770
Nice port thanks!
Reviewed-by Petr Vorel <[email protected]>Few questions below.
...
Quoted 13 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +13
-0+static void run (void ) +{ +uint32_t i, count, tail; +int beef_found =0 ; +struct io_uring_sqe *sqe_ptr; +const struct io_uring_cqe *cqe_ptr; + +SAFE_SOCKETPAIR (AF_UNIX ,SOCK_DGRAM ,0 , sockpair); +SAFE_SETSOCKOPT_INT (sockpair[0 ],SOL_SOCKET ,SO_SNDBUF , +32 +sizeof (buf)); +SAFE_FCNTL (sockpair[0 ],F_SETFL ,O_NONBLOCK ); + +SAFE_IO_URING_INIT (512 , ¶ms, &uring);testcases/kernel/syscalls/io_uring/io_uring02.c line 104
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ sqe_ptr = uring.sqr_entries; + +/* Add spam requests to force async processing of the real test */ +for (i =0 , tail = *uring.sqr_tail; i <255 ; i++, tail++, sqe_ptr++) { +memset (sqe_ptr,0 ,sizeof (*sqe_ptr)); + sqe_ptr->opcode =IORING_OP_SENDMSG ; + sqe_ptr->flags =IOSQE_IO_DRAIN ; + sqe_ptr->fd = sockpair[0 ]; + sqe_ptr->addr = (__u64)&spam_header; + sqe_ptr->user_data =SPAM_MARK ;Interesting, original reproducer uses here i
testcases/kernel/syscalls/io_uring/io_uring02.c line 114
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ uring.sqr_array[tail & *uring.sqr_mask] = i; + } + +/* Add the real test to queue */ +memset (sqe_ptr,0 ,sizeof (*sqe_ptr)); + sqe_ptr->opcode =IORING_OP_SENDMSG ; + sqe_ptr->flags =IOSQE_IO_DRAIN ; + sqe_ptr->fd = sendsock; + sqe_ptr->addr = (__u64)&beef_header; + sqe_ptr->user_data =BEEF_MARK ;and here also 255, you use much higher
0xbeef.
Quoted 2 lines
You probably have a good reason to use here
0xfa7(higher value). But maybe explaining why?
The good reason is that I like puns. sqe_ptr->user_data is not processed by the kernel in any way except for copying the value into the completion queue when the I/O request finishes. And we don't care whether we can tell apart the spam request results from one another so giving them all the same marker is good enough.
Quoted 15 lines
Quoted 15 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +15
-0+ uring.sqr_array[tail & *uring.sqr_mask] = i; + count = ++i; + tail++; + +__atomic_store (uring.sqr_tail, &tail, __ATOMIC_RELEASE); +SAFE_IO_URING_ENTER (1 , uring.fd, count, count,IORING_ENTER_GETEVENTS , +NULL ); + +/* Check test results */ +__atomic_load (uring.cqr_tail, &tail, __ATOMIC_ACQUIRE); + +for (i = *uring.cqr_head; i != tail; i++, count--) { + cqe_ptr = uring.cqr_entries + (i & *uring.cqr_mask); +TST_ERR = -cqe_ptr->res; +
Quoted 8 lines
testcases/kernel/syscalls/io_uring/io_uring02.c line 135
Quoted 6 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +6
-0+if (cqe_ptr->user_data ==SPAM_MARK ) { +if (cqe_ptr->res >=0 || cqe_ptr->res == -EAGAIN ) +continue ; + +tst_res (TFAIL |TTERRNO , +"Spam request failed unexpectedly" );I'm sorry, I'm lost to which TEST*() call this TTERRNO refers (there are mostly SAFE_*() macros.
I'm setting TST_ERR manually 6 lines above the tst_res() call. The errno value is in cqe_ptr->res.
Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
PATCH v2 4/4 Add test for CVE 2020-29373
Hi Martin,
Quoted 22 lines
Quoted 21 lines
testcases/kernel/syscalls/io_uring/io_uring02.c line 104
Quoted 8 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +8
-0+/* Add spam requests to force async processing of the real test */ +for (i =0 , tail = *uring.sqr_tail; i <255 ; i++, tail++, sqe_ptr++) { +memset (sqe_ptr,0 ,sizeof (*sqe_ptr)); + sqe_ptr->opcode =IORING_OP_SENDMSG ; + sqe_ptr->flags =IOSQE_IO_DRAIN ; + sqe_ptr->fd = sockpair[0 ]; + sqe_ptr->addr = (__u64)&spam_header; + sqe_ptr->user_data =SPAM_MARK ;Interesting, original reproducer uses here i
testcases/kernel/syscalls/io_uring/io_uring02.c line 114
Quoted 10 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +10
-0+ uring.sqr_array[tail & *uring.sqr_mask] = i; + } + +/* Add the real test to queue */ +memset (sqe_ptr,0 ,sizeof (*sqe_ptr)); + sqe_ptr->opcode =IORING_OP_SENDMSG ; + sqe_ptr->flags =IOSQE_IO_DRAIN ; + sqe_ptr->fd = sendsock; + sqe_ptr->addr = (__u64)&beef_header; + sqe_ptr->user_data =BEEF_MARK ;and here also 255, you use much higher
0xbeef.
Quoted 8 lines
Quoted 2 lines
You probably have a good reason to use here
0xfa7(higher value). But maybe explaining why?The good reason is that I like puns.
sqe_ptr->user_datais not processed by the kernel in any way except for copying the value into the completion queue when the I/O request finishes. And we don't care whether we can tell apart the spam request results from one another so giving them all the same marker is good enough.
Thanks for an explanation!
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +15
-0+ uring.sqr_array[tail & *uring.sqr_mask] = i; + count = ++i; + tail++; + +__atomic_store (uring.sqr_tail, &tail, __ATOMIC_RELEASE); +SAFE_IO_URING_ENTER (1 , uring.fd, count, count,IORING_ENTER_GETEVENTS , +NULL ); + +/* Check test results */ +__atomic_load (uring.cqr_tail, &tail, __ATOMIC_ACQUIRE); + +for (i = *uring.cqr_head; i != tail; i++, count--) { + cqe_ptr = uring.cqr_entries + (i & *uring.cqr_mask); +TST_ERR = -cqe_ptr->res; +Quoted 8 lines
testcases/kernel/syscalls/io_uring/io_uring02.c line 135
Quoted 6 lines
testcases/kernel/syscalls/io_uring/io_uring02.c new file +6
-0+if (cqe_ptr->user_data ==SPAM_MARK ) { +if (cqe_ptr->res >=0 || cqe_ptr->res == -EAGAIN ) +continue ; + +tst_res (TFAIL |TTERRNO , +"Spam request failed unexpectedly" );I'm sorry, I'm lost to which TEST*() call this TTERRNO refers (there are mostly SAFE_*() macros.
Quoted 2 lines
I'm setting
TST_ERRmanually 6 lines above thetst_res()call. The errno value is incqe_ptr->res.
Thank you, I'm blind :).
Anyway, merged. Thanks for your work!
BTW: test fails on my openSUSE kernel 5.11.0-rc6, which should have both kernel fixes.
Kind regards,
Petr
PATCH v2 1/4 Prevent linker issues in lapi/io_uring.h
In reply to Martin DouchaHi Martin,
Quoted 6 lines
Fallback
io_uringsyscall wrappers were not defined as static inline. This will lead to linker issues when safe function variants get added to LTP library.Also add check for <
linux/io_uring.h> to configure script and #include it in the LAPI header if it's available.
Thanks for cleanup!
...
Quoted 9 lines
+++ b/configure.ac
configure.ac +1
-0@@ -49,6 +49,7 @@ AC_CHECK_HEADERS_ONCE([ \ linux/if_alg.h \ linux/if_ether.h \ linux/if_packet.h \ + linux/io_uring.h \ linux/keyctl.h \ linux/mempolicy.h \ linux/module.h \
...
Quoted 1 line
+++
b/include/lapi/io_uring.h
...
include/lapi/io_uring.h line 25
Quoted 5 lines
include/lapi/io_uring.h +4
-0+#ifdef HAVE_LINUX_IO_URING_H +#include <linux/io_uring.h> +#endif +#ifndef IOSQE_FIXED_FILE
This could be also guarded as ! HAVE_LINUX_IO_URING_H (#else branch), but keeping IOSQE_FIXED_FILE is probably safer.
include/lapi/io_uring.h int io_uring_register(int fd, unsigned int opcode, void *arg,
Quoted 13 lines
#ifndef
__kernel_rwf_tinclude/lapi/io_uring.h +2
-2@@ -260,8 +264,8 @@ struct io_uring_probe {#ifndef HAVE_IO_URING_REGISTER -int io_uring_register (int fd,unsigned int opcode,void *arg, -unsigned int nr_args) +static inline int io_uring_register (int fd,unsigned int opcode,void *arg, +unsigned int nr_args) {return tst_syscall (__NR_io_uring_register, fd, opcode, arg, nr_args); }@@ -269,22 +273,23 @@ int io_uring_register(int fd, unsigned int opcode, void *arg,
...
Kind regards,
Petr