[PATCH v2 10/11] tools/nolibc: add ptrace support
Willy Tarreau
w at 1wt.eu
Sun Sep 21 01:19:47 PDT 2025
On Sat, Sep 20, 2025 at 11:27:19AM +0200, Thomas Weißschuh wrote:
> > +/*
> > + * long ptrace(int op, pid_t pid, void *addr, void *data);
> > + *
> > + * However, addr may also be an integer in some cases.
>
> This comment is a bit confusing. It reads like it can be an integer as
> in 'int' datatype. But the kernel expects an integer compatible with
> 'void *', so 'unsigned long'. I think we can drop the comment.
Or if the point is to insist that void* is not strictly required, a
comment might as well say "types for addr and data are ignored and
will be cast to void*". But given that the man page indicates two
void*, I think that callers are expected to cast ints to void* in
any case, and if so maybe indeed not saying anything about it would
be better.
> > + */
> > +static __attribute__((unused))
> > +long sys_vptrace(int op, pid_t pid, va_list args)
> > +{
> > + return my_syscall4(__NR_ptrace, op, pid,
> > + va_arg(args, void *), va_arg(args, void *));
> > +}
> > +
> > +static __attribute__((unused))
> > +ssize_t sys_ptrace(int op, pid_t pid, ...)
>
> ptrace(2) does not document addr and data to be optional.
> While it does acknowledge the fact that it is variadic on glibc,
> users are still recommended to always supply all arguments.
> I'd prefer to keep it simple and avoid the va_list.
The man indeed says they are *ignored*, not optional. I agree then that
it would be better not doing simpler than the standard and have to roll
back later. Let's just pass unused arguments to the system.
Thanks,
Willy
More information about the linux-um
mailing list