diff options
author | Eugene Syromyatnikov <evgsyr@gmail.com> | 2022-05-25 17:26:39 +0200 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2022-05-26 23:10:47 +0000 |
commit | aaf546cafad9e5c7c85206538b738f9a12d6a034 (patch) | |
tree | bb9f54c133d4e29a9a5b902036086899921fb9e4 | |
parent | fae3a3641cbf2c50bea05d9d798cad7d027f779d (diff) | |
download | strace-aaf546cafad9e5c7c85206538b738f9a12d6a034.tar.gz |
bpf: fix next_id decoding for BPF_*_GET_NEXT_ID
It is an R/W attribute and is supposed to be handled as such.
* src/bpf.c (BEGIN_BPF_CMD_DECODER(BPF_PROG_GET_NEXT_ID)): Store next_id
field value on entering, print the new value (if it has been modified)
on exiting.
* NEWS: Mention it.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/bpf.c | 21 |
2 files changed, 19 insertions, 4 deletions
@@ -11,6 +11,8 @@ Noteworthy changes in release ?.?? (????-??-??) * Updated lists of ioctl commands from Linux 5.18. * Bug fixes + * Fixed printing of the updated value of union bpf_attr.next_id + on the exiting of bpf(BPF_*_GET_NEXT_ID) calls. Noteworthy changes in release 5.17 (2022-03-26) =============================================== @@ -537,10 +537,23 @@ END_BPF_CMD_DECODER(RVAL_DECODED) BEGIN_BPF_CMD_DECODER(BPF_PROG_GET_NEXT_ID) { - tprint_struct_begin(); - PRINT_FIELD_U(attr, start_id); - tprint_struct_next(); - PRINT_FIELD_U(attr, next_id); + if (entering(tcp)) { + set_tcb_priv_ulong(tcp, attr.next_id); + + tprint_struct_begin(); + PRINT_FIELD_U(attr, start_id); + tprint_struct_next(); + PRINT_FIELD_U(attr, next_id); + + return 0; + } + + uint32_t saved_next_id = get_tcb_priv_ulong(tcp); + + if (saved_next_id != attr.next_id) { + tprint_value_changed(); + PRINT_VAL_U(attr.next_id); + } /* open_flags field has been added in Linux v4.15-rc1~84^2~384^2~4 */ if (len <= offsetof(struct BPF_PROG_GET_NEXT_ID_struct, open_flags)) |