-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generic: add leds_st1202 patch to fix NULL pointer access #17543
Conversation
If it causes a kernel panic it means the driver is broken and needs to be fixed, not force loaded on boot to avoid it. Please report the issue upstream so it can be fixed. Also if there is an error message, always include the error message verbatim. |
And at a quick glance looking at the driver, I'm 99% sure the issue is that |
It was reported to the developer, but it is not something that he can reproduce, nor immediately obvious that the crash was caused by the driver itself. Your comment about the device becoming visible before it should could well explain why the crash seems to happen elsewhere but the root cause is still the driver. I was working on the basis that I had made a bad decision not putting the module in boot which is what almost every other kmod LED package does. Therefore, I didn't consider adding any crash information which I am doing now dmesg-pstore_blk-1.txt is the crash with the driver unmodified. I still think that moving it to boot is not forcing anything and it seems to be the norm but it doesn't change the fact that if there is a bug, it needs fixing. On a related note, I was able to collect the panic logs with #17422 and #16689. I'd be grateful if you could take a look at them at some point. |
That's a NULL pointer access all right.
so this happens here:
where
Classic race condition ;-) There is a lot of stuff happening after devm_led_classdev_register_ext() that looks racy as well, so |
492dd97
to
4f970f9
Compare
@KanjiMonster thanks, I'll pass the feedback to the developer. Meanwhile, I made an amateur attempt at moving @robimarko please hold fire because it might not be necessary to move the module to boot which would help shorten the time between the module loading and |
4f970f9
to
280c124
Compare
Since my last message, the driver as it is in OpenWrt (v11) has been added to the LEDs subsystem, although I can't find any trace of that on public repositories: https://lore.kernel.org/lkml/[email protected] I have changed this PR to a patch with the minimum changes required to prevent the NULL pointer access for your consideration. There is no need to move the module to boot. I also passed the feedback to the developer so he might take some actions himself. Otherwise, I will send the patch upstream once the driver actually shows up in their repo. |
14ed667
to
724c245
Compare
I will merge this, but please send it upstream as well since it looks like this driver will end up in the next release since LED maintainer has merged it into his LED tree in the for-next branch: |
As per @KanjiMonster comment: st1202_dt_init() calls devm_led_classdev_register_ext() before the internal data structures are properly setup, so the leds become visible to user space while being partially initialized, leading to a window where trying to access them causes a NULL pointer access. Move devm_led_classdev_register_ext() to the last thing to happen during initialization. Signed-off-by: Manuel Fombuena <[email protected]> Link: openwrt#17543 Signed-off-by: Robert Marko <[email protected]>
724c245
to
ec8a128
Compare
Thanks! Rebased on top of main and merged! |
Thanks. Yes, the patch you've merged is what I sent after |
As per @KanjiMonster comment: st1202_dt_init() calls devm_led_classdev_register_ext() before the internal data structures are properly setup, so the leds become visible to user space while being partially initialized, leading to a window where trying to access them causes a NULL pointer access. Move devm_led_classdev_register_ext() to the last thing to happen during initialization. Signed-off-by: Manuel Fombuena <[email protected]> Link: openwrt#17543 Signed-off-by: Robert Marko <[email protected]>
As per @KanjiMonster comment: st1202_dt_init() calls devm_led_classdev_register_ext() before the internal data structures are properly setup, so the leds become visible to user space while being partially initialized, leading to a window where trying to access them causes a NULL pointer access. Move devm_led_classdev_register_ext() to the last thing to happen during initialization. Signed-off-by: Manuel Fombuena <[email protected]> Link: openwrt#17543 Signed-off-by: Robert Marko <[email protected]>
Merged on #17451, the module has to be loaded before launching preinit to avoid a kernel panic triggered by userspace accessing the controller before it is ready.
It was initially put under modules to minimise the time the LEDs are off, as the driver resets them all, but that surfaced the before-mentioned issue.
So lets use AutoLoad with the boot flag and a relatively low priority as most other LED driver modules.