Skip to content

Commit 142b2ac

Browse files
committed
scsi: sd: enable compat ioctls for sed-opal
The sed_ioctl() function is written to be compatible between 32-bit and 64-bit processes, however compat mode is only wired up for nvme, not for sd. Add the missing call to sed_ioctl() in sd_compat_ioctl(). Fixes: d80210f ("sd: add support for TCG OPAL self encrypting disks") Cc: [email protected] Cc: "James E.J. Bottomley" <[email protected]> Cc: "Martin K. Petersen" <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 1b114b0 commit 142b2ac

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/scsi/sd.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,20 +1692,30 @@ static void sd_rescan(struct device *dev)
16921692
static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
16931693
unsigned int cmd, unsigned long arg)
16941694
{
1695-
struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
1695+
struct gendisk *disk = bdev->bd_disk;
1696+
struct scsi_disk *sdkp = scsi_disk(disk);
1697+
struct scsi_device *sdev = sdkp->device;
1698+
void __user *p = compat_ptr(arg);
16961699
int error;
16971700

1701+
error = scsi_verify_blk_ioctl(bdev, cmd);
1702+
if (error < 0)
1703+
return error;
1704+
16981705
error = scsi_ioctl_block_when_processing_errors(sdev, cmd,
16991706
(mode & FMODE_NDELAY) != 0);
17001707
if (error)
17011708
return error;
1709+
1710+
if (is_sed_ioctl(cmd))
1711+
return sed_ioctl(sdkp->opal_dev, cmd, p);
17021712

17031713
/*
17041714
* Let the static ioctl translation table take care of it.
17051715
*/
17061716
if (!sdev->host->hostt->compat_ioctl)
17071717
return -ENOIOCTLCMD;
1708-
return sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg);
1718+
return sdev->host->hostt->compat_ioctl(sdev, cmd, p);
17091719
}
17101720
#endif
17111721

0 commit comments

Comments
 (0)