kernel_samsung_a53x/drivers/scsi
Guilherme G. Piccoli 5de1028902 scsi: core: Fix unremoved procfs host directory regression
commit f23a4d6e07570826fe95023ca1aa96a011fa9f84 upstream.

Commit fc663711b944 ("scsi: core: Remove the /proc/scsi/${proc_name}
directory earlier") fixed a bug related to modules loading/unloading, by
adding a call to scsi_proc_hostdir_rm() on scsi_remove_host(). But that led
to a potential duplicate call to the hostdir_rm() routine, since it's also
called from scsi_host_dev_release(). That triggered a regression report,
which was then fixed by commit be03df3d4bfe ("scsi: core: Fix a procfs host
directory removal regression"). The fix just dropped the hostdir_rm() call
from dev_release().

But it happens that this proc directory is created on scsi_host_alloc(),
and that function "pairs" with scsi_host_dev_release(), while
scsi_remove_host() pairs with scsi_add_host(). In other words, it seems the
reason for removing the proc directory on dev_release() was meant to cover
cases in which a SCSI host structure was allocated, but the call to
scsi_add_host() didn't happen. And that pattern happens to exist in some
error paths, for example.

Syzkaller causes that by using USB raw gadget device, error'ing on
usb-storage driver, at usb_stor_probe2(). By checking that path, we can see
that the BadDevice label leads to a scsi_host_put() after a SCSI host
allocation, but there's no call to scsi_add_host() in such path. That leads
to messages like this in dmesg (and a leak of the SCSI host proc
structure):

usb-storage 4-1:87.51: USB Mass Storage device detected
proc_dir_entry 'scsi/usb-storage' already registered
WARNING: CPU: 1 PID: 3519 at fs/proc/generic.c:377 proc_register+0x347/0x4e0 fs/proc/generic.c:376

The proper fix seems to still call scsi_proc_hostdir_rm() on dev_release(),
but guard that with the state check for SHOST_CREATED; there is even a
comment in scsi_host_dev_release() detailing that: such conditional is
meant for cases where the SCSI host was allocated but there was no calls to
{add,remove}_host(), like the usb-storage case.

This is what we propose here and with that, the error path of usb-storage
does not trigger the warning anymore.

Reported-by: syzbot+c645abf505ed21f931b5@syzkaller.appspotmail.com
Fixes: be03df3d4bfe ("scsi: core: Fix a procfs host directory removal regression")
Cc: stable@vger.kernel.org
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Link: https://lore.kernel.org/r/20240313113006.2834799-1-gpiccoli@igalia.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 09:22:42 +01:00
..
aacraid Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aic7xxx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aic94xx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
arcmsr scsi: arcmsr: Support new PCI device IDs 1883 and 1886 2024-11-18 12:13:12 +01:00
arm Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
be2iscsi scsi: be2iscsi: Fix a memleak in beiscsi_init_wrb_handle() 2024-11-18 12:11:41 +01:00
bfa scsi: bfa: Fix function pointer type mismatch for hcb_qe->cbfn 2024-11-19 08:44:57 +01:00
bnx2fc scsi: bnx2fc: Fix skb double free in bnx2fc_rcv() 2024-11-18 12:12:00 +01:00
bnx2i Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
csiostor scsi: csiostor: Avoid function pointer casts 2024-11-19 08:44:57 +01:00
cxgbi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
cxlflash Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
device_handler scsi: core: Introduce enum scsi_disposition 2024-11-18 12:13:21 +01:00
dpt Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
esas2r Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fcoe scsi: Revert "scsi: fcoe: Fix potential deadlock on &fip->ctlr_lock" 2024-11-18 12:13:29 +01:00
fnic scsi: fnic: Return error if vmalloc() failed 2024-11-18 12:12:31 +01:00
hisi_sas scsi: hisi_sas: Replace with standard error code return value 2024-11-18 12:12:36 +01:00
ibmvscsi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ibmvscsi_tgt Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
isci scsi: isci: Fix an error code problem in isci_io_request_build() 2024-11-18 12:13:21 +01:00
libfc scsi: libfc: Fix up timeout error in fc_fcp_rec_error() 2024-11-18 12:13:12 +01:00
libsas Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lpfc scsi: lpfc: Use unsigned type for num_sge 2024-11-18 22:25:34 +01:00
megaraid scsi: megaraid_sas: Increase register read retry rount from 3 to 30 for selected registers 2024-11-18 11:43:21 +01:00
mpt3sas scsi: mpt3sas: Prevent sending diag_reset when the controller is ready 2024-11-19 08:44:36 +01:00
mvsas Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pcmcia Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pm8001 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qedf Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qedi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qla2xxx scsi: qla2xxx: Fix system crash due to bad pointer access 2024-11-18 12:11:13 +01:00
qla4xxx Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
smartpqi Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
snic Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sym53c8xx_2 Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ufs scsi: ufs: core: Leave space for '\0' in utf8 desc string 2024-11-18 11:43:03 +01:00
3w-9xxx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
3w-9xxx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
3w-sas.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
3w-sas.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
3w-xxxx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
3w-xxxx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
53c700.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
53c700.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
53c700.scr Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
53c700_d.h_shipped Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a100u2w.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a100u2w.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a2091.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a2091.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a3000.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a3000.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
a4000t.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
advansys.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aha152x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aha152x.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aha1542.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aha1542.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aha1740.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
aha1740.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
am53c974.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atari_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atp870u.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
atp870u.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
BusLogic.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
BusLogic.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
bvme6000_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ch.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
constants.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dc395x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dc395x.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dmx3191d.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dpt_i2o.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
dpti.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
esp_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
esp_scsi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fdomain.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fdomain.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fdomain_isa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
fdomain_pci.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
FlashPoint.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
g_NCR5380.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gdth.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gdth.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gdth_ioctl.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gdth_proc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gdth_proc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gvp11.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
gvp11.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hosts.c scsi: core: Fix unremoved procfs host directory regression 2024-11-19 09:22:42 +01:00
hpsa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hpsa.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hpsa_cmd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hptiop.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
hptiop.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
imm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
imm.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
initio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
initio.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ipr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ips.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ips.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iscsi_boot_sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iscsi_tcp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
iscsi_tcp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
jazz_esp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig scsi: jazz_esp: Only build if SCSI core is builtin 2024-11-18 22:25:41 +01:00
lasi700.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
libiscsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
libiscsi_tcp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mac53c94.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mac53c94.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mac_esp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mac_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
megaraid.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
megaraid.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mesh.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mesh.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvme16x_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvme147.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvme147.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvumi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mvumi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
myrb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
myrb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
myrs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
myrs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ncr53c8xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ncr53c8xx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
NCR5380.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
NCR5380.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nsp32.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nsp32.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nsp32_debug.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
nsp32_io.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pmcraid.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
pmcraid.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ppa.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ppa.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ps3rom.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qla1280.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qla1280.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qlogicfas.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qlogicfas408.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qlogicfas408.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qlogicpti.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
qlogicpti.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
raid_class.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
script_asm.pl Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_common.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_debug.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_debugfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_debugfs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_devinfo.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_dh.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_error.c scsi: core: Move scsi_host_busy() out of host lock if it is for per-command 2024-11-18 12:13:26 +01:00
scsi_ioctl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_lib.c scsi: core: Move scsi_host_busy() out of host lock if it is for per-command 2024-11-18 12:13:26 +01:00
scsi_lib_dma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_logging.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_logging.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_netlink.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_pm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_priv.h scsi: core: Move scsi_host_busy() out of host lock for waking up EH handler 2024-11-18 12:13:21 +01:00
scsi_proc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_sas_internal.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_scan.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_srpmb.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_srpmb.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_sysctl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_sysfs.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_trace.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_transport_api.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_transport_fc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_transport_iscsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_transport_sas.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_transport_spi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsi_transport_srp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
scsicam.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sd.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sd.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sd_dif.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sd_zbc.c block: introduce zone_write_granularity limit 2024-11-19 09:22:16 +01:00
sense_codes.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
ses.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sg.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sgiwd93.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sim710.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sni_53c710.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sr.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sr_ioctl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sr_vendor.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
st.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
st.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
st_options.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
stex.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
storvsc_drv.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sun3_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sun3_scsi_vme.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sun3x_esp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
sun_esp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
virtio_scsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmw_pvscsi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
vmw_pvscsi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wd33c93.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wd33c93.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wd719x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
wd719x.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
xen-scsifront.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
zalon.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
zorro7xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
zorro_esp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00