All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-16 16:49 ` Arnd Bergmann
  0 siblings, 0 replies; 13+ messages in thread
From: Arnd Bergmann @ 2015-11-16 16:49 UTC (permalink / raw)
  To: James Bottomley, linux-scsi
  Cc: Hannes Reinecke, linux-kernel, linux-arm-kernel, Matthew Wilcox,
	Geert Uytterhoeven, Martin K. Petersen

Building the advansys driver in a big-endian configuration such as
ARM allmodconfig shows a warning:

 drivers/scsi/advansys.c: In function 'adv_build_req':
 include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
 drivers/scsi/advansys.c:7806:22: note: in expansion of macro 'cpu_to_le32'
   scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);

It turns out that the commit that introduced this used the cpu_to_le32()
incorrectly on an 8-bit field, which results in the sense_len to always
be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
byte of the 32-bit intermediate.

This removes the cpu_to_le32() call to restore the original version.

I found this only by looking at the compiler output and have not done
a full review for possible further endianess bugs in the same driver.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 811ddc057aac ("advansys: use DMA-API for mapping sense buffer")
Cc: stable@vger.kernel.org # v4.2+
---
Using willy@linux.intel.com, as the address listed in MAINTAINERS
failed:

Failed to transport message. Message sending failed since the following recipients were rejected by the server: matthew@wil.cx (The server responded: Requested action not taken: mailbox unavailable invalid DNS MX or A/AAAA resource record)

Geert found the same bug and submitted the same patch earlier:
https://lkml.org/lkml/2015/6/24/89

Neither one has been reviewed or accepted so far. Can we get one of the
two merged please?

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4305178e4e01..1c1cd657c380 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -7803,7 +7803,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 		return ASC_BUSY;
 	}
 	scsiqp->sense_addr = cpu_to_le32(sense_addr);
-	scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
+	scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
 
 	/* Build ADV_SCSI_REQ_Q */
 

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-16 16:49 ` Arnd Bergmann
  0 siblings, 0 replies; 13+ messages in thread
From: Arnd Bergmann @ 2015-11-16 16:49 UTC (permalink / raw)
  To: linux-arm-kernel

Building the advansys driver in a big-endian configuration such as
ARM allmodconfig shows a warning:

 drivers/scsi/advansys.c: In function 'adv_build_req':
 include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
  #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
 drivers/scsi/advansys.c:7806:22: note: in expansion of macro 'cpu_to_le32'
   scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);

It turns out that the commit that introduced this used the cpu_to_le32()
incorrectly on an 8-bit field, which results in the sense_len to always
be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
byte of the 32-bit intermediate.

This removes the cpu_to_le32() call to restore the original version.

I found this only by looking at the compiler output and have not done
a full review for possible further endianess bugs in the same driver.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 811ddc057aac ("advansys: use DMA-API for mapping sense buffer")
Cc: stable at vger.kernel.org # v4.2+
---
Using willy at linux.intel.com, as the address listed in MAINTAINERS
failed:

Failed to transport message. Message sending failed since the following recipients were rejected by the server: matthew at wil.cx (The server responded: Requested action not taken: mailbox unavailable invalid DNS MX or A/AAAA resource record)

Geert found the same bug and submitted the same patch earlier:
https://lkml.org/lkml/2015/6/24/89

Neither one has been reviewed or accepted so far. Can we get one of the
two merged please?

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 4305178e4e01..1c1cd657c380 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -7803,7 +7803,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
 		return ASC_BUSY;
 	}
 	scsiqp->sense_addr = cpu_to_le32(sense_addr);
-	scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
+	scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
 
 	/* Build ADV_SCSI_REQ_Q */
 

^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH, resend] scsi: advansys: fix big-endian builds
  2015-11-16 16:49 ` Arnd Bergmann
@ 2015-11-16 18:20   ` Russell King - ARM Linux
  -1 siblings, 0 replies; 13+ messages in thread
