[LTP] [RFC PATCH 0/1] Change return type of tst_syscall

Teo Couprie Diaz teo.coupriediaz@arm.com
Thu Oct 27 18:36:53 CEST 2022


Hello LTP maintainers,

The goal of this patch is to check that the change makes sense, that I
haven't missed anything in my testing and that it doesn't break some
assumptions that LTP might make.

Currently, tst_syscall stores the return value of the syscall in an int,
which is fine most of the time but some syscalls can return values larger
than an int.
For example `write` returns a long and `mmap` returns a pointer. _Most_ of
the time it would be fine, but it means that a test using such a syscall
written with tst_syscall would be incorrect, as its return value would be
truncated.
This was discovered while working on a patch testing `brk` directly,
without going through the libc, as `brk` returns an unsigned long.

This patche fixes the type by using `intptr_t` to keep it signed,
and because it guarantees that it can be cast to and from a pointer type,
which is one of the primary use cases here.
As such, it also would work on architectures that have pointers bigger
than long, such as CHERI[0] or Morello[1].

To make sure that the change didn't impact already written tests, I
generated a list from the source files that use `tst_syscall` and ran
them all.
Hopefully I didn't miss anything here: the list is provided in the
patch for your testing purposes but would probably not make sense
to merge.
I tested the patch on x86_64-musl and Aarch64-musl (QEMU and Arm FVP)
with this list of tests, without regressions.

The build CI on Github is all green as well :
https://github.com/Teo-CD/ltp/actions/runs/3337957209


I hope that this all makes sense and can be useful for LTP. I would be
glad to know if this has consequences I don't see or if I'm wrong in my
reasoning !

Best regards,
Téo Couprie Diaz

[0]: https://www.cl.cam.ac.uk/research/security/ctsrd/cheri/
[1]: https://www.morello-project.org/

Teo Couprie Diaz (1):
  regen.sh: Use intptr_t for tst_syscall return

 include/lapi/syscalls/regen.sh |   2 +-
 runtest/check_tst_syscall      | 190 +++++++++++++++++++++++++++++++++
 2 files changed, 191 insertions(+), 1 deletion(-)
 create mode 100644 runtest/check_tst_syscall


base-commit: 8cd3bf3149c4a8cb6f6c85dc76a36d7f6dd87f76
-- 
2.25.1



More information about the ltp mailing list