From: Tejun Heo <tj@kernel.org>
To: Zqiang <qiang.zhang1211@gmail.com>
Cc: jiangshanlai@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] workqueue: Fix UAF report by KASAN in pwq_release_workfn()
Date: Tue, 5 Sep 2023 08:51:52 -1000 [thread overview]
Message-ID: <ZPd4yKqbvBNGV7cL@slm.duckdns.org> (raw)
In-Reply-To: <20230902115026.13460-1-qiang.zhang1211@gmail.com>
Hello,
On Sat, Sep 02, 2023 at 07:50:26PM +0800, Zqiang wrote:
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index c85825e17df8..f3f9c9222070 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -4609,6 +4609,10 @@ static int alloc_and_link_pwqs(struct workqueue_struct *wq)
> free_percpu(wq->cpu_pwq);
> wq->cpu_pwq = NULL;
> }
> + wq_unregister_lockdep(wq);
> + wq_free_lockdep(wq);
> + free_workqueue_attrs(wq->unbound_attrs);
> + kfree(wq);
So, this would fix the bug but it's quite confusing because we end up taking
two separate error handling paths and alloc_and_link_pwqs() ends up freeing
stuff allocated outside the function. Wouldn't it be enough to flush the
pwq_release_worker after apply_workqueue_attrs() failure so that the cleanup
operation ordering is maintained?
Thanks.
--
tejun
next prev parent reply other threads:[~2023-09-05 18:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-02 11:50 [PATCH] workqueue: Fix UAF report by KASAN in pwq_release_workfn() Zqiang
2023-09-05 18:51 ` Tejun Heo [this message]
2023-09-06 2:12 ` Z qiang
2023-09-06 17:01 ` Tejun Heo
2023-09-07 2:13 ` Z qiang
2023-09-18 9:18 ` Z qiang
2023-09-18 18:06 ` Tejun Heo
2023-09-19 2:14 ` Z qiang
2023-12-08 7:32 ` Xuewen Yan
2023-12-08 8:18 ` Z qiang
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=ZPd4yKqbvBNGV7cL@slm.duckdns.org \
--to=tj@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=qiang.zhang1211@gmail.com \
/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