Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757113Ab3FFImW (ORCPT ); Thu, 6 Jun 2013 04:42:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:46735 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750976Ab3FFImT (ORCPT ); Thu, 6 Jun 2013 04:42:19 -0400 Message-ID: <51B04B68.8080001@suse.de> Date: Thu, 06 Jun 2013 10:42:16 +0200 From: Hannes Reinecke User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: Jan Vesely Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, James Bottomley , Dan Williams Subject: Re: [PATCH] [SCSI] scsilun_to_int should ignore the highest 2 bits References: <1370506691-22933-1-git-send-email-jvesely@redhat.com> In-Reply-To: <1370506691-22933-1-git-send-email-jvesely@redhat.com> X-Enigmail-Version: 1.6a1pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2131 Lines: 58 On 06/06/2013 10:18 AM, Jan Vesely wrote: > From: Jan Vesely > > The comment says the function does this but it does not. > Reported luns change from weirdly high numbers (like 16640) > to something saner (256), when using flat space addressing. > > CC: James Bottomley > CC: Dan Williams > Signed-off-by: Jan Vesely > --- > drivers/scsi/scsi_scan.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c > index 3e58b22..38dc093 100644 > --- a/drivers/scsi/scsi_scan.c > +++ b/drivers/scsi/scsi_scan.c > @@ -1244,7 +1244,7 @@ int scsilun_to_int(struct scsi_lun *scsilun) > > lun = 0; > for (i = 0; i < sizeof(lun); i += 2) > - lun = lun | (((scsilun->scsi_lun[i] << 8) | > + lun = lun | ((((scsilun->scsi_lun[i] & 0x3f) << 8) | > scsilun->scsi_lun[i + 1]) << (i * 8)); > return lun; > } > Bzzt. It's not that simple. For SCSI-3 _all_ numbers are valid, and doesn't know of any addressing scheme. It's only SPC-2 which introduced the addressing scheme. So at the very least you should be checking the scsi revision before attempting something like this. But in general doing a sequential scan past 256 is criminally dangerous. Any array / device attempting to is in most cases misconfigured or does not have the correct BLIST flag set. I know of some older Hitachi and EMC firmware which would pretend to be SCSI-2, but supporting more than 256 LUNs per host. Which, of course, it totally bonkers. I'll be posting my 64-bit LUN patchset, that should fix this issue. Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage hare@suse.de +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: J. Hawn, J. Guild, F. Imend?rffer, HRB 16746 (AG N?rnberg) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/