Skip to content
Commit e8819349 authored by Alex Richardson's avatar Alex Richardson Committed by Simon Ser
Browse files

os-wrappers-test.c: Correctly forward arguments to fcntl



We can't just unconditionally read the optional arguments (and also read
it as a void* despite actually being an int).
While this happens to work on most architectures because the first few
variadic arguments are passed in registers, this is non-portable and
causes a crash on architectures that set bounds on variadic function
arguments (for example CHERI-enabled architectures). It could also cause
problems on big-endian architectures that pass variadic arguments on the
stack rather than in registers.

For CHERI-MIPS, reading sizeof(void*) causes a read of 16 bytes from the
bounded varargs capability. This always crashes since even calls with the
optional argument only have 4 bytes available.

Signed-off-by: default avatarAlex Richardson <Alexander.Richardson@cl.cam.ac.uk>
Reviewed-by: default avatarSimon Ser <contact@emersion.fr>
parent e4659ffb
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment