qemu-e2k/linux-user
Filip Bozuta 0a7ec8493d linux-user: Fix 'semop()' and 'semtimedop()' implementation
The implementations of syscalls 'semop()' and 'semtimedop()' in
file 'syscall.c' use function 'target_to_host_sembuf()' to convert
values of 'struct sembuf' from host to target. However, before this
conversion it should be check whether the number of semaphore operations
'nsops' is not bigger than maximum allowed semaphor operations per
syscall: 'SEMOPM'. In these cases, errno 'E2BIG' ("Arg list too long")
should be set. But the implementation will set errno 'EFAULT' ("Bad address")
in this case since the conversion from target to host in this case fails.

This was confirmed with the LTP test for 'semop()' ('ipc/semop/semop02') in
test case where 'nsops' is greater than SEMOPM with unaproppriate errno EFAULT:

semop02.c:130: FAIL: semop failed unexpectedly; expected: E2BIG: EFAULT (14)

This patch changes this by adding a check whether 'nsops' is bigger than
'SEMOPM' before the conversion function 'target_to_host_sembuf()' is called.
After the changes from this patch, the test works fine along with the other
LTP testcases for 'semop()'):

semop02.c:126: PASS: semop failed as expected: E2BIG (7)

Implementation notes:

    A target value ('TARGET_SEMOPM') was added for 'SEMOPM' as to be sure
    in case the value is not available for some targets.

Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200818180722.45089-1-Filip.Bozuta@syrmia.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2020-08-27 12:29:49 +02:00
..
aarch64
alpha meson: linux-user 2020-08-21 06:30:38 -04:00
arm meson: linux-user 2020-08-21 06:30:38 -04:00
cris
generic linux-user: implement OFD locks 2020-06-05 21:23:22 +02:00
host
hppa meson: linux-user 2020-08-21 06:30:38 -04:00
i386 meson: linux-user 2020-08-21 06:30:38 -04:00
m68k meson: linux-user 2020-08-21 06:30:38 -04:00
microblaze meson: linux-user 2020-08-21 06:30:38 -04:00
mips meson: linux-user 2020-08-21 06:30:38 -04:00
mips64 meson: linux-user 2020-08-21 06:30:38 -04:00
nios2
openrisc
ppc meson: linux-user 2020-08-21 06:30:38 -04:00
riscv
s390x meson: linux-user 2020-08-21 06:30:38 -04:00
sh4 meson: linux-user 2020-08-21 06:30:38 -04:00
sparc meson: linux-user 2020-08-21 06:30:38 -04:00
sparc64 meson: linux-user 2020-08-21 06:30:38 -04:00
tilegx
x86_64 meson: linux-user 2020-08-21 06:30:38 -04:00
xtensa meson: linux-user 2020-08-21 06:30:38 -04:00
cpu_loop-common.h
elfload.c linux-user: don't use MAP_FIXED in pgd_find_hole_fallback 2020-07-27 09:41:18 +01:00
errno_defs.h
exit.c
fd-trans.c linux-user: add netlink RTM_SETLINK command 2020-07-13 21:26:33 +02:00
fd-trans.h
flat.h
flatload.c linux-user: completely re-write init_guest_space 2020-05-15 15:25:16 +01:00
ioctls.h linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS 2020-06-29 13:10:11 +02:00
linux_loop.h
linuxload.c
main.c linux-user: Ensure mmap_min_addr is non-zero 2020-07-27 22:02:40 +02:00
meson.build meson: linux-user 2020-08-21 06:30:38 -04:00
mmap.c linux-user: Adjust guest page protection for the host 2020-08-23 16:57:58 +02:00
qemu.h linux-user: Add strace support for printing arguments of ioctl() 2020-07-04 18:08:51 +02:00
safe-syscall.S
signal-common.h
signal.c
socket.h
strace.c linux-user: Fix "print_fdset()" in "strace.c" to not print ", " after last value 2020-08-23 16:57:58 +02:00
strace.list linux-user: Add strace support for printing arguments of ioctl() 2020-07-04 18:08:51 +02:00
syscall_defs.h linux-user: Fix 'semop()' and 'semtimedop()' implementation 2020-08-27 12:29:49 +02:00
syscall_types.h linux-user: Add thunk argument types for SIOCGSTAMP and SIOCGSTAMPNS 2020-06-29 13:10:11 +02:00
syscall.c linux-user: Fix 'semop()' and 'semtimedop()' implementation 2020-08-27 12:29:49 +02:00
target_flat.h
trace-events
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
uaccess.c
uname.c
uname.h
vm86.c