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] [day] [month] [year] [list]
Message-ID: <25eabe2f-93ce-46d3-b0e0-f633e1cefbe4@salutedevices.com>
Date: Thu, 11 Apr 2024 17:20:31 +0300
From: George Stark <gnstark@...utedevices.com>
To: Lee Jones <lee@...nel.org>
CC: <andy.shevchenko@...il.com>, <pavel@....cz>, <vadimp@...dia.com>,
	<christophe.leroy@...roup.eu>, <hdegoede@...hat.com>,
	<mazziesaccount@...il.com>, <peterz@...radead.org>, <mingo@...hat.com>,
	<will@...nel.org>, <longman@...hat.com>, <boqun.feng@...il.com>,
	<nikitos.tr@...il.com>, <marek.behun@....cz>, <kabel@...nel.org>,
	<linux-leds@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v7 0/8] devm_led_classdev_register() usage problem

Hello Lee

On 4/11/24 16:45, Lee Jones wrote:
> On Fri, 29 Mar 2024, George Stark wrote:
> 
>> Hello Lee
>>
>> On 3/22/24 13:43, Lee Jones wrote:
>>> On Fri, 22 Mar 2024, George Stark wrote:
>>>
>>>> Hello Lee
>>>>
>>>> On 3/21/24 21:11, Lee Jones wrote:
>>>>> On Thu, 14 Mar 2024, George Stark wrote:
>>>>>
>>>>>> This patch series fixes the problem of devm_led_classdev_register misusing.
>>>>>>
>>>>>> The basic problem is described in [1]. Shortly when devm_led_classdev_register()
>>>>>> is used then led_classdev_unregister() called after driver's remove() callback.
>>>>>> led_classdev_unregister() calls driver's brightness_set callback and that callback
>>>>>> may use resources which were destroyed already in driver's remove().
>>>>>>
>>>>>> After discussion with maintainers [2] [3] we decided:
>>>>>> 1) don't touch led subsystem core code and don't remove led_set_brightness() from it
>>>>>> but fix drivers
>>>>>> 2) don't use devm_led_classdev_unregister
>>>>>>
>>>>>> So the solution is to use devm wrappers for all resources
>>>>>> driver's brightness_set() depends on. And introduce dedicated devm wrapper
>>>>>> for mutex as it's often used resource.
>>>>
>>>> ...
>>>>
>>>>>>      locking/mutex: introduce devm_mutex_init()
>>>>>>      leds: aw2013: use devm API to cleanup module's resources
>>>>>>      leds: aw200xx: use devm API to cleanup module's resources
>>>>>>      leds: lp3952: use devm API to cleanup module's resources
>>>>>>      leds: lm3532: use devm API to cleanup module's resources
>>>>>>      leds: nic78bx: use devm API to cleanup module's resources
>>>>>>      leds: mlxreg: use devm_mutex_init() for mutex initialization
>>>>>>      leds: an30259a: use devm_mutex_init() for mutex initialization
>>>>>>
>>>>>>     drivers/leds/leds-an30259a.c | 14 ++++----------
>>>>>>     drivers/leds/leds-aw200xx.c  | 32 +++++++++++++++++++++-----------
>>>>>>     drivers/leds/leds-aw2013.c   | 25 +++++++++++++------------
>>>>>>     drivers/leds/leds-lm3532.c   | 29 +++++++++++++++++------------
>>>>>>     drivers/leds/leds-lp3952.c   | 21 +++++++++++----------
>>>>>>     drivers/leds/leds-mlxreg.c   | 14 +++++---------
>>>>>>     drivers/leds/leds-nic78bx.c  | 23 +++++++++++++----------
>>>>>>     include/linux/mutex.h        | 27 +++++++++++++++++++++++++++
>>>>>>     kernel/locking/mutex-debug.c | 11 +++++++++++
>>>>>>     9 files changed, 122 insertions(+), 74 deletions(-)
>>>>>
>>>>> Doesn't apply to v6.8.
>>>>>
>>>>> What base was used for this?
>>>>
>>>> I've just pulled git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>>>> and v7 was applied cleanly. linux-next is ok too.
>>>>
>>>> v6.8 is lack of recent patch 6969d0a2ba1adc9ba6a49b9805f24080896c255c
>>>> v7's patch #2 depends on it
>>>
>>> No problem.  I'll wait for v6.9-rc1.
>>>
>>
>> Just checked the v7 patch series on released 6.9-rc1 and it's applied
>> cleanly. If anything i can help please let me know.
> 
> It applies, but doesn't seem to build:
> 
> make --silent --keep-going --jobs=8 O=../build ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- 'CC=sccache aarch64-linux-gnu-gcc' 'HOSTCC=sccache gcc' allmodconfig
> make --silent --keep-going --jobs=8 O=../build ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- CROSS_COMPILE_COMPAT=arm-linux-gnueabihf- 'CC=sccache aarch64-linux-gnu-gcc' 'HOSTCC=sccache gcc'
> ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-an30259a.ko] undefined!
> ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-aw200xx.ko] undefined!
> ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-aw2013.ko] undefined!
> ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-lm3532.ko] undefined!
> ERROR: modpost: "__devm_mutex_init" [drivers/leds/leds-mlxreg.ko] undefined!
> make[3]: *** [/builds/linux/scripts/Makefile.modpost:145: Module.symvers] Error 1
> 
> Did you forget to export it?
> 

Yes, my bad. I tested *DEBUG* configs but without modules enabled.
Adding EXPORT_SYMBOL_GPL(__devm_mutex_init); fixes the problem,
v8 is on the way.

-- 
Best regards
George

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