From owner-svn-src-stable-10@freebsd.org Thu Jan 5 11:35:12 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1B26ECA01DB; Thu, 5 Jan 2017 11:35:12 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DEBAB1335; Thu, 5 Jan 2017 11:35:11 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v05BZBVw053697; Thu, 5 Jan 2017 11:35:11 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v05BZBDe053696; Thu, 5 Jan 2017 11:35:11 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201701051135.v05BZBDe053696@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 5 Jan 2017 11:35:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r311415 - stable/10/sys/cam/scsi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Jan 2017 11:35:12 -0000 Author: mav Date: Thu Jan 5 11:35:10 2017 New Revision: 311415 URL: https://svnweb.freebsd.org/changeset/base/311415 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/10/sys/cam/scsi/scsi_all.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/scsi/scsi_all.c ============================================================================== --- stable/10/sys/cam/scsi/scsi_all.c Thu Jan 5 11:34:30 2017 (r311414) +++ stable/10/sys/cam/scsi/scsi_all.c Thu Jan 5 11:35:10 2017 (r311415) @@ -4019,11 +4019,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; + } } /*