Bug 185626 - virtio-scsi driver incorrectly encodes LUNs for device
Summary: virtio-scsi driver incorrectly encodes LUNs for device
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Bryan Venteicher
URL:
Keywords:
: 186146 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-01-10 01:50 UTC by Venkatesh Srinivas
Modified: 2018-06-01 18:37 UTC (History)
1 user (show)

See Also:


Attachments
file.txt (956 bytes, text/plain)
2014-01-10 01:50 UTC, Venkatesh Srinivas
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Venkatesh Srinivas 2014-01-10 01:50:00 UTC
The virtio-scsi driver in FreeBSD 9.2-RELEASE (and in -current) encodes CAM LUN identifiers into virtio-scsi identifiers in vtscsi_set_request_lun(). vtscsi_set_request_lun constructs the low byte (lun[3]) of the transport-layer LUN incorrectly, resulting in mapping LUNs [0-255] to LUN 0.

For hypervisors and SCSI targets which emulate REPORT LUNs, this is harmless. For ones that do not, this may result in multiple CAM targets for a single physical target.

Fix: Patch attached with fix.

Fix is tested on qemu from git -master, with REPORT LUNs disabled. Fix is also tested on Google Compute Engine hypervisor.

Patch attached with submission follows:
Comment 1 Bryan Venteicher freebsd_committer freebsd_triage 2014-01-10 23:00:10 UTC
Responsible Changed
From-To: freebsd-bugs->bryanv
Comment 2 dfilter service freebsd_committer freebsd_triage 2014-01-12 17:40:54 UTC
Author: bryanv
Date: Sun Jan 12 17:40:47 2014
New Revision: 260566
URL: http://svnweb.freebsd.org/changeset/base/260566

Log:
  Remove incorrect bit shift when assigning the LUN request field
  
  This caused duplicate targets appearing on Google Compute Engine
  instances.
  
  PR:		kern/185626
  Submitted by:	Venkatesh Srinivas <venkateshs@google.com>
  MFC after:	3 days

Modified:
  head/sys/dev/virtio/scsi/virtio_scsi.c

Modified: head/sys/dev/virtio/scsi/virtio_scsi.c
==============================================================================
--- head/sys/dev/virtio/scsi/virtio_scsi.c	Sun Jan 12 15:35:03 2014	(r260565)
+++ head/sys/dev/virtio/scsi/virtio_scsi.c	Sun Jan 12 17:40:47 2014	(r260566)
@@ -1539,7 +1539,7 @@ vtscsi_set_request_lun(struct ccb_hdr *c
 	lun[0] = 1;
 	lun[1] = ccbh->target_id;
 	lun[2] = 0x40 | ((ccbh->target_lun >> 8) & 0x3F);
-	lun[3] = (ccbh->target_lun >> 8) & 0xFF;
+	lun[3] = ccbh->target_lun & 0xFF;
 }
 
 static void
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Bryan Venteicher freebsd_committer freebsd_triage 2014-01-12 17:41:51 UTC
State Changed
From-To: open->closed

Committed. Thanks!
Comment 4 Bryan Venteicher freebsd_committer freebsd_triage 2018-06-01 18:37:49 UTC
*** Bug 186146 has been marked as a duplicate of this bug. ***