Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: don't panic host on invalid sgtable count
Date: Fri, 24 Jan 2020 07:23:02 -0800	[thread overview]
Message-ID: <1579879382.3001.4.camel@HansenPartnership.com> (raw)
In-Reply-To: <20200124151607.31375-1-johannes.thumshirn@wdc.com>

On Sat, 2020-01-25 at 00:16 +0900, Johannes Thumshirn wrote:
> If we have an invalid number of entries mapped an sg table, there's
> no need to panic the host, instead we can spit out a warning in dmesg
> and gracefully return an I/O error.

Can we?  This is an assertion failure which should never happen.  If it
does, it's likely an indicator that a system has gone seriously out of
spec for some reason, like internal compromise, CPU/Memory failure or
something else.

The HA view is that panic is appropriate for conditions that should
never happen because it helps the machine fail fast.

James

> While we're at it fix a trailing whitespace in the comment above.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  drivers/scsi/scsi_lib.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 3e7a45d0daca..9bddf54e3def 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -992,12 +992,15 @@ static blk_status_t scsi_init_sgtable(struct
> request *req,
>  			SCSI_INLINE_SG_CNT)))
>  		return BLK_STS_RESOURCE;
>  
> -	/* 
> +	/*
>  	 * Next, walk the list, and fill in the addresses and sizes
> of
>  	 * each segment.
>  	 */
>  	count = blk_rq_map_sg(req->q, req, sdb->table.sgl);
> -	BUG_ON(count > sdb->table.nents);
> +	if (WARN_ON_ONCE(count > sdb->table.nents)) {
> +		sg_free_table_chained(&sdb->table,
> SCSI_INLINE_SG_CNT);
> +		return BLK_STS_IOERR;
> +	}
>  	sdb->table.nents = count;
>  	sdb->length = blk_rq_payload_bytes(req);
>  	return BLK_STS_OK;


  reply	other threads:[~2020-01-24 15:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 15:16 [PATCH] scsi: don't panic host on invalid sgtable count Johannes Thumshirn
2020-01-24 15:23 ` James Bottomley [this message]
2020-01-24 15:27   ` Johannes Thumshirn

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=1579879382.3001.4.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=johannes.thumshirn@wdc.com \
    --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