Skip to content

Commit b8418e0

Browse files
Pu LehuiKernel Patches Daemon
Pu Lehui
authored and
Kernel Patches Daemon
committed
libbpf: Fix usdt_cookie being cast to 32 bits
The usdt_cookie is defined as __u64, which should not be used as a long type because it will be cast to 32 bits in 32-bit platforms. Signed-off-by: Pu Lehui <[email protected]>
1 parent 36dce57 commit b8418e0

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10982,7 +10982,7 @@ struct bpf_link *bpf_program__attach_usdt(const struct bpf_program *prog,
1098210982
char resolved_path[512];
1098310983
struct bpf_object *obj = prog->obj;
1098410984
struct bpf_link *link;
10985-
long usdt_cookie;
10985+
__u64 usdt_cookie;
1098610986
int err;
1098710987

1098810988
if (!OPTS_VALID(opts, bpf_uprobe_opts))

tools/lib/bpf/libbpf_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,6 @@ struct bpf_link * usdt_manager_attach_usdt(struct usdt_manager *man,
571571
const struct bpf_program *prog,
572572
pid_t pid, const char *path,
573573
const char *usdt_provider, const char *usdt_name,
574-
long usdt_cookie);
574+
__u64 usdt_cookie);
575575

576576
#endif /* __LIBBPF_LIBBPF_INTERNAL_H */

tools/lib/bpf/usdt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,10 @@ static int parse_usdt_note(Elf *elf, const char *path, long base_addr,
557557
GElf_Nhdr *nhdr, const char *data, size_t name_off, size_t desc_off,
558558
struct usdt_note *usdt_note);
559559

560-
static int parse_usdt_spec(struct usdt_spec *spec, const struct usdt_note *note, long usdt_cookie);
560+
static int parse_usdt_spec(struct usdt_spec *spec, const struct usdt_note *note, __u64 usdt_cookie);
561561

562562
static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *path, pid_t pid,
563-
const char *usdt_provider, const char *usdt_name, long usdt_cookie,
563+
const char *usdt_provider, const char *usdt_name, __u64 usdt_cookie,
564564
struct usdt_target **out_targets, size_t *out_target_cnt)
565565
{
566566
size_t off, name_off, desc_off, seg_cnt = 0, lib_seg_cnt = 0, target_cnt = 0;
@@ -939,7 +939,7 @@ static int allocate_spec_id(struct usdt_manager *man, struct hashmap *specs_hash
939939
struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct bpf_program *prog,
940940
pid_t pid, const char *path,
941941
const char *usdt_provider, const char *usdt_name,
942-
long usdt_cookie)
942+
__u64 usdt_cookie)
943943
{
944944
int i, fd, err, spec_map_fd, ip_map_fd;
945945
LIBBPF_OPTS(bpf_uprobe_opts, opts);
@@ -1141,7 +1141,7 @@ static int parse_usdt_note(Elf *elf, const char *path, long base_addr,
11411141

11421142
static int parse_usdt_arg(const char *arg_str, int arg_num, struct usdt_arg_spec *arg);
11431143

1144-
static int parse_usdt_spec(struct usdt_spec *spec, const struct usdt_note *note, long usdt_cookie)
1144+
static int parse_usdt_spec(struct usdt_spec *spec, const struct usdt_note *note, __u64 usdt_cookie)
11451145
{
11461146
const char *s;
11471147
int len;

0 commit comments

Comments
 (0)