* [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request
[not found] <20170525184327.23570-1-bart.vanassche@sandisk.com>
@ 2017-05-25 18:43 ` Bart Van Assche
2017-05-25 18:48 ` J . Bruce Fields
2017-05-26 6:10 ` Christoph Hellwig
0 siblings, 2 replies; 6+ messages in thread
From: Bart Van Assche @ 2017-05-25 18:43 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Christoph Hellwig, Bart Van Assche, J . Bruce Fields,
Jeff Layton, Jens Axboe, Omar Sandoval, linux-nfs
Since using scsi_req() is only allowed against request queues for
which struct scsi_request is the first member of their private
request data, refuse to submit SCSI commands against a queue for
which this is not the case.
References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: J. Bruce Fields <bfields@fieldses.org>
Cc: Jeff Layton <jlayton@poochiereds.net>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Omar Sandoval <osandov@fb.com>
Cc: linux-nfs@vger.kernel.org
Cc: linux-block@vger.kernel.org
---
fs/nfsd/blocklayout.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
index fb5213afc854..38e14cf7e74a 100644
--- a/fs/nfsd/blocklayout.c
+++ b/fs/nfsd/blocklayout.c
@@ -219,6 +219,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
u8 *buf, *d, type, assoc;
int error;
+ if (WARN_ON_ONCE(!blk_queue_scsi_pdu(q)))
+ return -EINVAL;
+
buf = kzalloc(bufflen, GFP_KERNEL);
if (!buf)
return -ENOMEM;
--
2.12.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request
2017-05-25 18:43 ` [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request Bart Van Assche
@ 2017-05-25 18:48 ` J . Bruce Fields
2017-05-25 20:19 ` Bart Van Assche
2017-05-26 6:10 ` Christoph Hellwig
1 sibling, 1 reply; 6+ messages in thread
From: J . Bruce Fields @ 2017-05-25 18:48 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Christoph Hellwig, Jeff Layton,
Jens Axboe, Omar Sandoval, linux-nfs
On Thu, May 25, 2017 at 11:43:14AM -0700, Bart Van Assche wrote:
> Since using scsi_req() is only allowed against request queues for
> which struct scsi_request is the first member of their private
> request data, refuse to submit SCSI commands against a queue for
> which this is not the case.
Is it possible we could catch this earlier and avoid giving out the
layout in the first place?
--b.
>
> References: commit 82ed4db499b8 ("block: split scsi_request out of struct request")
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Reviewed-by: Hannes Reinecke <hare@suse.com>
> Cc: J. Bruce Fields <bfields@fieldses.org>
> Cc: Jeff Layton <jlayton@poochiereds.net>
> Cc: Jens Axboe <axboe@fb.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Omar Sandoval <osandov@fb.com>
> Cc: linux-nfs@vger.kernel.org
> Cc: linux-block@vger.kernel.org
> ---
> fs/nfsd/blocklayout.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c
> index fb5213afc854..38e14cf7e74a 100644
> --- a/fs/nfsd/blocklayout.c
> +++ b/fs/nfsd/blocklayout.c
> @@ -219,6 +219,9 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
> u8 *buf, *d, type, assoc;
> int error;
>
> + if (WARN_ON_ONCE(!blk_queue_scsi_pdu(q)))
> + return -EINVAL;
> +
> buf = kzalloc(bufflen, GFP_KERNEL);
> if (!buf)
> return -ENOMEM;
> --
> 2.12.2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request
2017-05-25 18:48 ` J . Bruce Fields
@ 2017-05-25 20:19 ` Bart Van Assche
2017-05-26 6:10 ` hch
0 siblings, 1 reply; 6+ messages in thread
From: Bart Van Assche @ 2017-05-25 20:19 UTC (permalink / raw)
To: bfields@fieldses.org
Cc: hch@lst.de, jlayton@poochiereds.net, linux-block@vger.kernel.org,
osandov@fb.com, axboe@fb.com, axboe@kernel.dk,
linux-nfs@vger.kernel.org
On Thu, 2017-05-25 at 14:48 -0400, J . Bruce Fields wrote:
> On Thu, May 25, 2017 at 11:43:14AM -0700, Bart Van Assche wrote:
> > Since using scsi_req() is only allowed against request queues for
> > which struct scsi_request is the first member of their private
> > request data, refuse to submit SCSI commands against a queue for
> > which this is not the case.
>=20
> Is it possible we could catch this earlier and avoid giving out the
> layout in the first place?
Hello Christoph,
According to what I see in commit 8650b8a05850 you are the author of this
code? Can the blk_queue_scsi_pdu(q) test fail in nfsd4_scsi_identify_device=
()?
If so, can nfsd4_layout_verify() be modified in such a way that it prevents
that nfsd4_scsi_proc_getdeviceinfo() is ever called for a non-SCSI queue?
Can you recommend an approach?
Thanks,
Bart.=
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request
2017-05-25 20:19 ` Bart Van Assche
@ 2017-05-26 6:10 ` hch
2017-05-26 15:47 ` bfields
0 siblings, 1 reply; 6+ messages in thread
From: hch @ 2017-05-26 6:10 UTC (permalink / raw)
To: Bart Van Assche
Cc: bfields@fieldses.org, hch@lst.de, jlayton@poochiereds.net,
linux-block@vger.kernel.org, osandov@fb.com, axboe@fb.com,
axboe@kernel.dk, linux-nfs@vger.kernel.org
On Thu, May 25, 2017 at 08:19:47PM +0000, Bart Van Assche wrote:
> On Thu, 2017-05-25 at 14:48 -0400, J . Bruce Fields wrote:
> > On Thu, May 25, 2017 at 11:43:14AM -0700, Bart Van Assche wrote:
> > > Since using scsi_req() is only allowed against request queues for
> > > which struct scsi_request is the first member of their private
> > > request data, refuse to submit SCSI commands against a queue for
> > > which this is not the case.
> >
> > Is it possible we could catch this earlier and avoid giving out the
> > layout in the first place?
>
> Hello Christoph,
>
> According to what I see in commit 8650b8a05850 you are the author of this
> code? Can the blk_queue_scsi_pdu(q) test fail in nfsd4_scsi_identify_device()?
If the user explicitly asked for a scsi layout export of a non-scsi
device it can.
> If so, can nfsd4_layout_verify() be modified in such a way that it prevents
> that nfsd4_scsi_proc_getdeviceinfo() is ever called for a non-SCSI queue?
> Can you recommend an approach?
Not easily. The only thing we could do is an export time check, that
would refuse the scsi layout export if the device is not capable.
I can look into that, but it will take some time so for now I think we
should go ahead with your series.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request
2017-05-25 18:43 ` [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request Bart Van Assche
2017-05-25 18:48 ` J . Bruce Fields
@ 2017-05-26 6:10 ` Christoph Hellwig
1 sibling, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2017-05-26 6:10 UTC (permalink / raw)
To: Bart Van Assche
Cc: Jens Axboe, linux-block, Christoph Hellwig, J . Bruce Fields,
Jeff Layton, Jens Axboe, Omar Sandoval, linux-nfs
Looks fine,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request
2017-05-26 6:10 ` hch
@ 2017-05-26 15:47 ` bfields
0 siblings, 0 replies; 6+ messages in thread
From: bfields @ 2017-05-26 15:47 UTC (permalink / raw)
To: hch@lst.de
Cc: Bart Van Assche, jlayton@poochiereds.net,
linux-block@vger.kernel.org, osandov@fb.com, axboe@fb.com,
axboe@kernel.dk, linux-nfs@vger.kernel.org
On Fri, May 26, 2017 at 08:10:03AM +0200, hch@lst.de wrote:
> On Thu, May 25, 2017 at 08:19:47PM +0000, Bart Van Assche wrote:
> > On Thu, 2017-05-25 at 14:48 -0400, J . Bruce Fields wrote:
> > > On Thu, May 25, 2017 at 11:43:14AM -0700, Bart Van Assche wrote:
> > > > Since using scsi_req() is only allowed against request queues for
> > > > which struct scsi_request is the first member of their private
> > > > request data, refuse to submit SCSI commands against a queue for
> > > > which this is not the case.
> > >
> > > Is it possible we could catch this earlier and avoid giving out the
> > > layout in the first place?
> >
> > Hello Christoph,
> >
> > According to what I see in commit 8650b8a05850 you are the author of this
> > code? Can the blk_queue_scsi_pdu(q) test fail in nfsd4_scsi_identify_device()?
>
> If the user explicitly asked for a scsi layout export of a non-scsi
> device it can.
>
> > If so, can nfsd4_layout_verify() be modified in such a way that it prevents
> > that nfsd4_scsi_proc_getdeviceinfo() is ever called for a non-SCSI queue?
> > Can you recommend an approach?
>
> Not easily. The only thing we could do is an export time check, that
> would refuse the scsi layout export if the device is not capable.
>
> I can look into that, but it will take some time so for now I think we
> should go ahead with your series.
Fine by me.--b.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-26 15:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170525184327.23570-1-bart.vanassche@sandisk.com>
2017-05-25 18:43 ` [PATCH 06/19] nfsd: Check private request size before submitting a SCSI request Bart Van Assche
2017-05-25 18:48 ` J . Bruce Fields
2017-05-25 20:19 ` Bart Van Assche
2017-05-26 6:10 ` hch
2017-05-26 15:47 ` bfields
2017-05-26 6:10 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).