【标题描述】hisi_sas驱动加载时初始化debugfs,申请内存失败后,在驱动卸载或设备移除时会触发空指针异常
【环境信息】
硬件信息:
1) 鲲鹏920
软件信息:
[root@localhost 0000:b4:02.0]# cat /etc/euleros-latest
eulerversion=EulerOS_Server_V200R008C00SPC300B630
compiletime=2019-12-27-10-58-38
kernelversion=4.19.36-vhulk1907.1.0.h619
[root@localhost 0000:b4:02.0]# uname -a
Linux localhost.localdomain 4.19.36-vhulk1907.1.0.h619.eulerosv2r8.aarch64 #1 SMP Mon Jul 22 00:00:00 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
【问题复现步骤】
问题前提:系统内存资源不足。
具体操作步骤: 对控制器进行加卸载测试:
echo 1 > /sys/bus/pci/devices/0000:74:02.0/remove
echo 1 > /sys/bus/pci/rescan
出现概率:80%
【预期结果】
设备能正常完成加卸载。
【实际结果】
出现空指针异常
【解决方案】
debugfs_dir资源释放后置NULL,防止第2次去释放时,触发空指针异常。
【附件信息】
日志:
localhost:/verification/ko # echo 1 > /sys/bus/pci/rescan
[29405.891961] pci 0000:74:02.0: [19e5:a230] type 00 class 0x010700
[29405.897969] pci 0000:74:02.0: reg 0x24: [mem 0xa2000000-0xa2007fff]
[29405.904352] pci 0000:74:02.0: BAR 5: assigned [mem 0xa2000000-0xa2007fff]
[29405.911919] iommu: Adding device 0000:74:02.0 to group 12
[29405.934500] kworker/0:2: page allocation failure: order:7, mode:0x6040c0(GFP_KERNEL|__GFP_COMP), nodemask=(null)
[29405.944670] kworker/0:2 cpuset=/ mems_allowed=0
[29405.949197] CPU: 0 PID: 337 Comm: kworker/0:2 Tainted: G W OE 4.19.36-vhulk1907.1.0.h619.eulerosv2r8.aarch64 #1
[29405.960310] Hardware name: Huawei Technologies Co., Ltd. EVBCS/EVBCS, BIOS CS B200 1P TA 01/15/2022
[29405.969343] Workqueue: events work_for_cpu_fn
[29405.973686] Call trace:
[29405.976120] dump_backtrace+0x0/0x198
[29405.979768] show_stack+0x24/0x30
[29405.983069] dump_stack+0xa4/0xcc
[29405.986372] warn_alloc+0x10c/0x190
[29405.989846] __alloc_pages_nodemask+0xc78/0xd38
[29405.994363] kmalloc_large_node+0x6c/0x90
[29405.998359] __kmalloc_node_track_caller+0x268/0x330
[29406.003310] devm_kmalloc+0x44/0xb0
[29406.006788] hisi_sas_debugfs_init+0x370/0x480 [hisi_sas_main]
[29406.012608] hisi_sas_v3_probe+0x53c/0x590 [hisi_sas_v3_hw]
[29406.018168] local_pci_probe+0x44/0xa8
[29406.021903] work_for_cpu_fn+0x20/0x30
[29406.025638] process_one_work+0x1b4/0x3f8
[29406.029633] worker_thread+0x210/0x470
[29406.033368] kthread+0x134/0x138
[29406.036583] ret_from_fork+0x10/0x18
[29406.040151] warn_alloc_show_mem: 1 callbacks suppressed
localhost:/verification/ko # echo 1 > /sys/bus/pci/devices/0000:74:02.0/remove
[29413.635882] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000a0
[29413.644656] Mem abort info:
[29413.647435] ESR = 0x96000004
[29413.650481] Exception class = DABT (current EL), IL = 32 bits
[29413.656389] SET = 0, FnV = 0
[29413.659429] EA = 0, S1PTW = 0
[29413.662559] Data abort info:
[29413.665429] ISV = 0, ISS = 0x00000004
[29413.669254] CM = 0, WnR = 0
[29413.672210] user pgtable: 4k pages, 48-bit VAs, pgdp = 000000006840720c
[29413.678813] [00000000000000a0] pgd=0000000000000000
[29413.683681] Internal error: Oops: 96000004 [#1] SMP
[29413.688545] Process bash (pid: 4708, stack limit = 0x0000000088630e8c)
[29413.695058] CPU: 27 PID: 4708 Comm: bash Tainted: G W OE 4.19.36-vhulk1907.1.0.h619.eulerosv2r8.aarch64 #1
[29413.705737] Hardware name: Huawei Technologies Co., Ltd. EVBCS/EVBCS, BIOS CS B200 1P TA 01/15/2022
[29413.714767] pstate: 80400009 (Nzcv daif +PAN -UAO)
[29413.719545] pc : down_write+0x24/0x70
[29413.723193] lr : down_write+0x1c/0x70
[29413.726840] sp : ffff00001df6ba30
[29413.730141] x29: ffff00001df6ba30 x28: ffff802fb835dd00
[29413.735439] x27: ffff802a89140000 x26: 0000000000000000
[29413.740737] x25: ffff802f5201ca90 x24: ffff802f5201ca90
[29413.746035] x23: ffff00000986dc00 x22: ffff00000986dbf0
[29413.751333] x21: 0000000000000000 x20: ffff802f5201cb30
[29413.756631] x19: 00000000000000a0 x18: ffff802fb887d810
[29413.761929] x17: 0000000000000000 x16: 0000000000000000
[29413.767226] x15: 0000000000000000 x14: ffff8023e23f2500
[29413.772524] x13: ffff8023e23f2480 x12: 0000000000000000
[29413.777822] x11: ffff8023e23f24a8 x10: ffff802fb4fb8dd0
[29413.783120] x9 : 000000000000000c x8 : 0000000000000011
[29413.788417] x7 : ffff7e00a1ed3300 x6 : 0000000000000001
[29413.793715] x5 : 0000000000000001 x4 : ffff802f59dac238
[29413.799012] x3 : ffff802f51a9a19c x2 : 0000000000000000
[29413.804310] x1 : 00000000000000a0 x0 : ffffffff00000001
[29413.809607] Call trace:
[29413.812040] down_write+0x24/0x70
[29413.815343] debugfs_remove_recursive+0x5c/0x1b0
[29413.819950] hisi_sas_debugfs_exit+0x24/0x30 [hisi_sas_main]
[29413.825596] hisi_sas_v3_remove+0x34/0x150 [hisi_sas_v3_hw]
[29413.831155] pci_device_remove+0x48/0xd8
[29413.835063] device_release_driver_internal+0x1b4/0x250
[29413.840273] device_release_driver+0x28/0x38
[29413.844530] pci_stop_bus_device+0x84/0xb8
[29413.848612] pci_stop_and_remove_bus_device_locked+0x24/0x40
[29413.854257] remove_store+0xfc/0x140
[29413.857818] dev_attr_store+0x44/0x60
[29413.861466] sysfs_kf_write+0x58/0x80
[29413.865114] kernfs_fop_write+0xe8/0x1f0
[29413.869023] __vfs_write+0x60/0x190
[29413.872497] vfs_write+0xac/0x1c0
[29413.875798] ksys_write+0x6c/0xd8
[29413.879099] __arm64_sys_write+0x24/0x30
[29413.883008] el0_svc_common+0x78/0x130
[29413.886743] el0_svc_handler+0x38/0x78
[29413.890478] el0_svc+0x8/0xc
Hi jamyyxg, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at Here.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers: @YangYingliang , @成坚 (CHENG Jian) , @jiaoff , @刘勇强 , @wangxiongfeng , @朱科潜 , @WangShaoBo , @lujialin , @Xu Kuohai , @冷嘲啊 , @Lingmingqiang , @yuzenghui , @juntian , @OSSIM , @陈结松 , @whoisxxx , @koulihong , @刘恺 , @hanjun-guo , @woqidaideshi , @Chiqijun , @Kefeng , @ThunderTown , @AlexGuo , @kylin-mayukun , @Zheng Zucheng , @柳歆 , @Jackie Liu , @zhujianwei001 , @郑振鹏 , @SuperSix173 , @colyli , @Zhang Yi , @htforge , @Yuehaibing , @xiehaocheng , @guzitao , @CTC-Xibo.Wang , @zhanghongchen , @chen wei , @Jason Zeng , @苟浩 , @DuanqiangWen , @georgeguo , @毛泓博 , @AllenShi , @zhangjialin , @Wei Li , @tcc@hello , @谭小飞 , @Fred Kimmy , @LiYihang , @young1c , @hucz , @WangBoe2022 , @chenke , @李力军 , @Yang Shen , @wsoydl , @sanglipeng , @zhangchangzhong , @jimmy_hero , @YGN-NDWD-Official , @Xie XiuQi , @zhengzengkai
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
登录 后才可以发表评论