Skip to content

Commit

Permalink
drgn.helpers.linux.printk: handle log_buf name conflict between v3.18…
Browse files Browse the repository at this point in the history
… and v4.15

In a few kernel versions with structured printk, printk and the BPF
verifier both had static global variables named log_buf.
get_printk_records() doesn't handle this. We never hit this before with
the old DWARF index, but the rework exposed this for some reason. Pass
the filename so we always get the right one.

Fixes: ba51e88 ("helpers: add get_printk_records()")
Signed-off-by: Omar Sandoval <[email protected]>
  • Loading branch information
osandov committed Aug 17, 2023
1 parent bc85145 commit 7ac5007
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion drgn/helpers/linux/printk.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ def _get_printk_records_structured(prog: Program) -> List[PrintkRecord]:
LOG_CONT = prog["LOG_CONT"].value_()

result = []
log_buf = prog["log_buf"].read_()
# Between Linux kernel commits cbd357008604 ("bpf: verifier (add ability to
# receive verification log)") (in v3.18) and e7bf8249e8f1 ("bpf:
# encapsulate verifier log state into a structure") (in v4.15),
# kernel/bpf/verifier.c also contains a variable named log_buf.
log_buf = prog.object("log_buf", filename="printk.c").read_()
current_idx = prog["log_first_idx"].read_()
next_idx = prog["log_next_idx"].read_()
seq = prog["log_first_seq"].value_()
Expand Down

0 comments on commit 7ac5007

Please sign in to comment.