From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Bart Van Assche <bvanassche@acm.org>,
Ingo Molnar <mingo@kernel.org>, Tejun Heo <tj@kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: <syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com>
Subject: Re: [PATCH] workqueue: unregister wq lockdep on error path in alloc_workqueue()
Date: Sat, 9 Mar 2019 12:13:30 +0800 [thread overview]
Message-ID: <9fb0213e-efc2-ec7f-b257-d0c851e67025@huawei.com> (raw)
In-Reply-To: <150578a7-f053-a479-2b1a-34279c93fc4b@acm.org>
On 2019/3/8 22:45, Bart Van Assche wrote:
> On 3/7/19 11:37 PM, Kefeng Wang wrote:
>> syzkaller report an issue "KASAN: use-after-free Read in alloc_workqueue",
>>
>> alloc_workqueue
>> - kzalloc wq
>> - wq_init_lockdep(wq);
>> - lockdep_register_key(&wq->key); // add to hlist
>> - kfree wq
>>
>> But forget to call wq_unregister_lockdep()->lockdep_unregister_key(), it
>> will delete the entry from hlist.
>>
>> Reported-by: syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com
>> Fixes: 669de8bda87b ("kernel/workqueue: Use dynamic lockdep keys for workqueues")
>> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
>> ---
>> kernel/workqueue.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
>> index 7abbeed13421..9209d25dfade 100644
>> --- a/kernel/workqueue.c
>> +++ b/kernel/workqueue.c
>> @@ -4291,6 +4291,7 @@ struct workqueue_struct *alloc_workqueue(const char *fmt,
>> return wq;
>> err_free_wq:
>> + wq_unregister_lockdep(wq);
>> free_workqueue_attrs(wq->unbound_attrs);
>> kfree(wq);
>> return NULL;
>
> Hi Kefeng,
>
> Five days ago I had posted a similar but slightly different patch. Can you have a look at it? See also https://lore.kernel.org/lkml/20190303220046.29448-1-bvanassche@acm.org/
I don't notice your patch due to no subscribe lkml, that is better, wq->lock_name should be freed too; )
>
> Thanks,
>
> Bart.
>
>
>
> .
>
prev parent reply other threads:[~2019-03-09 4:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 7:37 Kefeng Wang
2019-03-08 14:45 ` Bart Van Assche
2019-03-09 4:13 ` Kefeng Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9fb0213e-efc2-ec7f-b257-d0c851e67025@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=bvanassche@acm.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=syzbot+17335689e239ce135d8b@syzkaller.appspotmail.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®