[PATCH libaio] Fix io_pgetevents() syscall wrapper on 32-bit userland on 64-bit kernels
authorGuillem Jover <guillem@hadrons.org>
Fri, 16 Aug 2019 00:33:46 +0000 (02:33 +0200)
committerPeter Michael Green <plugwash@raspbian.org>
Mon, 15 Nov 2021 00:13:31 +0000 (00:13 +0000)
commitcb1eb6ab923e4a4a113611cfaed024d1d4df953a
treeacdc3c8e2839d28fd9b0692e032364a183f1b4a4
parent1eeee903cc861288c245ea0af5dc4e78b0962f4e
[PATCH libaio] Fix io_pgetevents() syscall wrapper on 32-bit userland on 64-bit kernels

The kernel compat syscall in the kernel got introduced with a broken
layout, which requires a pointer to the actual sigset_t variable but
with the size of the running kernel, not the size of the compat code.

This means that when the wrapper sends the expected compat (32-bit)
pointer, the kernel reads a 64-bit pointer, eating with it also the
sigset size member. And then proceeds to fail the comparison of the
sigset_t size and returns EINVAL.

This really needs to be fixed in the kernel, as there's no apparent
user of the broken compat layout (from codesearch.debian.org, nor a
quick github.com search). But we have to workaround it in libaio so
that we can use kernels that have not yet been fixed.

We do that, by trying the non-broken layout (that would be used with
a 32-bit userland on a 32-bit kernel), and if that fails with -EINVAL
we retry with a structure padded to what the kernel expects.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
Gbp-Pq: Name 0001-Fix-io_pgetevents-syscall-wrapper-on-32-bit-userland.patch
src/io_pgetevents.c
src/libaio.h