|
78 | 78 | int trace_inbound_message(struct pt_regs *ctx) {
|
79 | 79 | int idx = 0;
|
80 | 80 | struct p2p_message *msg = msg_arr.lookup(&idx);
|
| 81 | + void *paddr = NULL, *pconn_type = NULL, *pmsg_type = NULL, *pmsg = NULL; |
81 | 82 |
|
82 | 83 | // lookup() does not return a NULL pointer. However, the BPF verifier
|
83 | 84 | // requires an explicit check that that the `msg` pointer isn't a NULL
|
84 | 85 | // pointer. See https://github.com/iovisor/bcc/issues/2595
|
85 | 86 | if (msg == NULL) return 1;
|
86 | 87 |
|
87 | 88 | bpf_usdt_readarg(1, ctx, &msg->peer_id);
|
88 |
| - bpf_usdt_readarg_p(2, ctx, &msg->peer_addr, MAX_PEER_ADDR_LENGTH); |
89 |
| - bpf_usdt_readarg_p(3, ctx, &msg->peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH); |
90 |
| - bpf_usdt_readarg_p(4, ctx, &msg->msg_type, MAX_MSG_TYPE_LENGTH); |
| 89 | + bpf_usdt_readarg(2, ctx, &paddr); |
| 90 | + bpf_probe_read_user_str(&msg->peer_addr, sizeof(msg->peer_addr), paddr); |
| 91 | + bpf_usdt_readarg(3, ctx, &pconn_type); |
| 92 | + bpf_probe_read_user_str(&msg->peer_conn_type, sizeof(msg->peer_conn_type), pconn_type); |
| 93 | + bpf_usdt_readarg(4, ctx, &pmsg_type); |
| 94 | + bpf_probe_read_user_str(&msg->msg_type, sizeof(msg->msg_type), pmsg_type); |
91 | 95 | bpf_usdt_readarg(5, ctx, &msg->msg_size);
|
92 |
| - bpf_usdt_readarg_p(6, ctx, &msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH)); |
| 96 | + bpf_usdt_readarg(6, ctx, &pmsg); |
| 97 | + bpf_probe_read_user(&msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH), pmsg); |
93 | 98 |
|
94 | 99 | inbound_messages.perf_submit(ctx, msg, sizeof(*msg));
|
95 | 100 | return 0;
|
|
99 | 104 | int idx = 0;
|
100 | 105 | struct p2p_message *msg = msg_arr.lookup(&idx);
|
101 | 106 |
|
| 107 | + void *paddr = NULL, *pconn_type = NULL, *pmsg_type = NULL, *pmsg = NULL; |
| 108 | +
|
102 | 109 | // lookup() does not return a NULL pointer. However, the BPF verifier
|
103 | 110 | // requires an explicit check that that the `msg` pointer isn't a NULL
|
104 | 111 | // pointer. See https://github.com/iovisor/bcc/issues/2595
|
105 | 112 | if (msg == NULL) return 1;
|
106 | 113 |
|
107 | 114 | bpf_usdt_readarg(1, ctx, &msg->peer_id);
|
108 |
| - bpf_usdt_readarg_p(2, ctx, &msg->peer_addr, MAX_PEER_ADDR_LENGTH); |
109 |
| - bpf_usdt_readarg_p(3, ctx, &msg->peer_conn_type, MAX_PEER_CONN_TYPE_LENGTH); |
110 |
| - bpf_usdt_readarg_p(4, ctx, &msg->msg_type, MAX_MSG_TYPE_LENGTH); |
| 115 | + bpf_usdt_readarg(2, ctx, &paddr); |
| 116 | + bpf_probe_read_user_str(&msg->peer_addr, sizeof(msg->peer_addr), paddr); |
| 117 | + bpf_usdt_readarg(3, ctx, &pconn_type); |
| 118 | + bpf_probe_read_user_str(&msg->peer_conn_type, sizeof(msg->peer_conn_type), pconn_type); |
| 119 | + bpf_usdt_readarg(4, ctx, &pmsg_type); |
| 120 | + bpf_probe_read_user_str(&msg->msg_type, sizeof(msg->msg_type), pmsg_type); |
111 | 121 | bpf_usdt_readarg(5, ctx, &msg->msg_size);
|
112 |
| - bpf_usdt_readarg_p(6, ctx, &msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH)); |
| 122 | + bpf_usdt_readarg(6, ctx, &pmsg); |
| 123 | + bpf_probe_read_user(&msg->msg, _TRACEPOINT_TEST_MIN(msg->msg_size, MAX_MSG_DATA_LENGTH), pmsg); |
113 | 124 |
|
114 | 125 | outbound_messages.perf_submit(ctx, msg, sizeof(*msg));
|
115 | 126 | return 0;
|
|
0 commit comments