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_bpf_fprog.c 921B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2015-2018 Dmitry V. Levin <ldv@altlinux.org>
  3. * All rights reserved.
  4. *
  5. * SPDX-License-Identifier: LGPL-2.1-or-later
  6. */
  7. #include "defs.h"
  8. #include DEF_MPERS_TYPE(struct_sock_fprog)
  9. #include <linux/filter.h>
  10. typedef struct sock_fprog struct_sock_fprog;
  11. #include MPERS_DEFS
  12. #include "bpf_fprog.h"
  13. MPERS_PRINTER_DECL(unsigned int, get_sock_fprog_size, void)
  14. {
  15. return sizeof(struct_sock_fprog);
  16. }
  17. MPERS_PRINTER_DECL(bool, fetch_bpf_fprog, struct tcb *const tcp,
  18. const kernel_ulong_t addr, void *const p)
  19. {
  20. struct bpf_fprog *pfp = p;
  21. struct_sock_fprog mfp;
  22. if ((sizeof(*pfp) == sizeof(mfp))
  23. && (offsetof(struct bpf_fprog, filter) ==
  24. offsetof(struct_sock_fprog, filter)))
  25. return !umove_or_printaddr(tcp, addr, pfp);
  26. if (umove_or_printaddr(tcp, addr, &mfp))
  27. return false;
  28. pfp->len = mfp.len;
  29. pfp->filter =
  30. #ifndef IN_MPERS
  31. (uintptr_t)
  32. #endif
  33. mfp.filter;
  34. return true;
  35. }