From: Russell King - ARM Linux @ 2015-11-16 18:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James Bottomley, linux-scsi, Martin K. Petersen, linux-kernel,
	Geert Uytterhoeven, Hannes Reinecke, Matthew Wilcox,
	linux-arm-kernel

On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
> It turns out that the commit that introduced this used the cpu_to_le32()
> incorrectly on an 8-bit field, which results in the sense_len to always
> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
> byte of the 32-bit intermediate.

More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
have proper endian annotations?

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-16 18:20   ` Russell King - ARM Linux
  0 siblings, 0 replies; 13+ messages in thread
From: Russell King - ARM Linux @ 2015-11-16 18:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
> It turns out that the commit that introduced this used the cpu_to_le32()
> incorrectly on an 8-bit field, which results in the sense_len to always
> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
> byte of the 32-bit intermediate.

More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
have proper endian annotations?

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, resend] scsi: advansys: fix big-endian builds
  2015-11-16 18:20   ` Russell King - ARM Linux
@ 2015-11-16 18:35     ` Christoph Hellwig
  -1 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2015-11-16 18:35 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Arnd Bergmann, James Bottomley, linux-scsi, Martin K. Petersen,
	linux-kernel, Geert Uytterhoeven, Hannes Reinecke,
	Matthew Wilcox, linux-arm-kernel

On Mon, Nov 16, 2015 at 06:20:31PM +0000, Russell King - ARM Linux wrote:
> On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
> > It turns out that the commit that introduced this used the cpu_to_le32()
> > incorrectly on an 8-bit field, which results in the sense_len to always
> > be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
> > byte of the 32-bit intermediate.
> 
> More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
> have proper endian annotations?

Ho about enabling __CHECK_ENDIAN__ by default when running sparse at
least?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-16 18:35     ` Christoph Hellwig
  0 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2015-11-16 18:35 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 06:20:31PM +0000, Russell King - ARM Linux wrote:
> On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
> > It turns out that the commit that introduced this used the cpu_to_le32()
> > incorrectly on an 8-bit field, which results in the sense_len to always
> > be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
> > byte of the 32-bit intermediate.
> 
> More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
> have proper endian annotations?

Ho about enabling __CHECK_ENDIAN__ by default when running sparse at
least?

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, resend] scsi: advansys: fix big-endian builds
  2015-11-16 18:20   ` Russell King - ARM Linux
  (?)
@ 2015-11-16 18:56     ` Geert Uytterhoeven
  -1 siblings, 0 replies; 13+ messages in thread
From: Geert Uytterhoeven @ 2015-11-16 18:56 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Arnd Bergmann, James Bottomley, scsi, Martin K. Petersen,
	linux-kernel, Hannes Reinecke, Matthew Wilcox, linux-arm-kernel

On Mon, Nov 16, 2015 at 7:20 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
>> It turns out that the commit that introduced this used the cpu_to_le32()
>> incorrectly on an 8-bit field, which results in the sense_len to always
>> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
>> byte of the 32-bit intermediate.
>
> More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
> have proper endian annotations?

Sure.

But in this case, it shows up as a normal compiler warning on all big endian
platforms.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-16 18:56     ` Geert Uytterhoeven
  0 siblings, 0 replies; 13+ messages in thread
From: Geert Uytterhoeven @ 2015-11-16 18:56 UTC (permalink / raw)
  To: Russell King - ARM Linux
  Cc: Arnd Bergmann, James Bottomley, scsi, Martin K. Petersen,
	linux-kernel, Hannes Reinecke, Matthew Wilcox, linux-arm-kernel

On Mon, Nov 16, 2015 at 7:20 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
>> It turns out that the commit that introduced this used the cpu_to_le32()
>> incorrectly on an 8-bit field, which results in the sense_len to always
>> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
>> byte of the 32-bit intermediate.
>
> More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
> have proper endian annotations?

Sure.

But in this case, it shows up as a normal compiler warning on all big endian
platforms.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-16 18:56     ` Geert Uytterhoeven
  0 siblings, 0 replies; 13+ messages in thread
