Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tools/lib/uobjnew.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
#
elif language == "java":
program += """
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
int alloc_entry(struct pt_regs *ctx) {
struct key_t key = {};
struct val_t *valp, zero = {};
Expand All @@ -100,7 +103,7 @@
bpf_usdt_readarg(2, ctx, &classptr);
bpf_usdt_readarg(3, ctx, &length);
bpf_usdt_readarg(4, ctx, &size);
bpf_probe_read_user(&key.name, min(sizeof(key.name), (size_t)length), (void *)classptr);
bpf_probe_read_user(&key.name, MIN(sizeof(key.name), (size_t)length), (void *)classptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the content stored in key.name is confirmed to be a NUL-terminated string, would it be possible to replace bpf_probe_read_user with bpf_probe_read_user_str (without the MIN macro)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about this one: searching for the object__alloc usdt probe returns surprisingly few results.

Using bpf_probe_read_user_str() seems to work.

valp = allocs.lookup_or_try_init(&key, &zero);
if (valp) {
valp->total_size += size;
Expand Down
Loading