All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Hannes Reinecke <hare@suse.de>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
	Christoph Hellwig <hch@lst.de>,
	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 11:28:13 +0100	[thread overview]
Message-ID: <20170203102813.GC29163@lst.de> (raw)
In-Reply-To: <1486112091-68470-4-git-send-email-hare@suse.de>

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.

> +	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.

  reply	other threads:[~2017-02-03 10:28 UTC|newest]

Thread overview: 19+ 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  9:34     ` Johannes Thumshirn
2017-02-03 10:24   ` Christoph Hellwig
2017-02-03 10:45     ` Hannes Reinecke
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 [this message]
2017-02-03 10:50     ` Hannes Reinecke
2017-02-03 11:46     ` Hannes Reinecke
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=20170203102813.GC29163@lst.de \
    --to=hch@lst.de \
    --cc=dgilbert@interlog.com \
    --cc=hare@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.