[PATCH v3 5/6] pidfd_getfd: fix decoder
Ákos Uzonyi
uzonyi.akos at gmail.com
Sun May 24 10:41:37 UTC 2020
The decoder incorrectly assumed the first argument being a pid,
but actually it is a pidfd.
The patch also makes the decoder be able to decode the targetfd
(-y and -yy options).
* pidfd_getfd.c: fix decoder
Fixes: v5.6~46 "Implement pidfd_getfd syscall decoding"
Signed-off-by: Ákos Uzonyi <uzonyi.akos at gmail.com>
---
pidfd_getfd.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/pidfd_getfd.c b/pidfd_getfd.c
index 8461b8f4..dc263e27 100644
--- a/pidfd_getfd.c
+++ b/pidfd_getfd.c
@@ -8,16 +8,24 @@
*/
#include "defs.h"
+#include "number_set.h"
SYS_FUNC(pidfd_getfd)
{
- /* int pidfd */
- printfd(tcp, (int) tcp->u_arg[0]);
- /* int fd */
+ int pidfd = (int) tcp->u_arg[0];
+ int targetfd = (int) tcp->u_arg[1];
+ unsigned int flags = (unsigned int) tcp->u_arg[2];
+
+ printfd(tcp, pidfd);
tprints(", ");
- printfd_pid_tracee_ns(tcp, (int) tcp->u_arg[0], (int) tcp->u_arg[1]);
- /* unsigned int flags */
- tprintf(", %#x", (unsigned int) tcp->u_arg[2]);
+
+ pid_t target_pid = pidfd_get_pid(tcp->pid, pidfd);
+ if (target_pid > 0)
+ printfd_pid(tcp, target_pid, targetfd);
+ else
+ tprintf("%d", targetfd);
+
+ tprintf(", %#x", flags);
return RVAL_DECODED | RVAL_FD;
}
--
2.26.2
More information about the Strace-devel
mailing list