Re: [PATCH v2 17/27] compat_ioctl: ide: floppy: add handler
From: Arnd Bergmann
Date: Wed Dec 18 2019 - 14:28:42 EST
On Wed, Dec 18, 2019 at 7:45 PM Ben Hutchings
<ben.hutchings@xxxxxxxxxxxxxxx> wrote:
>
> On Tue, 2019-12-17 at 23:16 +0100, Arnd Bergmann wrote:
> > Rather than relying on fs/compat_ioctl.c, this adds support
> > for a compat_ioctl() callback in the ide-floppy driver directly,
> > which lets it translate the scsi commands.
> [...]
>
> After this, and before "compat_ioctl: move HDIO ioctl handling into
> drivers/ide", compat ioctls on an IDE hard drive will result in a null
> pointer dereference in ide_gd_compat_ioctl(). Not sure how much that
> really matters though.
I'm sure it makes no difference in the end, but you are of course right that
this is a bug. I've folded in a check now, and leaving that in place
even after it is no longer needed:
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -348,6 +348,9 @@ static int ide_gd_compat_ioctl(struct block_device
*bdev, fmode_t mode,
struct ide_disk_obj *idkp = ide_drv_g(bdev->bd_disk, ide_disk_obj);
ide_drive_t *drive = idkp->drive;
+ if (!drive->disk_ops->compat_ioctl)
+ return -ENOIOCTLCMD;
+
return drive->disk_ops->compat_ioctl(drive, bdev, mode, cmd, arg);
}
#endif
I pushed out an updated signed tag with this change.
Thanks for the continued careful review!
Arnd