audk/MdePkg
Laszlo Ersek c128d5281f MdePkg: UefiScsiLib: do not encode LUN in CDB for READ and WRITE
The "SCSI Block Commands - 2" (SBC-2) standard defines bits [7:5] of the
CDB byte 1 as Reserved, for the READ and WRITE commands.

The updated "SCSI Block Commands - 3" (SBC-3) standard defines the same
bitfield as RDPROTECT and WRPROTECT, respectively.

After reviewing the above standards, and the following commits:
- SVN r8331 (git 676e2a32),
- SVN r8334 (git 6b3ecf5c),
we've determined that UefiScsiLib is incorrect in encoding the LUN in this
bitfield for the READ and WRITE commands.

Encoding a nonzero LUN there creates unintended RDPROTECT and WRPROTECT
values, which the recipient device is required to reject if it does not
support protection information, with CHECK CONDITION, ILLEGAL REQUEST,
INVALID FIELD IN CDB:

  ScsiDiskRead10: Check Condition happened!
  ScsiDisk: Sense Key = 0x5 ASC = 0x24!
  ScsiDiskRead10: Check Condition happened!
  ScsiDisk: Sense Key = 0x5 ASC = 0x24!
  ScsiDiskRead10: Check Condition happened!
  ScsiDisk: Sense Key = 0x5 ASC = 0x24!
  ScsiDiskRead10: Check Condition happened!
  ScsiDisk: Sense Key = 0x5 ASC = 0x24!
  FatOpenDevice: read of part_lba failed Device Error

In practice this flaw breaks UefiScsiLib minimally on SCSI disks with
nonzero LUNs that are emulated by QEMU (after QEMU commit 96bdbbab, part
of v1.2.0).

RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1166971

Reported-by: Cole Robinson <crobinso@redhat.com>

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>

Suggested-by: Feng Tian <feng.tian@intel.com>

Contributed-under: TianoCore Contribution Agreement 1.0

Signed-off-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16454 6f19259b-4bc3-4df7-8a09-765794883524
2014-11-28 10:24:41 +00:00
..
Include Added PlatformNotification to ACPI 5.0 PCCT structure. 2014-11-27 02:17:28 +00:00
Library MdePkg: UefiScsiLib: do not encode LUN in CDB for READ and WRITE 2014-11-28 10:24:41 +00:00
Contributions.txt EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
License.txt Update copyright format 2012-04-24 06:49:39 +00:00
MdePkg.dec UEFI 2.4 X509 Certificate Hash and RFC3161 Timestamp Verification support for Secure Boot 2014-11-14 08:41:12 +00:00
MdePkg.dsc Update MdePkg package version from 1.04 to 1.05 2014-09-02 05:10:46 +00:00
MdePkg.uni MdePkg: Convert non DOS format files to DOS format 2014-09-03 08:33:28 +00:00
MdePkgExtra.uni MdePkg: INF/DEC file updates to EDK II packages 2014-08-27 09:39:59 +00:00