diff mbox series

[01/24] bsg: remove support for SCSI_IOCTL_SEND_COMMAND

Message ID 20210712054816.4147559-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/24] bsg: remove support for SCSI_IOCTL_SEND_COMMAND | expand

Commit Message

Christoph Hellwig July 12, 2021, 5:47 a.m. UTC
SCSI_IOCTL_SEND_COMMAND has been deprecated longer than bsg exists
and has been warning for just as long.  More importantly it harcodes
SCSI CDBs and thus will do the wrong thing on non-scsi bsg nodes.

Fixes: aa387cc89567 ("block: add bsg helper library")
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bsg.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Bart Van Assche July 22, 2021, 5:31 p.m. UTC | #1
On 7/11/21 10:47 PM, Christoph Hellwig wrote:
> SCSI_IOCTL_SEND_COMMAND has been deprecated longer than bsg exists
> and has been warning for just as long.  More importantly it harcodes
> SCSI CDBs and thus will do the wrong thing on non-scsi bsg nodes.
> 
> Fixes: aa387cc89567 ("block: add bsg helper library")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>   block/bsg.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/bsg.c b/block/bsg.c
> index 1f196563ae6c..79b42c5cafeb 100644
> --- a/block/bsg.c
> +++ b/block/bsg.c
> @@ -373,10 +373,13 @@ static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
>   	case SG_GET_RESERVED_SIZE:
>   	case SG_SET_RESERVED_SIZE:
>   	case SG_EMULATED_HOST:
> -	case SCSI_IOCTL_SEND_COMMAND:
>   		return scsi_cmd_ioctl(bd->queue, NULL, file->f_mode, cmd, uarg);
>   	case SG_IO:
>   		return bsg_sg_io(bd->queue, file->f_mode, uarg);
> +	case SCSI_IOCTL_SEND_COMMAND:
> +		pr_warn_ratelimited("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n",
> +				current->comm);
> +		return -EINVAL;
>   	default:
>   		return -ENOTTY;
>   	}

The Fixes: tag will cause this patch to be backported to stable trees. 
Is that intentional?

Anyway:

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Christoph Hellwig July 22, 2021, 7:05 p.m. UTC | #2
On Thu, Jul 22, 2021 at 10:31:13AM -0700, Bart Van Assche wrote:
>> +				current->comm);
>> +		return -EINVAL;
>>   	default:
>>   		return -ENOTTY;
>>   	}
>
> The Fixes: tag will cause this patch to be backported to stable trees. Is 
> that intentional?

Yes, as this ioctl actively does the wrong thing for non-scsi queues.
diff mbox series

Patch

diff --git a/block/bsg.c b/block/bsg.c
index 1f196563ae6c..79b42c5cafeb 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -373,10 +373,13 @@  static long bsg_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case SG_GET_RESERVED_SIZE:
 	case SG_SET_RESERVED_SIZE:
 	case SG_EMULATED_HOST:
-	case SCSI_IOCTL_SEND_COMMAND:
 		return scsi_cmd_ioctl(bd->queue, NULL, file->f_mode, cmd, uarg);
 	case SG_IO:
 		return bsg_sg_io(bd->queue, file->f_mode, uarg);
+	case SCSI_IOCTL_SEND_COMMAND:
+		pr_warn_ratelimited("%s: calling unsupported SCSI_IOCTL_SEND_COMMAND\n",
+				current->comm);
+		return -EINVAL;
 	default:
 		return -ENOTTY;
 	}