Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jan 2017 11:34:30 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r311414 - stable/11/sys/cam/scsi
Message-ID:  <201701051134.v05BYUEn053598@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Jan  5 11:34:30 2017
New Revision: 311414
URL: https://svnweb.freebsd.org/changeset/base/311414

Log:
  MFC r310284:
  When writing fixed format sense data, set VALID bit only if provided value
  for INFORMATION field fit into available 4 bytes (has no non-zero bytes
  except last 4), as explicitly required by SPC-5 specification.

Modified:
  stable/11/sys/cam/scsi/scsi_all.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/cam/scsi/scsi_all.c
==============================================================================
--- stable/11/sys/cam/scsi/scsi_all.c	Thu Jan  5 11:33:38 2017	(r311413)
+++ stable/11/sys/cam/scsi/scsi_all.c	Thu Jan  5 11:34:30 2017	(r311414)
@@ -4020,11 +4020,17 @@ scsi_set_sense_data_va(struct scsi_sense
 					data_dest = &sense->info[0];
 					len_to_copy = MIN(sense_len,
 					    sizeof(sense->info));
-					/*
-					 * We're setting the info field, so
-					 * set the valid bit.
-					 */
-					sense->error_code |= SSD_ERRCODE_VALID;
+
+					/* Set VALID bit only if no overflow. */
+					for (i = 0; i < sense_len - len_to_copy;
+					    i++) {
+						if (data[i] != 0)
+							break;
+					}
+					if (i >= sense_len - len_to_copy) {
+						sense->error_code |=
+						    SSD_ERRCODE_VALID;
+					}
 				}
 
 				/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701051134.v05BYUEn053598>