mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] kernel: kcov: a possible sleep-in-atomic-context bug in kcov_ioctl()
@ 2018-06-21  3:20 Jia-Ju Bai
  2018-06-21  3:43 ` Al Viro
  0 siblings, 1 reply; 8+ messages in thread
From: Jia-Ju Bai @ 2018-06-21  3:20 UTC (permalink / raw)
  To: akpm, dvyukov, Greg KH, tchibo, aryabinin; +Cc: Linux Kernel Mailing List

The kernel may sleep with holding a spinlock.
The function call path (from bottom to top) in Linux-4.16.7 is:

[FUNC] vfree --> can sleep
kernel/kcov.c, 237: vfree in kcov_put
kernel/kcov.c, 396: kcov_put in kcov_ioctl_locked
kernel/kcov.c, 410: kcov_ioctl_locked in kcov_ioctl
kernel/kcov.c, 409: spin_lock in kcov_ioctl

This bug is found by my static analysis tool (DSAC-2) and checked by my
code review.

I do not know how to correctly fix this bug, so I just report them.


Best wishes,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] 8+ messages in thread
* [BUG] kernel: kcov: a possible sleep-in-atomic-context bug in kcov_ioctl()
@ 2019-12-17 12:56 Jia-Ju Bai
  2019-12-17 13:02 ` Dmitry Vyukov
  0 siblings, 1 reply; 8+ messages in thread
From: Jia-Ju Bai @ 2019-12-17 12:56 UTC (permalink / raw)
  To: akpm, ishkamiel, rostedt, dvyukov, andrea.parri, anders.roxell,
	Greg Kroah-Hartman, elena.reshetova, andreyknvl
  Cc: linux-kernel

The kernel may sleep while holding a spinlock.
The function call path (from bottom to top) in Linux 4.19 is:

kernel/kcov.c, 237:
     vfree in kcov_put
kernel/kcov.c, 413:
     kcov_put in kcov_ioctl_locked
kernel/kcov.c, 427:
     kcov_ioctl_locked in kcov_ioctl
kernel/kcov.c, 426:
     spin_lock in kcov_ioctl

vfree() can sleep at runtime.

I am not sure how to properly fix this possible bug, so I only report it.
A possible way is to replace vfree() with kfree(), and replace related 
calls to vmalloc() with kmalloc().

This bug is found by a static analysis tool STCheck written by myself.


Best wishes,
Jia-Ju Bai

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-12-17 13:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-21  3:20 [BUG] kernel: kcov: a possible sleep-in-atomic-context bug in kcov_ioctl() Jia-Ju Bai
2018-06-21  3:43 ` Al Viro
2018-06-21  3:50   ` Jia-Ju Bai
2019-12-17 12:56 Jia-Ju Bai
2019-12-17 13:02 ` Dmitry Vyukov
2019-12-17 13:11   ` Jia-Ju Bai
2019-12-17 13:13     ` Dmitry Vyukov
2019-12-17 13:17       ` Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome