Commit 9d37fe3
md: init bioset in mddev_init
[ Upstream commit 381a3ce ]
IO operations may be needed before md_run(), such as updating metadata
after writing sysfs. Without bioset, this triggers a NULL pointer
dereference as below:
BUG: kernel NULL pointer dereference, address: 0000000000000020
Call Trace:
md_update_sb+0x658/0xe00
new_level_store+0xc5/0x120
md_attr_store+0xc9/0x1e0
sysfs_kf_write+0x6f/0xa0
kernfs_fop_write_iter+0x141/0x2a0
vfs_write+0x1fc/0x5a0
ksys_write+0x79/0x180
__x64_sys_write+0x1d/0x30
x64_sys_call+0x2818/0x2880
do_syscall_64+0xa9/0x580
entry_SYSCALL_64_after_hwframe+0x4b/0x53
Reproducer
```
mdadm -CR /dev/md0 -l1 -n2 /dev/sd[cd]
echo inactive > /sys/block/md0/md/array_state
echo 10 > /sys/block/md0/md/new_level
```
mddev_init() can only be called once per mddev, no need to test if bioset
has been initialized anymore.
Link: https://lore.kernel.org/linux-raid/20251103125757.1405796-3-linan666@huaweicloud.com
Fixes: d981ed8 ("md: Add new_level sysfs interface")
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Xiao Ni <xni@redhat.com>
Signed-off-by: Yu Kuai <yukuai@fnnas.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent a66e5f5 commit 9d37fe3
1 file changed
+33
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
730 | 730 | | |
731 | 731 | | |
732 | 732 | | |
| 733 | + | |
| 734 | + | |
733 | 735 | | |
734 | 736 | | |
735 | 737 | | |
| |||
741 | 743 | | |
742 | 744 | | |
743 | 745 | | |
744 | | - | |
745 | | - | |
| 746 | + | |
| 747 | + | |
746 | 748 | | |
747 | 749 | | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
748 | 763 | | |
749 | 764 | | |
750 | 765 | | |
| |||
773 | 788 | | |
774 | 789 | | |
775 | 790 | | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
776 | 801 | | |
777 | 802 | | |
778 | 803 | | |
779 | 804 | | |
780 | 805 | | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
781 | 809 | | |
782 | 810 | | |
783 | 811 | | |
| |||
6387 | 6415 | | |
6388 | 6416 | | |
6389 | 6417 | | |
6390 | | - | |
6391 | | - | |
6392 | | - | |
6393 | | - | |
6394 | | - | |
6395 | | - | |
6396 | | - | |
6397 | | - | |
6398 | | - | |
6399 | | - | |
6400 | | - | |
6401 | | - | |
6402 | | - | |
6403 | | - | |
6404 | | - | |
6405 | | - | |
6406 | | - | |
6407 | | - | |
6408 | 6418 | | |
6409 | | - | |
6410 | | - | |
6411 | | - | |
6412 | | - | |
| 6419 | + | |
| 6420 | + | |
6413 | 6421 | | |
6414 | 6422 | | |
6415 | 6423 | | |
| |||
6420 | 6428 | | |
6421 | 6429 | | |
6422 | 6430 | | |
6423 | | - | |
6424 | | - | |
| 6431 | + | |
6425 | 6432 | | |
6426 | 6433 | | |
6427 | 6434 | | |
| |||
6548 | 6555 | | |
6549 | 6556 | | |
6550 | 6557 | | |
6551 | | - | |
6552 | | - | |
6553 | | - | |
6554 | | - | |
6555 | | - | |
6556 | | - | |
6557 | 6558 | | |
6558 | 6559 | | |
6559 | 6560 | | |
| |||
6778 | 6779 | | |
6779 | 6780 | | |
6780 | 6781 | | |
6781 | | - | |
6782 | | - | |
6783 | | - | |
6784 | | - | |
6785 | 6782 | | |
6786 | 6783 | | |
6787 | 6784 | | |
| |||
0 commit comments