From: Geert Uytterhoeven @ 2015-11-16 18:56 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Nov 16, 2015 at 7:20 PM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:
> On Mon, Nov 16, 2015 at 05:49:23PM +0100, Arnd Bergmann wrote:
>> It turns out that the commit that introduced this used the cpu_to_le32()
>> incorrectly on an 8-bit field, which results in the sense_len to always
>> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
>> byte of the 32-bit intermediate.
>
> More people need to run the sparse checker with -D__CHECK_ENDIAN__ and
> have proper endian annotations?

Sure.

But in this case, it shows up as a normal compiler warning on all big endian
platforms.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, resend] scsi: advansys: fix big-endian builds
  2015-11-16 16:49 ` Arnd Bergmann
@ 2015-11-17  6:46   ` Hannes Reinecke
  -1 siblings, 0 replies; 13+ messages in thread
From: Hannes Reinecke @ 2015-11-17  6:46 UTC (permalink / raw)
  To: Arnd Bergmann, James Bottomley, linux-scsi
  Cc: linux-kernel, linux-arm-kernel, Matthew Wilcox,
	Geert Uytterhoeven, Martin K. Petersen

On 11/16/2015 05:49 PM, Arnd Bergmann wrote:
> Building the advansys driver in a big-endian configuration such as
> ARM allmodconfig shows a warning:
> 
>  drivers/scsi/advansys.c: In function 'adv_build_req':
>  include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
>   #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
>  drivers/scsi/advansys.c:7806:22: note: in expansion of macro 'cpu_to_le32'
>    scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
> 
> It turns out that the commit that introduced this used the cpu_to_le32()
> incorrectly on an 8-bit field, which results in the sense_len to always
> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
> byte of the 32-bit intermediate.
> 
> This removes the cpu_to_le32() call to restore the original version.
> 
> I found this only by looking at the compiler output and have not done
> a full review for possible further endianess bugs in the same driver.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 811ddc057aac ("advansys: use DMA-API for mapping sense buffer")
> Cc: stable@vger.kernel.org # v4.2+
> ---
> Using willy@linux.intel.com, as the address listed in MAINTAINERS
> failed:
> 
> Failed to transport message. Message sending failed since the following recipients were rejected by the server: matthew@wil.cx (The server responded: Requested action not taken: mailbox unavailable invalid DNS MX or A/AAAA resource record)
> 
> Geert found the same bug and submitted the same patch earlier:
> https://lkml.org/lkml/2015/6/24/89
> 
> Neither one has been reviewed or accepted so far. Can we get one of the
> two merged please?
> 
> diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
> index 4305178e4e01..1c1cd657c380 100644
> --- a/drivers/scsi/advansys.c
> +++ b/drivers/scsi/advansys.c
> @@ -7803,7 +7803,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
>  		return ASC_BUSY;
>  	}
>  	scsiqp->sense_addr = cpu_to_le32(sense_addr);
> -	scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
> +	scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
>  
>  	/* Build ADV_SCSI_REQ_Q */
>  
> 
Ho-hum. You are right.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare@suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-17  6:46   ` Hannes Reinecke
  0 siblings, 0 replies; 13+ messages in thread
From: Hannes Reinecke @ 2015-11-17  6:46 UTC (permalink / raw)
  To: linux-arm-kernel

On 11/16/2015 05:49 PM, Arnd Bergmann wrote:
> Building the advansys driver in a big-endian configuration such as
> ARM allmodconfig shows a warning:
> 
>  drivers/scsi/advansys.c: In function 'adv_build_req':
>  include/uapi/linux/byteorder/big_endian.h:32:26: warning: large integer implicitly truncated to unsigned type [-Woverflow]
>   #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
>  drivers/scsi/advansys.c:7806:22: note: in expansion of macro 'cpu_to_le32'
>    scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
> 
> It turns out that the commit that introduced this used the cpu_to_le32()
> incorrectly on an 8-bit field, which results in the sense_len to always
> be set to zero, as the SCSI_SENSE_BUFFERSIZE value gets moved to upper
> byte of the 32-bit intermediate.
> 
> This removes the cpu_to_le32() call to restore the original version.
> 
> I found this only by looking at the compiler output and have not done
> a full review for possible further endianess bugs in the same driver.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 811ddc057aac ("advansys: use DMA-API for mapping sense buffer")
> Cc: stable at vger.kernel.org # v4.2+
> ---
> Using willy at linux.intel.com, as the address listed in MAINTAINERS
> failed:
> 
> Failed to transport message. Message sending failed since the following recipients were rejected by the server: matthew at wil.cx (The server responded: Requested action not taken: mailbox unavailable invalid DNS MX or A/AAAA resource record)
> 
> Geert found the same bug and submitted the same patch earlier:
> https://lkml.org/lkml/2015/6/24/89
> 
> Neither one has been reviewed or accepted so far. Can we get one of the
> two merged please?
> 
> diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
> index 4305178e4e01..1c1cd657c380 100644
> --- a/drivers/scsi/advansys.c
> +++ b/drivers/scsi/advansys.c
> @@ -7803,7 +7803,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,
>  		return ASC_BUSY;
>  	}
>  	scsiqp->sense_addr = cpu_to_le32(sense_addr);
> -	scsiqp->sense_len = cpu_to_le32(SCSI_SENSE_BUFFERSIZE);
> +	scsiqp->sense_len = SCSI_SENSE_BUFFERSIZE;
>  
>  	/* Build ADV_SCSI_REQ_Q */
>  
> 
Ho-hum. You are right.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		               zSeries & Storage
hare at suse.de			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg
GF: F. Imend?rffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG N?rnberg)

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH, resend] scsi: advansys: fix big-endian builds
  2015-11-16 16:49 ` Arnd Bergmann
