From: Tejun Heo <tj@kernel.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] workqueue: fix null-ptr-deref on __alloc_workqueue() error
Date: Wed, 21 Aug 2024 06:14:03 -1000 [thread overview]
Message-ID: <ZsYSS6FXFNi9W5Wx@slm.duckdns.org> (raw)
In-Reply-To: <20240815070339.346160-1-senozhatsky@chromium.org>
On Thu, Aug 15, 2024 at 04:02:58PM +0900, Sergey Senozhatsky wrote:
> wq->lockdep_map is set only after __alloc_workqueue()
> successfully returns. However, on its error path
> __alloc_workqueue() may call destroy_workqueue() which
> expects wq->lockdep_map to be already set, which results
> in a null-ptr-deref in touch_wq_lockdep_map().
>
> Add a simple NULL-check to touch_wq_lockdep_map().
>
> Oops: general protection fault, probably for non-canonical address
> KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
> RIP: 0010:__lock_acquire+0x81/0x7800
> [..]
> Call Trace:
> <TASK>
> ? __die_body+0x66/0xb0
> ? die_addr+0xb2/0xe0
> ? exc_general_protection+0x300/0x470
> ? asm_exc_general_protection+0x22/0x30
> ? __lock_acquire+0x81/0x7800
> ? mark_lock+0x94/0x330
> ? __lock_acquire+0x12fd/0x7800
> ? __lock_acquire+0x3439/0x7800
> lock_acquire+0x14c/0x3e0
> ? __flush_workqueue+0x167/0x13a0
> ? __init_swait_queue_head+0xaf/0x150
> ? __flush_workqueue+0x167/0x13a0
> __flush_workqueue+0x17d/0x13a0
> ? __flush_workqueue+0x167/0x13a0
> ? lock_release+0x50f/0x830
> ? drain_workqueue+0x94/0x300
> drain_workqueue+0xe3/0x300
> destroy_workqueue+0xac/0xc40
> ? workqueue_sysfs_register+0x159/0x2f0
> __alloc_workqueue+0x1506/0x1760
> alloc_workqueue+0x61/0x150
> ...
>
> Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Applied to wq/for-6.12.
Thanks.
--
tejun
prev parent reply other threads:[~2024-08-21 16:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 7:02 [PATCH] workqueue: fix null-ptr-deref on __alloc_workqueue() error Sergey Senozhatsky
2024-08-15 7:09 ` Sergey Senozhatsky
2024-08-15 7:24 ` Sergey Senozhatsky
2024-08-15 15:56 ` Matthew Brost
2024-08-15 16:24 ` Matthew Brost
2024-08-16 2:38 ` Sergey Senozhatsky
2024-08-16 2:45 ` Matthew Brost
2024-08-16 2:52 ` Sergey Senozhatsky
2024-08-19 21:15 ` Tejun Heo
2024-08-19 23:57 ` Matthew Brost
2024-08-20 23:54 ` Sergey Senozhatsky
2024-08-20 23:56 ` Matthew Brost
2024-08-21 0:07 ` Sergey Senozhatsky
2024-08-21 0:04 ` Tejun Heo
2024-08-21 0:09 ` Sergey Senozhatsky
2024-08-21 16:14 ` Tejun Heo [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=ZsYSS6FXFNi9W5Wx@slm.duckdns.org \
--to=tj@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=senozhatsky@chromium.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