* [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
@ 2025-06-25 2:00 Nobuhiro Iwamatsu
2025-06-25 2:23 ` Alan Stern
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Nobuhiro Iwamatsu @ 2025-06-25 2:00 UTC (permalink / raw)
To: cip-dev, Ulrich Hecht, Pavel Machek
Cc: Bart Van Assche, Alan Stern, Yi Zhang, stable,
Martin K . Petersen, Nobuhiro Iwamatsu
From: Bart Van Assche <bvanassche@acm.org>
commit fc663711b94468f4e1427ebe289c9f05669699c9 upstream.
Remove the /proc/scsi/${proc_name} directory earlier to fix a race
condition between unloading and reloading kernel modules. This fixes a bug
introduced in 2009 by commit 77c019768f06 ("[SCSI] fix /proc memory leak in
the SCSI core").
Fix the following kernel warning:
proc_dir_entry 'scsi/scsi_debug' already registered
WARNING: CPU: 19 PID: 27986 at fs/proc/generic.c:376 proc_register+0x27d/0x2e0
Call Trace:
proc_mkdir+0xb5/0xe0
scsi_proc_hostdir_add+0xb5/0x170
scsi_host_alloc+0x683/0x6c0
sdebug_driver_probe+0x6b/0x2d0 [scsi_debug]
really_probe+0x159/0x540
__driver_probe_device+0xdc/0x230
driver_probe_device+0x4f/0x120
__device_attach_driver+0xef/0x180
bus_for_each_drv+0xe5/0x130
__device_attach+0x127/0x290
device_initial_probe+0x17/0x20
bus_probe_device+0x110/0x130
device_add+0x673/0xc80
device_register+0x1e/0x30
sdebug_add_host_helper+0x1a7/0x3b0 [scsi_debug]
scsi_debug_init+0x64f/0x1000 [scsi_debug]
do_one_initcall+0xd7/0x470
do_init_module+0xe7/0x330
load_module+0x122a/0x12c0
__do_sys_finit_module+0x124/0x1a0
__x64_sys_finit_module+0x46/0x50
do_syscall_64+0x38/0x80
entry_SYSCALL_64_after_hwframe+0x46/0xb0
Link: https://lore.kernel.org/r/20230210205200.36973-3-bvanassche@acm.org
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Yi Zhang <yi.zhang@redhat.com>
Cc: stable@vger.kernel.org
Fixes: 77c019768f06 ("[SCSI] fix /proc memory leak in the SCSI core")
Reported-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Nobuhiro Iwamatsu (CIP) <nobuhiro1.iwamatsu@toshiba.co.jp>
---
drivers/scsi/hosts.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index c59b3fd6b361..7ffdebdd9c54 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -173,6 +173,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
scsi_forget_host(shost);
mutex_unlock(&shost->scan_mutex);
scsi_proc_host_rm(shost);
+ scsi_proc_hostdir_rm(shost->hostt);
spin_lock_irqsave(shost->host_lock, flags);
if (scsi_host_set_state(shost, SHOST_DEL))
@@ -322,6 +323,7 @@ static void scsi_host_dev_release(struct device *dev)
struct request_queue *q;
void *queuedata;
+ /* In case scsi_remove_host() has not been called. */
scsi_proc_hostdir_rm(shost->hostt);
if (shost->tmf_work_q)
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
2025-06-25 2:00 [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier Nobuhiro Iwamatsu
@ 2025-06-25 2:23 ` Alan Stern
2025-06-25 7:04 ` Greg KH
2025-06-25 14:07 ` Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Alan Stern @ 2025-06-25 2:23 UTC (permalink / raw)
To: Nobuhiro Iwamatsu
Cc: cip-dev, Ulrich Hecht, Pavel Machek, Bart Van Assche, Yi Zhang,
stable, Martin K . Petersen
On Wed, Jun 25, 2025 at 11:00:26AM +0900, Nobuhiro Iwamatsu wrote:
> From: Bart Van Assche <bvanassche@acm.org>
>
> commit fc663711b94468f4e1427ebe289c9f05669699c9 upstream.
>
> Remove the /proc/scsi/${proc_name} directory earlier to fix a race
> condition between unloading and reloading kernel modules. This fixes a bug
> introduced in 2009 by commit 77c019768f06 ("[SCSI] fix /proc memory leak in
> the SCSI core").
>
> Fix the following kernel warning:
>
> proc_dir_entry 'scsi/scsi_debug' already registered
> WARNING: CPU: 19 PID: 27986 at fs/proc/generic.c:376 proc_register+0x27d/0x2e0
> Call Trace:
> proc_mkdir+0xb5/0xe0
> scsi_proc_hostdir_add+0xb5/0x170
> scsi_host_alloc+0x683/0x6c0
> sdebug_driver_probe+0x6b/0x2d0 [scsi_debug]
> really_probe+0x159/0x540
> __driver_probe_device+0xdc/0x230
> driver_probe_device+0x4f/0x120
> __device_attach_driver+0xef/0x180
> bus_for_each_drv+0xe5/0x130
> __device_attach+0x127/0x290
> device_initial_probe+0x17/0x20
> bus_probe_device+0x110/0x130
> device_add+0x673/0xc80
> device_register+0x1e/0x30
> sdebug_add_host_helper+0x1a7/0x3b0 [scsi_debug]
> scsi_debug_init+0x64f/0x1000 [scsi_debug]
> do_one_initcall+0xd7/0x470
> do_init_module+0xe7/0x330
> load_module+0x122a/0x12c0
> __do_sys_finit_module+0x124/0x1a0
> __x64_sys_finit_module+0x46/0x50
> do_syscall_64+0x38/0x80
> entry_SYSCALL_64_after_hwframe+0x46/0xb0
Can you or Bart please explain in more detail the race that causes this
problem, and add that description to the changelog? Also, explain how
this patch fixes the race.
Alan Stern
> Link: https://lore.kernel.org/r/20230210205200.36973-3-bvanassche@acm.org
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Yi Zhang <yi.zhang@redhat.com>
> Cc: stable@vger.kernel.org
> Fixes: 77c019768f06 ("[SCSI] fix /proc memory leak in the SCSI core")
> Reported-by: Yi Zhang <yi.zhang@redhat.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Signed-off-by: Nobuhiro Iwamatsu (CIP) <nobuhiro1.iwamatsu@toshiba.co.jp>
> ---
> drivers/scsi/hosts.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
> index c59b3fd6b361..7ffdebdd9c54 100644
> --- a/drivers/scsi/hosts.c
> +++ b/drivers/scsi/hosts.c
> @@ -173,6 +173,7 @@ void scsi_remove_host(struct Scsi_Host *shost)
> scsi_forget_host(shost);
> mutex_unlock(&shost->scan_mutex);
> scsi_proc_host_rm(shost);
> + scsi_proc_hostdir_rm(shost->hostt);
>
> spin_lock_irqsave(shost->host_lock, flags);
> if (scsi_host_set_state(shost, SHOST_DEL))
> @@ -322,6 +323,7 @@ static void scsi_host_dev_release(struct device *dev)
> struct request_queue *q;
> void *queuedata;
>
> + /* In case scsi_remove_host() has not been called. */
> scsi_proc_hostdir_rm(shost->hostt);
>
> if (shost->tmf_work_q)
> --
> 2.25.1
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
2025-06-25 2:00 [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier Nobuhiro Iwamatsu
2025-06-25 2:23 ` Alan Stern
@ 2025-06-25 7:04 ` Greg KH
2025-06-25 7:18 ` nobuhiro1.iwamatsu
2025-06-25 14:07 ` Sasha Levin
2 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2025-06-25 7:04 UTC (permalink / raw)
To: Nobuhiro Iwamatsu
Cc: cip-dev, Ulrich Hecht, Pavel Machek, Bart Van Assche, Alan Stern,
Yi Zhang, stable, Martin K . Petersen
On Wed, Jun 25, 2025 at 11:00:26AM +0900, Nobuhiro Iwamatsu wrote:
> From: Bart Van Assche <bvanassche@acm.org>
>
> commit fc663711b94468f4e1427ebe289c9f05669699c9 upstream.
4.4.y is long out-of-support by us, and this is in all activly supported
kenrnels at this time, so why is this sent to us?
confused,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
2025-06-25 7:04 ` Greg KH
@ 2025-06-25 7:18 ` nobuhiro1.iwamatsu
0 siblings, 0 replies; 5+ messages in thread
From: nobuhiro1.iwamatsu @ 2025-06-25 7:18 UTC (permalink / raw)
To: gregkh
Cc: cip-dev, uli, pavel, bvanassche, stern, yi.zhang, stable,
martin.petersen
> -----Original Message-----
> From: Greg KH <gregkh@linuxfoundation.org>
> Sent: Wednesday, June 25, 2025 4:05 PM
> To: iwamatsu nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro1.iwamatsu@toshiba.co.jp>
> Cc: cip-dev@lists.cip-project.org; Ulrich Hecht <uli@fpond.eu>; Pavel
> Machek <pavel@denx.de>; Bart Van Assche <bvanassche@acm.org>; Alan
> Stern <stern@rowland.harvard.edu>; Yi Zhang <yi.zhang@redhat.com>;
> stable@vger.kernel.org; Martin K . Petersen <martin.petersen@oracle.com>
> Subject: Re: [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name}
> directory earlier
>
> On Wed, Jun 25, 2025 at 11:00:26AM +0900, Nobuhiro Iwamatsu wrote:
> > From: Bart Van Assche <bvanassche@acm.org>
> >
> > commit fc663711b94468f4e1427ebe289c9f05669699c9 upstream.
>
> 4.4.y is long out-of-support by us, and this is in all activly supported kenrnels at
> this time, so why is this sent to us?
>
This was also sent to stable due to the processing of the patch's CC tag.
I'm sorry for the confusion.
Best regards,
Nobuhiro
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
2025-06-25 2:00 [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier Nobuhiro Iwamatsu
2025-06-25 2:23 ` Alan Stern
2025-06-25 7:04 ` Greg KH
@ 2025-06-25 14:07 ` Sasha Levin
2 siblings, 0 replies; 5+ messages in thread
From: Sasha Levin @ 2025-06-25 14:07 UTC (permalink / raw)
To: stable, nobuhiro1.iwamatsu; +Cc: Sasha Levin
[ Sasha's backport helper bot ]
Hi,
Summary of potential issues:
⚠️ Found follow-up fixes in mainline
The upstream commit SHA1 provided is correct: fc663711b94468f4e1427ebe289c9f05669699c9
WARNING: Author mismatch between patch and upstream commit:
Backport author: Nobuhiro Iwamatsu<nobuhiro1.iwamatsu@toshiba.co.jp>
Commit author: Bart Van Assche<bvanassche@acm.org>
Found fixes commits:
be03df3d4bfe scsi: core: Fix a procfs host directory removal regression
Note: The patch differs from the upstream commit:
---
1: fc663711b9446 < -: ------------- scsi: core: Remove the /proc/scsi/${proc_name} directory earlier
-: ------------- > 1: a2b47f77e740a Linux 6.15.3
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test |
|---------------------------|-------------|------------|
| stable/linux-6.15.y | Success | Success |
| stable/linux-6.12.y | Success | Success |
| stable/linux-6.6.y | Success | Success |
| stable/linux-6.1.y | Success | Success |
| stable/linux-5.15.y | Success | Success |
| stable/linux-5.10.y | Success | Success |
| stable/linux-5.4.y | Success | Success |
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-06-25 14:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25 2:00 [PATCH for 4.4] scsi: core: Remove the /proc/scsi/${proc_name} directory earlier Nobuhiro Iwamatsu
2025-06-25 2:23 ` Alan Stern
2025-06-25 7:04 ` Greg KH
2025-06-25 7:18 ` nobuhiro1.iwamatsu
2025-06-25 14:07 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).