Skip to content

Commit

Permalink
libbpf-tools: fix ksnoop panic
Browse files Browse the repository at this point in the history
Running ksnoop with an invalid func will cause
panic, testing with glibc 2.35.

Error:
```
$ ./ksnoop info xxx
Error: [1]    41304 segmentation fault (core dumped)  ./ksnoop info xxx
```

Fixed by changing format string to %s.

Signed-off-by: Chen Yaqi <[email protected]>
  • Loading branch information
chendotjs authored and yonghong-song committed Jul 12, 2022
1 parent ca03af7 commit 4ce27d4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libbpf-tools/ksnoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ static int get_func_ip_mod(struct func *func)
f = fopen("/proc/kallsyms", "r");
if (!f) {
err = errno;
p_err("failed to open /proc/kallsyms: %d", strerror(err));
p_err("failed to open /proc/kallsyms: %s", strerror(err));
return err;
}

Expand Down Expand Up @@ -563,7 +563,7 @@ static int parse_trace(char *str, struct trace *trace)
trace->dump = btf_dump__new(trace->btf, NULL, &opts, trace_printf);
if (!trace->dump) {
ret = -errno;
p_err("could not create BTF dump : %n", strerror(-ret));
p_err("could not create BTF dump : %s", strerror(-ret));
return -EINVAL;
}

Expand Down

0 comments on commit 4ce27d4

Please sign in to comment.