lkml.org 
[lkml]   [2019]   [Dec]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [BUG] kernel: kcov: a possible sleep-in-atomic-context bug in kcov_ioctl()
From
Date


On 2019/12/17 21:02, Dmitry Vyukov wrote:
> On Tue, Dec 17, 2019 at 1:56 PM Jia-Ju Bai <baijiaju1990@gmail.com> wrote:
>> 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.
> Hi Jia-Ju,
>
> Are you sure kcov_ioctl_locked can really release the descriptor? It
> happens in the context of ioctl, which means there is an open
> reference for the file descriptor. So ioctl should not do vfree I
> would assume.

Thanks for the reply :)
I am not sure, because I am not familiar with kcov.
But looking at the code, if the reference count of kcov is 1, vfree()
could be called.


Best wishes,
Jia-Ju Bai

\
 
 \ /
  Last update: 2019-12-17 14:12    [W:0.039 / U:2.448 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site