Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

fetch_indirect_syscall_args.c 847B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2018 The strace developers.
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. /*
  9. * Fetch indirect syscall arguments that are provided as an array.
  10. * Return a pointer to a static array of kernel_ulong_t elements,
  11. * or NULL in case of fetch failure.
  12. */
  13. kernel_ulong_t *
  14. fetch_indirect_syscall_args(struct tcb *const tcp,
  15. const kernel_ulong_t addr,
  16. const unsigned int n_args)
  17. {
  18. static kernel_ulong_t u_arg[MAX_ARGS];
  19. if (current_wordsize == sizeof(*u_arg)) {
  20. if (umoven(tcp, addr, sizeof(*u_arg) * n_args, u_arg))
  21. return NULL;
  22. } else {
  23. uint32_t narrow_arg[ARRAY_SIZE(u_arg)];
  24. if (umoven(tcp, addr, sizeof(*narrow_arg) * n_args, narrow_arg))
  25. return NULL;
  26. for (unsigned int i = 0; i < n_args; ++i)
  27. u_arg[i] = narrow_arg[i];
  28. }
  29. return u_arg;
  30. }