public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dgilbert@interlog.com>
To: Tony Battersby <tonyb@cybernetics.com>,
	linux-scsi@vger.kernel.org,
	"James E.J. Bottomley" <JBottomley@parallels.com>,
	Jens Axboe <axboe@fb.com>
Cc: linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH][SCSI] fix regression in SCSI_IOCTL_SEND_COMMAND
Date: Fri, 22 Aug 2014 20:28:27 -0400	[thread overview]
Message-ID: <53F7E02B.4070606@interlog.com> (raw)
In-Reply-To: <53F79FBF.4090000@cybernetics.com>

On 14-08-22 03:53 PM, Tony Battersby wrote:
> blk_rq_set_block_pc() memsets rq->cmd to 0, so it should come
> immediately after blk_get_request() to avoid overwriting the
> user-supplied CDB.  Also check for failure to allocate rq.
>
> Fixes: f27b087b81b7 ("block: add blk_rq_set_block_pc()")
> Cc: <stable@vger.kernel.org> # 3.16.x
> Signed-off-by: Tony Battersby <tonyb@cybernetics.com>

Tested-by: Douglas Gilbert <dgilbert@interlog.com>

> For inclusion in 3.17 and 3.16.x.
>
> Note: I don't have any programs that use this ioctl, so this patch is
> compile-tested only.

To test this ioctl one option is to get the sg3_utils
package and build scsi_ioctl.c in the examples
directory with 'make scsi_ioctl'.

In lk 3.17-rc1, scsi_ioctl indicates that
SCSI_IOCTL_SEND_COMMAND is not working. In my test applying
this patch fixes the regression.

> --- linux-3.17.0-rc1-a/block/scsi_ioctl.c	2014-08-16 12:40:26.000000000 -0400
> +++ linux-3.17.0-rc1-b/block/scsi_ioctl.c	2014-08-22 14:15:34.000000000 -0400
> @@ -448,6 +448,11 @@ int sg_scsi_ioctl(struct request_queue *
>   	}
>
>   	rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_WAIT);
> +	if (!rq) {
> +		err = -ENOMEM;
> +		goto error;
> +	}
> +	blk_rq_set_block_pc(rq);
>
>   	cmdlen = COMMAND_SIZE(opcode);
>
> @@ -501,7 +506,6 @@ int sg_scsi_ioctl(struct request_queue *
>   	memset(sense, 0, sizeof(sense));
>   	rq->sense = sense;
>   	rq->sense_len = 0;
> -	blk_rq_set_block_pc(rq);
>
>   	blk_execute_rq(q, disk, rq, 0);
>
> @@ -521,7 +525,8 @@ out:
>   	
>   error:
>   	kfree(buffer);
> -	blk_put_request(rq);
> +	if (rq)
> +		blk_put_request(rq);
>   	return err;
>   }
>   EXPORT_SYMBOL_GPL(sg_scsi_ioctl);
>
> --

  reply	other threads:[~2014-08-23  0:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-22 19:53 [PATCH][SCSI] fix regression in SCSI_IOCTL_SEND_COMMAND Tony Battersby
2014-08-23  0:28 ` Douglas Gilbert [this message]
2014-08-23  0:31   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53F7E02B.4070606@interlog.com \
    --to=dgilbert@interlog.com \
    --cc=JBottomley@parallels.com \
    --cc=axboe@fb.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tonyb@cybernetics.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox