[REGRESSION] "split bio_kmalloc from bio_alloc_bioset" causing crash shortly after bootup

From: John Stultz
Date: Mon Feb 22 2021 - 22:07:16 EST


Hey all,
In testing Linus' HEAD today I found another[1] regression in the block merge.

This time I see a crash on my hikey960 board shortly after booting
ASOP. See the log below.

I bisected the issue down to "block: split bio_kmalloc from bio_alloc_bioset":
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3175199ab0ac8c874ec25c6bf169f74888917435

But unfortunately that does not revert cleanly against Linus' HEAD.

It seems like the issue is that the function is no longer handling the
case where the bio_set *bs is NULL as is done here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/block/blk-crypto-fallback.c#n230

If there's anything I can do to help debug this issue, please let me know!

thanks
-john

[1]: "add a disk_uevent helper" also was giving me trouble as reported here:
https://lore.kernel.org/lkml/CALAqxLU3B8YcS_MTnr2Lpasvn8oLJvD2qO4hkfkZeEwVNfeHXg@xxxxxxxxxxxxxx/


[ 34.600558] Unable to handle kernel read from unreadable memory at
virtual address 0000000000000068
[ 34.609819] Mem abort info:
[ 34.612644] ESR = 0x96000005
[ 34.615707] EC = 0x25: DABT (current EL), IL = 32 bits
[ 34.621157] SET = 0, FnV = 0
[ 34.624288] EA = 0, S1PTW = 0
[ 34.628312] Data abort info:
[ 34.631236] ISV = 0, ISS = 0x00000005
[ 34.635222] CM = 0, WnR = 0
[ 34.638186] user pgtable: 4k pages, 39-bit VAs, pgdp=000000000774f000
[ 34.644639] [0000000000000068] pgd=0000000000000000,
p4d=0000000000000000, pud=0000000000000000
[ 34.653381] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[ 34.658954] Modules linked in:
[ 34.662007] CPU: 0 PID: 173 Comm: kworker/u16:3 Not tainted
5.11.0-04196-ga8e8932e4ae #559
[ 34.670270] Hardware name: HiKey960 (DT)
[ 34.674190] Workqueue: writeback wb_workfn (flush-8:48)
[ 34.679429] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO BTYPE=--)
[ 34.685435] pc : bio_alloc_bioset+0x14/0x230
[ 34.689720] lr : bio_clone_fast+0x28/0x80
[ 34.693728] sp : ffffffc012a13530
[ 34.697036] x29: ffffffc012a13530 x28: 0000000000003400
[ 34.702351] x27: 0000000000000000 x26: ffffff8001993040
[ 34.703203] dwmmc_k3 ff3ff000.dwmmc2: Unexpected interrupt latency
[ 34.707662] x25: 0000000000000001 x24: ffffff8001fc8800
[ 34.719145] x23: ffffffffffffffff x22: ffffffc012a137e8
[ 34.724456] x21: 0000000000000c00 x20: ffffff8001fc8800
[ 34.729767] x19: 0000000000000800 x18: fffffffe013efe80
[ 34.735078] x17: 0000000000000068 x16: fffffffe012aa440
[ 34.740389] x15: 0000000000001000 x14: ffffff8001fc8800
[ 34.745700] x13: ffffff805c3e4000 x12: 00000000001ce000
[ 34.751009] x11: 00000000000000fb x10: 0000000000001000
[ 34.756320] x9 : 0000000000000033 x8 : 00000000000d9000
[ 34.761631] x7 : 0000000000000000 x6 : 000000000000a000
[ 34.766941] x5 : 0000000000000c00 x4 : 0000000000001000
[ 34.772251] x3 : 0000000000000000 x2 : 0000000000000000
[ 34.777561] x1 : 0000000000000000 x0 : 0000000000000c00
[ 34.782873] Call trace:
[ 34.784901] ueventd: LoadWithAliases was unable to load platform:regulatory
[ 34.785313] bio_alloc_bioset+0x14/0x230
[ 34.796189] bio_clone_fast+0x28/0x80
[ 34.799848] bio_split+0x50/0xd0
[ 34.803072] blk_crypto_fallback_encrypt_bio+0x2ec/0x5e8
[ 34.808384] blk_crypto_fallback_bio_prep+0xfc/0x140
[ 34.813345] __blk_crypto_bio_prep+0x13c/0x150
[ 34.817784] submit_bio_noacct+0x3c0/0x548
[ 34.821880] submit_bio+0x48/0x200
[ 34.825278] ext4_io_submit+0x50/0x68
[ 34.828939] ext4_writepages+0x558/0xca8
[ 34.832860] do_writepages+0x58/0x108
[ 34.836522] __writeback_single_inode+0x44/0x510
[ 34.841137] writeback_sb_inodes+0x1e0/0x4a8
[ 34.845404] __writeback_inodes_wb+0x78/0xe8
[ 34.849670] wb_writeback+0x274/0x3e8
[ 34.853328] wb_workfn+0x308/0x5f0
[ 34.856726] process_one_work+0x1ec/0x4d0
[ 34.860734] worker_thread+0x44/0x478
[ 34.864392] kthread+0x140/0x150
[ 34.867618] ret_from_fork+0x10/0x30
[ 34.871197] Code: a9ba7bfd 910003fd f9000bf3 7900bfa1 (f9403441)
[ 34.877289] ---[ end trace e6c2a3ab108278f0 ]---
[ 34.893636] Kernel panic - not syncing: Oops: Fatal exception