From: Hannes Reinecke <hare@suse.de>
To: Christoph Hellwig <hch@lst.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
James Bottomley <james.bottomley@hansenpartnership.com>,
Johannes Thumshirn <jth@kernel.org>,
Doug Gilberg <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org,
Johannes Thumshirn <jthumshirn@suse.de>
Subject: Re: [PATCH 3/4] sg: check for valid direction before starting the request
Date: Fri, 3 Feb 2017 12:46:48 +0100 [thread overview]
Message-ID: <a3c87f04-dfa2-3bfe-9df2-e8812b572978@suse.de> (raw)
In-Reply-To: <20170203102813.GC29163@lst.de>
On 02/03/2017 11:28 AM, Christoph Hellwig wrote:
> On Fri, Feb 03, 2017 at 09:54:50AM +0100, Hannes Reinecke wrote:
>> From: Johannes Thumshirn <jthumshirn@suse.de>
>>
>> Check for a valid direction before starting the request, otherwise we risk
>> running into an assertion in the scsi midlayer checking for vaild requests.
>
> Good idea, but..
>
>> +static bool sg_is_valid_direction(int dxfer_direction)
>> +{
>> + switch (dxfer_direction) {
>> + case SG_DXFER_NONE:
>> + case SG_DXFER_TO_DEV:
>> + case SG_DXFER_FROM_DEV:
>> + case SG_DXFER_TO_FROM_DEV:
>
> This isn't strictly valid as sg doesn't actually handle real bidi
> commands, but we work around it.
>
> It might be a good idea to move the warning about it from sg_write
> to here and use printk_ratelimited instead of the hand-rolled
> per-thread warning there.
>
Well, that warning is only applicable to sg_write(); sg_new_write() is
supposed to have the correct header, so that warning doesn't apply.
We could drop the per-thread-thingie, though.
>> + case SG_DXFER_UNKNOWN:
>> + return true;
>
> And how valid is this one (Question to Doug I guess): for a 0-sized
> transfer we should be fine, but otherwise it should probably be
> rejected.
>
Yes, true.
Will be fixing it up.
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
next prev parent reply other threads:[~2017-02-03 11:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-03 8:54 [PATCH 0/4] sanitize sg Hannes Reinecke
2017-02-03 8:54 ` [PATCH 1/4] sg: disable SET_FORCE_LOW_DMA Hannes Reinecke
2017-02-03 9:32 ` Johannes Thumshirn
2017-02-03 10:16 ` Hannes Reinecke
2017-02-03 10:23 ` Christoph Hellwig
2017-02-03 8:54 ` [PATCH 2/4] sg: protect access to to 'reserved' page array Hannes Reinecke
2017-02-03 9:34 ` Johannes Thumshirn
2017-02-03 10:24 ` Christoph Hellwig
2017-02-03 10:45 ` Hannes Reinecke
2017-02-03 8:54 ` [PATCH 3/4] sg: check for valid direction before starting the request Hannes Reinecke
2017-02-03 10:28 ` Christoph Hellwig
2017-02-03 10:50 ` Hannes Reinecke
2017-02-03 11:46 ` Hannes Reinecke [this message]
2017-02-03 8:54 ` [PATCH 4/4] sg: use standard lists for sg_requests Hannes Reinecke
2017-02-03 9:38 ` Johannes Thumshirn
2017-02-03 10:43 ` Christoph Hellwig
2017-02-03 10:48 ` Hannes Reinecke
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=a3c87f04-dfa2-3bfe-9df2-e8812b572978@suse.de \
--to=hare@suse.de \
--cc=dgilbert@interlog.com \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=jth@kernel.org \
--cc=jthumshirn@suse.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.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;
as well as URLs for NNTP newsgroup(s).