lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240604105456.1668-1-hdanton@sina.com>
Date: Tue,  4 Jun 2024 18:54:56 +0800
From: Hillf Danton <hdanton@...a.com>
To: Leon Romanovsky <leon@...nel.org>
Cc: Tejun Heo <tj@...nel.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Lai Jiangshan <jiangshanlai@...il.com>,
	Zqiang <qiang.zhang1211@...il.com>,
	linux-kernel@...r.kernel.org,
	Gal Pressman <gal@...dia.com>,
	Tariq Toukan <tariqt@...dia.com>,
	RDMA mailing list <linux-rdma@...r.kernel.org>
Subject: Re: [PATCH -rc] workqueue: Reimplement UAF fix to avoid lockdep worning

On Tue, 4 Jun 2024 11:09:58 +0300 Leon Romanovsky <leon@...nel.org>
> On Mon, Jun 03, 2024 at 10:10:36AM -1000, Tejun Heo wrote:
> > 
> > And KASAN is reporting use-after-free on a completely unrelated VFS object.
> > I can't tell for sure from the logs alone but lockdep_register_key()
> > iterates entries in the hashtable trying to find whether the key is a
> > duplicate and it could be that that walk is triggering the use-after-free
> > warning. If so, it doesn't really have much to do with workqueue. The
> > corruption happened elsewhere and workqueue just happens to traverse the
> > hashtable afterwards.
> 
> The problem is that revert of commit 643445531829
> ("workqueue: Fix UAF report by KASAN in pwq_release_workfn()")
> fixed these use-after-free reports.
> 
Given revert makes sense,

	if (alloc_and_link_pwqs(wq) < 0)
		goto err_unreg_lockdep;

err_unreg_lockdep:
	wq_unregister_lockdep(wq);
	wq_free_lockdep(wq);
err_free_wq:
	free_workqueue_attrs(wq->unbound_attrs);
	kfree(wq);	<-- freed
	return NULL;

the difference 643445531829 makes is double free.

	alloc_and_link_pwqs(struct workqueue_struct *wq)
	if (ret)
		kthread_flush_worker(pwq_release_worker);
		  pwq_release_workfn()
		  if (is_last) {
			wq_unregister_lockdep(wq);
			call_rcu(&wq->rcu, rcu_free_wq); <-- freed again
		  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