]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
scsi: NCR5380: Check for invalid reselection target
authorFinn Thain <fthain@telegraphics.com.au>
Thu, 27 Sep 2018 01:17:11 +0000 (11:17 +1000)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 26 Nov 2019 12:16:54 +0000 (13:16 +0100)
BugLink: https://bugs.launchpad.net/bugs/1853915
[ Upstream commit 7ef55f6744c45e3d7c85a3f74ada39b67ac741dd ]

The X3T9.2 specification (draft) says, under "6.1.4.1 RESELECTION", that "the
initiator shall not respond to a RESELECTION phase if other than two SCSI ID
bits are on the DATA BUS." This issue (too many bits set) has been observed in
the wild, so add a check.

Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/scsi/NCR5380.c

index 90136942f4882b90776a7f96dbbe5c9e05bac21f..c67f476447372a75a9623899b64cc8ac3b0067d6 100644 (file)
@@ -2008,6 +2008,11 @@ static void NCR5380_reselect(struct Scsi_Host *instance)
        NCR5380_write(MODE_REG, MR_BASE);
 
        target_mask = NCR5380_read(CURRENT_SCSI_DATA_REG) & ~(hostdata->id_mask);
+       if (!target_mask || target_mask & (target_mask - 1)) {
+               shost_printk(KERN_WARNING, instance,
+                            "reselect: bad target_mask 0x%02x\n", target_mask);
+               return;
+       }
 
        dsprintk(NDEBUG_RESELECTION, instance, "reselect\n");