Introduce block device LED trigger
Hi Ian,
with a heavily patched Linux 6.0-rc4 with kfence, kmemleak and slub_debug I get the following splat at boot:
Sep 07 11:33:11 kernel: ============================================================================= Sep 07 11:33:11 kernel: BUG kmalloc-16 (Not tainted): Object already free Sep 07 11:33:11 kernel: ----------------------------------------------------------------------------- Sep 07 11:33:11 kernel: Allocated in kernfs_fop_write_iter+0x178/0x200 age=1 cpu=0 pid=453 Sep 07 11:33:11 kernel: __slab_alloc.constprop.0+0x42/0x80 Sep 07 11:33:11 kernel: __kmalloc+0x334/0x3a0 Sep 07 11:33:11 kernel: kernfs_fop_write_iter+0x178/0x200 Sep 07 11:33:11 kernel: vfs_write+0x268/0x430 Sep 07 11:33:11 kernel: ksys_write+0x6f/0xf0 Sep 07 11:33:11 kernel: do_syscall_64+0x5c/0x90 Sep 07 11:33:11 kernel: entry_SYSCALL_64_after_hwframe+0x63/0xcd Sep 07 11:33:11 kernel: Freed in blkdev_trig_get_bdev+0x47/0x60 [ledtrig_blkdev] age=1 cpu=0 pid=453 Sep 07 11:33:11 kernel: kfree+0x374/0x3b0 Sep 07 11:33:11 kernel: blkdev_trig_get_bdev+0x47/0x60 [ledtrig_blkdev] Sep 07 11:33:11 kernel: link_dev_by_path_store+0x5c/0x3f0 [ledtrig_blkdev] Sep 07 11:33:11 kernel: kernfs_fop_write_iter+0x11f/0x200 Sep 07 11:33:11 kernel: vfs_write+0x268/0x430 Sep 07 11:33:11 kernel: ksys_write+0x6f/0xf0 Sep 07 11:33:11 kernel: do_syscall_64+0x5c/0x90 Sep 07 11:33:11 kernel: entry_SYSCALL_64_after_hwframe+0x63/0xcd Sep 07 11:33:11 kernel: Slab 0xffffeb91446ad1c0 objects=32 used=31 fp=0xffff912c1ab47b10 flags=0x4000000000000201(locked|slab|zone=2) Sep 07 11:33:11 kernel: Object 0xffff912c1ab47b10 @offset=2832 fp=0x0000000000000000 Sep 07 11:33:11 kernel: Redzone ffff912c1ab47b00: bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb ................ Sep 07 11:33:11 kernel: Object ffff912c1ab47b10: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b a5 kkkkkkkkkkkkkkk. Sep 07 11:33:11 kernel: Redzone ffff912c1ab47b20: bb bb bb bb bb bb bb bb ........ Sep 07 11:33:11 kernel: Padding ffff912c1ab47b70: 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZZZZZZZZZ [...] Sep 07 11:33:11 kernel: Call Trace: Sep 07 11:33:11 kernel: <TASK> Sep 07 11:33:11 kernel: dump_stack_lvl+0x37/0x4a Sep 07 11:33:11 kernel: object_err+0x2f/0x42 Sep 07 11:33:11 kernel: free_debug_processing.cold+0x9c/0x126 Sep 07 11:33:11 kernel: ? kernfs_fop_write_iter+0xa0/0x200 Sep 07 11:33:11 kernel: __slab_free+0x265/0x450 Sep 07 11:33:11 kernel: ? _raw_spin_lock_irqsave+0x1b/0x50 Sep 07 11:33:11 kernel: ? _raw_spin_unlock_irqrestore+0x22/0x40 Sep 07 11:33:11 kernel: ? kernfs_fop_write_iter+0xa0/0x200 Sep 07 11:33:11 kernel: kfree+0x374/0x3b0 Sep 07 11:33:11 kernel: kernfs_fop_write_iter+0xa0/0x200 Sep 07 11:33:11 kernel: vfs_write+0x268/0x430 Sep 07 11:33:11 kernel: ksys_write+0x6f/0xf0 Sep 07 11:33:11 kernel: do_syscall_64+0x5c/0x90 Sep 07 11:33:11 kernel: ? do_syscall_64+0x6b/0x90 Sep 07 11:33:11 kernel: ? do_syscall_64+0x6b/0x90 Sep 07 11:33:11 kernel: entry_SYSCALL_64_after_hwframe+0x63/0xcd Sep 07 11:33:11 kernel: RIP: 0033:0x74dc50050e94 Sep 07 11:33:11 kernel: Code: 15 f9 0e 0e 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 f3 0f 1e fa 80 3d 8d 96 0e 00 00 74 13 b8 01 00 00 00 0f 05 <48> 3> Sep 07 11:33:11 kernel: RSP: 002b:00007fff526d4058 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 Sep 07 11:33:11 kernel: RAX: ffffffffffffffda RBX: 000000000000000c RCX: 000074dc50050e94 Sep 07 11:33:11 kernel: RDX: 000000000000000c RSI: 0000620ac0072430 RDI: 0000000000000005 Sep 07 11:33:11 kernel: RBP: 0000620ac0072430 R08: 0000620ac00852a0 R09: 007265776f703a3a Sep 07 11:33:11 kernel: R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000005 Sep 07 11:33:11 kernel: R13: 0000000000000000 R14: 0000000000000005 R15: 0000620ac00852a0 Sep 07 11:33:11 kernel: </TASK> Sep 07 11:33:11 kernel: Disabling lock debugging due to kernel taint Sep 07 11:33:11 kernel: FIX kmalloc-16: Object at 0xffff912c1ab47b10 not freed
I'm not 100% sure if this is an issue with ledtrig_blkdev or something else, but I thought I'll let you know about it.
I have not been able to test this on a vanilla kernel yet.
Other than that, I hope this patchset gets included in upstream. I have been using it for a long time now and found it very useful.
Cheers,
Tor
Quoted 4 lines · On 9/7/22 07:16, [email protected] wrote:
Hi Ian,
with a heavily patched Linux 6.0-rc4 with kfence, kmemleak and
slub_debugI get the following splat at boot:
Sorry about that! I'm not sure how that slipped throgh, as I was sure that I tested the new version before I sent it off.
Basically, I messed up while cleaning up the function parameter names, so you need to apply this:
leds/trigger/ledtrig-blkdev.c 2022-09-04 11:36:16.107690614 -0500 renamed from leds/trigger/ledtrig-blkdev.c.old 2022-09-07 10:00:26.194484681 -0500 +0 -0
@@ -540,7 +540,7 @@ return ERR_PTR(-ENOMEM); bdev = blkdev_get_by_path(strim(buf), BLKDEV_TRIG_FMODE,
THIS_MODULE);
- kfree(path);
+ kfree(buf);
return bdev;}
Quoted 3 lines
I'm not 100% sure if this is an issue with
ledtrig_blkdevor something else, but I thought I'll let you know about it.
I have not been able to test this on a vanilla kernel yet.
Defnintely my fault.
Quoted 2 lines
Other than that, I hope this patchset gets included in upstream. I have been using it for a long time now and found it very useful.
It's really hard to know if anyone is interested in/using this, so that's great to hear.
Signature · 3 lines
======================================================================== Google Where SkyNet meets Idiocracy ========================================================================
[email protected]
Tested-byQuoted 22 lines
Ian Pilcher <[email protected]> hat am 07.09.2022 15:11 GMT geschrieben:
Quoted 4 lines · On 9/7/22 07:16, [email protected] wrote:
Hi Ian,
with a heavily patched Linux 6.0-rc4 with kfence, kmemleak and
slub_debugI get the following splat at boot:Sorry about that! I'm not sure how that slipped throgh, as I was sure that I tested the new version before I sent it off.
Basically, I messed up while cleaning up the function parameter names, so you need to apply this:
---
drivers/leds/trigger/ledtrig-blkdev.c.old2022-09-07
10:00:26.194484681 -0500
+++drivers/leds/trigger/ledtrig-blkdev.c2022-09-04
11:36:16.107690614 -0500
Review line 546
Quoted 8 lines
(quoted diff) +1
-1@@ -540,7 +540,7 @@ return ERR_PTR(-ENOMEM); bdev = blkdev_get_by_path(strim(buf), BLKDEV_TRIG_FMODE, THIS_MODULE); - kfree(path); + kfree(buf); return bdev; }
This fixes the issue, no more errors.
Thank you!
Quoted 11 lines
Quoted 3 lines
I'm not 100% sure if this is an issue with
ledtrig_blkdevor something else, but I thought I'll let you know about it.
I have not been able to test this on a vanilla kernel yet.Defnintely my fault.
Quoted 2 lines
Other than that, I hope this patchset gets included in upstream. I have been using it for a long time now and found it very useful.
It's really hard to know if anyone is interested in/using this, so that's great to hear.
When and if you send a v11, you can add my
Quoted 5 lines
Signature · 4 lines
-- ======================================================================== Google Where SkyNet meets Idiocracy ========================================================================