mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
test: don't use bpf_usdt_readarg_p
Instead of using the undocumented bcc helper bpf_usdt_readarg_p(),
use bpf_usdt_readarg() [1] and bpf_probe_read_user{_str}() [2, 3] as
documented in the bcc USDT reference guide [1].
Note that the bpf_probe_read_user() documentation says the following:
> For safety, all user address space memory reads must pass through bpf_probe_read_user().
It's assumed that using bpf_usdt_readarg_p() caused a lifetime issue.
See https://github.com/bitcoin/bitcoin/issues/27380#issuecomment-2286505348
With bpf_usdt_readarg() and bpf_probe_read_user(), this doesn't seem
to be a problem anymore. See https://github.com/bitcoin/bitcoin/issues/27380#issuecomment-2528671656
[1]: https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#6-usdt-probes
[2]: https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#10-bpf_probe_read_user
[3]: https://github.com/iovisor/bcc/blob/master/docs/reference_guide.md#11-bpf_probe_read_user_str
This commit is contained in:
@@ -35,7 +35,9 @@ struct utxocache_change
|
||||
BPF_PERF_OUTPUT(utxocache_add);
|
||||
int trace_utxocache_add(struct pt_regs *ctx) {
|
||||
struct utxocache_change add = {};
|
||||
bpf_usdt_readarg_p(1, ctx, &add.txid, 32);
|
||||
void *ptxid = NULL;
|
||||
bpf_usdt_readarg(1, ctx, &ptxid);
|
||||
bpf_probe_read_user(&add.txid, sizeof(add.txid), ptxid);
|
||||
bpf_usdt_readarg(2, ctx, &add.index);
|
||||
bpf_usdt_readarg(3, ctx, &add.height);
|
||||
bpf_usdt_readarg(4, ctx, &add.value);
|
||||
@@ -47,7 +49,9 @@ int trace_utxocache_add(struct pt_regs *ctx) {
|
||||
BPF_PERF_OUTPUT(utxocache_spent);
|
||||
int trace_utxocache_spent(struct pt_regs *ctx) {
|
||||
struct utxocache_change spent = {};
|
||||
bpf_usdt_readarg_p(1, ctx, &spent.txid, 32);
|
||||
void *ptxid = NULL;
|
||||
bpf_usdt_readarg(1, ctx, &ptxid);
|
||||
bpf_probe_read_user(&spent.txid, sizeof(spent.txid), ptxid);
|
||||
bpf_usdt_readarg(2, ctx, &spent.index);
|
||||
bpf_usdt_readarg(3, ctx, &spent.height);
|
||||
bpf_usdt_readarg(4, ctx, &spent.value);
|
||||
@@ -59,7 +63,9 @@ int trace_utxocache_spent(struct pt_regs *ctx) {
|
||||
BPF_PERF_OUTPUT(utxocache_uncache);
|
||||
int trace_utxocache_uncache(struct pt_regs *ctx) {
|
||||
struct utxocache_change uncache = {};
|
||||
bpf_usdt_readarg_p(1, ctx, &uncache.txid, 32);
|
||||
void *ptxid = NULL;
|
||||
bpf_usdt_readarg(1, ctx, &ptxid);
|
||||
bpf_probe_read_user(&uncache.txid, sizeof(uncache.txid), ptxid);
|
||||
bpf_usdt_readarg(2, ctx, &uncache.index);
|
||||
bpf_usdt_readarg(3, ctx, &uncache.height);
|
||||
bpf_usdt_readarg(4, ctx, &uncache.value);
|
||||
|
||||
Reference in New Issue
Block a user