ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH 0/1] Change return type of tst_syscall
@ 2022-10-27 16:36 Teo Couprie Diaz
  2022-10-27 16:36 ` [LTP] [RFC PATCH 1/1] regen.sh: Use intptr_t for tst_syscall return Teo Couprie Diaz
  0 siblings, 1 reply; 6+ messages in thread
From: Teo Couprie Diaz @ 2022-10-27 16:36 UTC (permalink / raw)
  To: ltp

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


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-01 10:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27 16:36 [LTP] [RFC PATCH 0/1] Change return type of tst_syscall Teo Couprie Diaz
2022-10-27 16:36 ` [LTP] [RFC PATCH 1/1] regen.sh: Use intptr_t for tst_syscall return Teo Couprie Diaz
2022-10-31 13:32   ` Cyril Hrubis
2022-10-31 17:18     ` Teo Couprie Diaz
2022-10-31 17:41       ` Cyril Hrubis
2022-11-01 10:09         ` Teo Couprie Diaz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).