Skip to content

kcov: collect coverage from usb soft interrupts

Andrey Konovalov linux-usb lkml 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest7 patches 8 repliesIn review 6 of 7 applied
  2. v37 patches 0 repliesSuperseded 1 of 7 applied
  3. v23 patches 2 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v13 patches2 repliesSuperseded

Changes in v4 from the cover letter

- Turn current->kcov_softirq into unsigned int to fix objtool warning.
- Fix commit author email address.

Patches in v4 6 of 7 applied

#Subject and filesSizeRepliesApplied
1/7kcov: cleanup debug messageskernel/kcov.c+2 -201 reply
2/7kcov: fix potential use-after-free in kcov_remote_startkernel/kcov.c+8 -61 replyApplied
3/7kcov: move t->kcov assignments into kcov_start/stopkernel/kcov.c+7 -91 replyApplied
4/7kcov: move t->kcov_sequence assignmentkernel/kcov.c+1 -11 replyApplied
5/7kcov: use t->kcov_mode as enabled indicatorkernel/kcov.c+23 -91 replyApplied
6/7kcov: collect coverage from interruptsDocumentation/dev-tools/kcov.rst include/linux/sched.h kernel/kcov.c +1 more+176 -471 replyApplied
7/7usb: core: kcov: collect coverage from usb complete callbackdrivers/usb/core/hcd.c+3 -01 replyApplied

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by.

PatchDmitry Vyukov
1/7R-b
2/7R-b
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/7] kcov: collect coverage from usb soft interrupts

This patchset extends kcov to allow collecting coverage from soft interrupts and then uses the new functionality to collect coverage from USB code.

Any subsystem that uses softirqs (e.g. timers) can make use of this in the future. Looking at the recent syzbot reports, an obvious candidate is the networking subsystem [1, 2, 3 and many more].

[1] https://syzkaller.appspot.com/bug?extid=522ab502c69badc66ab7
[2] https://syzkaller.appspot.com/bug?extid=57f89d05946c53dbbb31
[3] https://syzkaller.appspot.com/bug?extid=df358e65d9c1b9d3f5f4

This patchset has been pushed to the public Linux kernel Gerrit instance:

https://linux-review.googlesource.com/c/linux/kernel/git/torvalds/linux/+/2225

Changes v3 -> v4:
- Turn current->kcov_softirq into unsigned int to fix objtool warning.
- Fix commit author email address.

Changes v2 -> v3:
- New patch: "kcov: fix potential use-after-free in kcov_remote_start".
- New patch: "kcov: move t->kcov assignments into kcov_start/stop".
- New patch: "kcov: move t->kcov_sequence assignment".
- New patch: "kcov: use t->kcov_mode as enabled indicator".
- Dropped out-of-memory error message from kcov_init() as checkpatch complains.
- Use a single local_irq_disable section when accessing per-task kcov variables in kcov_remote_start/stop().

Changes v1 -> v2:
- Add local_irq_save/restore() critical sections to simplify dealing with softirqs happening during kcov_remote_start/stop().
- Set kcov_softirq after flag kcov_start() in kcov_remote_start().

Changes RFC -> v1:
- Don't support hardirq or nmi, only softirq, to avoid issues with nested interrupts.
- Combined multiple per-cpu variables into one.
- Used plain accesses and kcov_start/stop() instead of xchg()'s.
- Simplified handling of per-cpu variables.
- Avoid disabling interrupts for the whole kcov_remote_start/stop() region.
- Avoid overwriting t->kcov_sequence when saving/restoring state.
- Move kcov_remote_start/stop_usb() annotations into __usb_hcd_giveback_urb() to cover all urb complete() callbacks at once.
- Drop unneeded Dummy HCD changes.
- Split out a patch that removed debug messages.

Andrey Konovalov (7):
kcov: cleanup debug messages
kcov: fix potential use-after-free in kcov_remote_start
kcov: move t->kcov assignments into kcov_start/stop
kcov: move t->kcov_sequence assignment
kcov: use t->kcov_mode as enabled indicator
kcov: collect coverage from interrupts
usb: core: kcov: collect coverage from usb complete callback

 Documentation/dev-tools/kcov.rst |  17 +-
 drivers/usb/core/hcd.c           |   3 +
 include/linux/sched.h            |   3 +
 kernel/kcov.c                    | 266 ++++++++++++++++++++++---------
 lib/Kconfig.debug                |   9 ++
 5 files changed, 213 insertions(+), 85 deletions(-)
Signature · 1 line
2.26.0.rc2.310.g2932bb562d-goog