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>] [day] [month] [year] [list]
Date:   Wed, 3 Apr 2019 14:55:31 +0100
From:   Charles Keepax <ckeepax@...nsource.cirrus.com>
To:     <broonie@...nel.org>, <digetx@...il.com>, <l.stach@...gutronix.de>
CC:     <lgirdwood@...il.com>, <linux-kernel@...r.kernel.org>
Subject: Regulator Potential Deadlock

Hi Guys,

Was testing some of my hardware and hit this potential lockup:

Possible unsafe locking scenario:

CPU0                    CPU1
----                    ----
lock((work_completion)(&(&rdev->disable_work)->work));
                        lock(regulator_list_mutex);
                        lock((work_completion)(&(&rdev->disable_work)->work));
lock(regulator_list_mutex);

***
DEADLOCK
***

Looks like it comes from this patch:

commit f8702f9e4aa7 ("regulator: core: Use ww_mutex for regulators locking")

The basic problem appears to be that regulator_unregister takes
the regulator_list_mutex and then calls flush_work on
disable_work. But regulator_disable_work calls
regulator_lock_dependent which will also take the
regulator_list_mutex. Resulting in a deadlock if the flush_work
call actually needs to flush the work.

The locking appears to have got quite complex since last time I
looked at it and I am having a little difficulty working out
exactly is protecting what.

I am wondering if the flush_work can just be moved outside the
regulator_list_mutex in regulator_unregister since that mutex
doesn't seem to protect the against the work being queued anyway?
I will keep looking into this over the next couple of days,
any pointers or ideas anyone has would be greatly appreciated.
Finally, as it looks like it might take a couple of days to
figure out the locking, I am leaving on holiday on Saturday
so if you don't see a fix from my by then it might be a couple
of weeks before I can look at it again.

Thanks,
Charles

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