mbox series

[0/2] Remove the /proc/scsi/${proc_name} directory earlier

Message ID 20230210205200.36973-1-bvanassche@acm.org
Headers show
Series Remove the /proc/scsi/${proc_name} directory earlier | expand

Message

Bart Van Assche Feb. 10, 2023, 8:51 p.m. UTC
Hi Martin,

This patch series fixes a race condition in the SCSI core. Please consider
this patch series for the next merge window.

Thanks,

Bart.

Bart Van Assche (2):
  scsi: core: Fix a source code comment
  scsi: core: Remove the /proc/scsi/${proc_name} directory earlier

 drivers/scsi/hosts.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

John Garry March 7, 2023, 3:08 p.m. UTC | #1
On 10/02/2023 20:51, Bart Van Assche wrote:
> Hi Martin,
> 
> This patch series fixes a race condition in the SCSI core. Please consider
> this patch series for the next merge window.
> 
> Thanks,
> 
> Bart.
> 
> Bart Van Assche (2):
>    scsi: core: Fix a source code comment
>    scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
> 
>   drivers/scsi/hosts.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 

Hi Bart,

I notice this following issue with v6.3-rc1 for scsi_debug when I turn 
on CONFIG_DEBUG_TEST_DRIVER_REMOVE and set DEF_NUM_HOST as 2 in that driver:

[    1.330849] ------------[ cut here ]------------
[    1.333027] remove_proc_entry: removing non-empty directory 
'scsi/scsi_debug', leaking at least '0'
[    1.335280] sd 0:0:0:0: [sda] Attached SCSI disk
[    1.337231] WARNING: CPU: 3 PID: 1 at fs/proc/generic.c:718 
remove_proc_entry+0x180/0x190
[    1.342979] Modules linked in:
[    1.344389] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 6.3.0-rc1-dirty 
#414
[    1.346760] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 
1.15.0-1 04/01/2014
[    1.349493] RIP: 0010:remove_proc_entry+0x180/0x190
[    1.351162] Code: c7 80 e8 6e aa 48 85 c0 48 8d 90 78 ff ff ff 48 0f 
45 c2 48 8b 55 78 4c 8b 80 a0 00 00 00 48 8b 92 a0 00 00 00 e8 10 0a d8 
ff <0f> 0b0
[    1.356712] RSP: 0000:ff7ad00780017c00 EFLAGS: 00010286
[    1.357991] RAX: 0000000000000000 RBX: ff4af384c146f440 RCX: 
0000000000000000
[    1.359716] RDX: 0000000000000001 RSI: 0000000000000001 RDI: 
0000000000000001
[    1.361439] RBP: ff4af384c1bc0300 R08: 6f6d6572203a7972 R09: 
746e655f636f7270
[    1.363145] R10: 72746e655f636f72 R11: 705f65766f6d6572 R12: 
ff4af384c1bc0380
[    1.364881] R13: ffffffffaa2ccd00 R14: ff4af384c1b47128 R15: 
ff4af384c1b4c420
[    1.366152] FS:  0000000000000000(0000) GS:ff4af3853aec0000(0000) 
knlGS:0000000000000000
[    1.367500] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    1.368463] CR2: 0000000000000000 CR3: 0000000030c2e001 CR4: 
0000000000771ee0
[    1.369639] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 
0000000000000000
[    1.370815] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 
0000000000000400
[    1.372040] PKRU: 55555554
[    1.372491] Call Trace:
[    1.372915]  <TASK>
[    1.373280]  scsi_proc_hostdir_rm+0x75/0xb0
[    1.373998]  scsi_host_dev_release+0x36/0xe0
[    1.374723]  device_release+0x30/0x90
[    1.375345]  kobject_put+0x68/0xd0
[    1.375923]  really_probe+0x24b/0x330
[    1.376451]  ? __pfx___device_attach_driver+0x10/0x10
[    1.377177]  __driver_probe_device+0x6d/0xd0
[    1.377794]  driver_probe_device+0x19/0xe0
[    1.378382]  __device_attach_driver+0x7e/0x110
[    1.379026]  bus_for_each_drv+0x7f/0xe0
[    1.379571]  __device_attach+0xb7/0x1d0
[    1.380126]  bus_probe_device+0x88/0xa0
[    1.380681]  device_add+0x612/0x800
[    1.381190]  sdebug_add_host_helper+0x1ce/0x260
[    1.381839]  scsi_debug_init+0x391/0x870
[    1.382431]  ? __pfx_scsi_debug_init+0x10/0x10
[    1.383081]  do_one_initcall+0x40/0x220
[    1.383637]  kernel_init_freeable+0x19a/0x2d0
[    1.384270]  ? __pfx_kernel_init+0x10/0x10
[    1.384862]  kernel_init+0x15/0x1b0
[    1.385368]  ret_from_fork+0x29/0x50
[    1.385891]  </TASK>
[    1.386203] ---[ end trace 0000000000000000 ]---
[    1.389637] scsi_debug:sdebug_driver_probe: scsi_debug: trim 
poll_queues to 0. poll_q/nr_hw = (0/1)
[    1.390954] scsi host1: scsi_debug: version 0191 [20210520]
                  dev_size_mb=8, opts=0x0, submit_queues=1, statistics=0

Is it related to this series, do you think?

Thanks,
John
Bart Van Assche March 7, 2023, 4:42 p.m. UTC | #2
On 3/7/23 07:08, John Garry wrote:
> Is it related to this series, do you think?

Probably. I'm not sure there is an alternative to reverting patch 2/2 
from this series and adding a wait loop inside
scsi_proc_hostdir_add(). Adding a wait loop inside 
scsi_proc_hostdir_add() might be controversial. Anyway, I will look into 
this.

Bart.