Skip to content

Commit

Permalink
scsi: sd: enable compat ioctls for sed-opal
Browse files Browse the repository at this point in the history
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: linux-scsi@vger.kernel.org
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Arnd Bergmann committed Oct 23, 2019
1 parent 1b114b0 commit 142b2ac
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1692,20 +1692,30 @@ static void sd_rescan(struct device *dev)
static int sd_compat_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
struct scsi_device *sdev = scsi_disk(bdev->bd_disk)->device;
struct gendisk *disk = bdev->bd_disk;
struct scsi_disk *sdkp = scsi_disk(disk);
struct scsi_device *sdev = sdkp->device;
void __user *p = compat_ptr(arg);
int error;

error = scsi_verify_blk_ioctl(bdev, cmd);
if (error < 0)
return error;

error = scsi_ioctl_block_when_processing_errors(sdev, cmd,
(mode & FMODE_NDELAY) != 0);
if (error)
return error;

if (is_sed_ioctl(cmd))
return sed_ioctl(sdkp->opal_dev, cmd, p);

/*
* Let the static ioctl translation table take care of it.
*/
if (!sdev->host->hostt->compat_ioctl)
return -ENOIOCTLCMD;
return sdev->host->hostt->compat_ioctl(sdev, cmd, (void __user *)arg);
return sdev->host->hostt->compat_ioctl(sdev, cmd, p);
}
#endif

Expand Down

0 comments on commit 142b2ac

Please sign in to comment.