diff mbox series

[v2,1/1] lapi/io_uring: <sys/types.h> => <linux/types.h>

Message ID 20240126111506.491324-1-pvorel@suse.cz
State Accepted
Headers show
Series [v2,1/1] lapi/io_uring: <sys/types.h> => <linux/types.h> | expand

Commit Message

Petr Vorel Jan. 26, 2024, 11:15 a.m. UTC
This fixes compilation on old toolchains:

Some old toolchains require to add <linux/types.h> to missing kernel
types:

tst_safe_io_uring.c: In function ‘safe_io_uring_init’:
tst_safe_io_uring.c:34:45: error: ‘__u32’ undeclared (first use in this function)
   34 |                 params->sq_entries * sizeof(__u32);
      |                                             ^~~~~

io_uring02.c: In function ‘drain_fallback’:
io_uring02.c:106:34: error: ‘__u64’ undeclared (first use in this function)
  106 |                 sqe_ptr->addr = (__u64)&spam_header;
      |                                  ^~~~~
io_uring02.c:106:34: note: each undeclared identifier is reported only once for each function it appears in
io_uring02.c: In function ‘run’:
io_uring02.c:221:26: error: ‘__u64’ undeclared (first use in this function)
  221 |         sqe_ptr->addr = (__u64)&beef_header;
      |                          ^~~~~

Newer kernel headers includes <linux/types.h> in <linux/io_uring.h>, but
we still support compilers without this header. Therefore replace
<sys/types.h> in lapi header with <linux/types.h>.

Fixes: 3f2ff5431 ("Add safe functions for io_uring to LTP library")
Fixes: c4f669f13 ("Add test for CVE 2020-29373")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* Fix also io_uring02.c

 include/lapi/io_uring.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Hrubis Jan. 26, 2024, 3:29 p.m. UTC | #1
Hi!
> This fixes compilation on old toolchains:
> 
> Some old toolchains require to add <linux/types.h> to missing kernel
> types:
> 
> tst_safe_io_uring.c: In function ‘safe_io_uring_init’:
> tst_safe_io_uring.c:34:45: error: ‘__u32’ undeclared (first use in this function)
>    34 |                 params->sq_entries * sizeof(__u32);
>       |                                             ^~~~~
> 
> io_uring02.c: In function ‘drain_fallback’:
> io_uring02.c:106:34: error: ‘__u64’ undeclared (first use in this function)
>   106 |                 sqe_ptr->addr = (__u64)&spam_header;
>       |                                  ^~~~~
> io_uring02.c:106:34: note: each undeclared identifier is reported only once for each function it appears in
> io_uring02.c: In function ‘run’:
> io_uring02.c:221:26: error: ‘__u64’ undeclared (first use in this function)
>   221 |         sqe_ptr->addr = (__u64)&beef_header;
>       |                          ^~~~~
> 
> Newer kernel headers includes <linux/types.h> in <linux/io_uring.h>, but
> we still support compilers without this header. Therefore replace
> <sys/types.h> in lapi header with <linux/types.h>.

I did look twice and we do not seem to use anything from the
<sys/types.h> in the header, so this should be safe.

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Petr Vorel Jan. 27, 2024, 5:54 a.m. UTC | #2
Hi Cyril,

...
> I did look twice and we do not seem to use anything from the
> <sys/types.h> in the header, so this should be safe.

Thank you for this check (I did just compile check), merged!

Kind regards,
Petr
diff mbox series

Patch

diff --git a/include/lapi/io_uring.h b/include/lapi/io_uring.h
index 03c45190e..c05517595 100644
--- a/include/lapi/io_uring.h
+++ b/include/lapi/io_uring.h
@@ -11,9 +11,9 @@ 
 
 #include <unistd.h>
 #include <fcntl.h>
-#include <sys/types.h>
 #include <sys/uio.h>
 #include <stdlib.h>
+#include <linux/types.h>
 
 #include "lapi/syscalls.h"