@ 2015-11-18 15:18   ` Martin K. Petersen
  -1 siblings, 0 replies; 13+ messages in thread
From: Martin K. Petersen @ 2015-11-18 15:18 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: James Bottomley, linux-scsi, Hannes Reinecke, linux-kernel,
	linux-arm-kernel, Matthew Wilcox, Geert Uytterhoeven,
	Martin K. Petersen

>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:

Arnd> Building the advansys driver in a big-endian configuration such as
Arnd> ARM allmodconfig shows a warning:

Applied to 4.4.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH, resend] scsi: advansys: fix big-endian builds
@ 2015-11-18 15:18   ` Martin K. Petersen
  0 siblings, 0 replies; 13+ messages in thread
From: Martin K. Petersen @ 2015-11-18 15:18 UTC (permalink / raw)
  To: linux-arm-kernel

>>>>> "Arnd" == Arnd Bergmann <arnd@arndb.de> writes:

Arnd> Building the advansys driver in a big-endian configuration such as
Arnd> ARM allmodconfig shows a warning:

Applied to 4.4.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-11-18 15:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-16 16:49 [PATCH, resend] scsi: advansys: fix big-endian builds Arnd Bergmann
2015-11-16 16:49 ` Arnd Bergmann
2015-11-16 18:20 ` Russell King - ARM Linux
2015-11-16 18:20   ` Russell King - ARM Linux
2015-11-16 18:35   ` Christoph Hellwig
2015-11-16 18:35     ` Christoph Hellwig
2015-11-16 18:56   ` Geert Uytterhoeven
2015-11-16 18:56     ` Geert Uytterhoeven
2015-11-16 18:56     ` Geert Uytterhoeven
2015-11-17  6:46 ` Hannes Reinecke
2015-11-17  6:46   ` Hannes Reinecke
2015-11-18 15:18 ` Martin K. Petersen
2015-11-18 15:18   ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.