public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address
@ 2014-06-08 22:33 Ben Hutchings
  2014-06-25 11:12 ` Christoph Hellwig
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Hutchings @ 2014-06-08 22:33 UTC (permalink / raw)
  To: James E.J. Bottomley, Anil Gurumurthy, Vijaya Mohan Guvva
  Cc: linux-scsi, stable

[-- Attachment #1: Type: text/plain, Size: 1596 bytes --]

bfa_swap_words() shifts its argument (assumed to be 64-bit) by 32 bits
each way.  In two places the argument type is dma_addr_t, which may be
32-bit, in which case the effect of the bit shift is undefined:

drivers/scsi/bfa/bfa_fcpim.c: In function 'bfa_ioim_send_ioreq':
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: right shift count >= width of type [enabled by default]
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: right shift count >= width of type [enabled by default]

Avoid this by adding casts to u64 in bfa_swap_words().

Compile-tested only.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: stable@vger.kernel.org
Fixes: f16a17507b09 ('[SCSI] bfa: remove all OS wrappers')
---
 drivers/scsi/bfa/bfa_ioc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
index 2e28392..a38aafa0 100644
--- a/drivers/scsi/bfa/bfa_ioc.h
+++ b/drivers/scsi/bfa/bfa_ioc.h
@@ -72,7 +72,7 @@ struct bfa_sge_s {
 } while (0)
 
 #define bfa_swap_words(_x)  (	\
-	((_x) << 32) | ((_x) >> 32))
+	((u64)(_x) << 32) | ((u64)(_x) >> 32))
 
 #ifdef __BIG_ENDIAN
 #define bfa_sge_to_be(_x)

-- 
Ben Hutchings
Never attribute to conspiracy what can adequately be explained by stupidity.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address
@ 2014-06-08 23:48 Ben Hutchings
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Hutchings @ 2014-06-08 23:48 UTC (permalink / raw)
  To: James E.J. Bottomley, M:Anil Gurumurthy, Sudarsana Kalluru
  Cc: linux-scsi, stable

[-- Attachment #1: Type: text/plain, Size: 1672 bytes --]

bfa_swap_words() shifts its argument (assumed to be 64-bit) by 32 bits
each way.  In two places the argument type is dma_addr_t, which may be
32-bit, in which case the effect of the bit shift is undefined:

drivers/scsi/bfa/bfa_fcpim.c: In function 'bfa_ioim_send_ioreq':
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2497:4: warning: right shift count >= width of type [enabled by default]
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: left shift count >= width of type [enabled by default]
    addr = bfa_sgaddr_le(sg_dma_address(sg));
    ^
drivers/scsi/bfa/bfa_fcpim.c:2509:4: warning: right shift count >= width of type [enabled by default]

Avoid this by adding casts to u64 in bfa_swap_words().

Compile-tested only.

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: stable@vger.kernel.org
Fixes: f16a17507b09 ('[SCSI] bfa: remove all OS wrappers')
---
Resending yet again, this time with current maintainer addresses.

Ben.

 drivers/scsi/bfa/bfa_ioc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
index 2e28392..a38aafa0 100644
--- a/drivers/scsi/bfa/bfa_ioc.h
+++ b/drivers/scsi/bfa/bfa_ioc.h
@@ -72,7 +72,7 @@ struct bfa_sge_s {
 } while (0)
 
 #define bfa_swap_words(_x)  (	\
-	((_x) << 32) | ((_x) >> 32))
+	((u64)(_x) << 32) | ((u64)(_x) >> 32))
 
 #ifdef __BIG_ENDIAN
 #define bfa_sge_to_be(_x)


-- 
Ben Hutchings
One of the nice things about standards is that there are so many of them.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

* Re: [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address
  2014-06-08 22:33 [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address Ben Hutchings
@ 2014-06-25 11:12 ` Christoph Hellwig
  2014-06-26  2:21   ` Martin K. Petersen
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Hellwig @ 2014-06-25 11:12 UTC (permalink / raw)
  To: Ben Hutchings
  Cc: James E.J. Bottomley, Anil Gurumurthy, Vijaya Mohan Guvva,
	linux-scsi, stable

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Can I get another review, too please?


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

* Re: [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address
  2014-06-25 11:12 ` Christoph Hellwig
@ 2014-06-26  2:21   ` Martin K. Petersen
  2014-06-26  5:23     ` Anil Gurumurthy
  0 siblings, 1 reply; 5+ messages in thread
From: Martin K. Petersen @ 2014-06-26  2:21 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Ben Hutchings, James E.J. Bottomley, Anil Gurumurthy,
	Vijaya Mohan Guvva, linux-scsi, stable

>>>>> "Christoph" == Christoph Hellwig <hch@infradead.org> writes:

Christoph> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>

Christoph> Can I get another review, too please?

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* RE: [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address
  2014-06-26  2:21   ` Martin K. Petersen
@ 2014-06-26  5:23     ` Anil Gurumurthy
  0 siblings, 0 replies; 5+ messages in thread
From: Anil Gurumurthy @ 2014-06-26  5:23 UTC (permalink / raw)
  To: Martin K. Petersen, Christoph Hellwig
  Cc: Ben Hutchings, James E.J. Bottomley, linux-scsi, stable

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

Acked-by: Anil Gurumurthy <anil.gurumurthy@qlogic.com>


-----Original Message-----
From: linux-scsi-owner@vger.kernel.org [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Martin K. Petersen
Sent: 26 June 2014 07:52
To: Christoph Hellwig
Cc: Ben Hutchings; James E.J. Bottomley; Anil Gurumurthy; Vijaya Mohan Guvva; linux-scsi; stable
Subject: Re: [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address

>>>>> "Christoph" == Christoph Hellwig <hch@infradead.org> writes:

Christoph> Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>

Christoph> Can I get another review, too please?

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>

--
Martin K. Petersen      Oracle Linux Engineering
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html

________________________________

This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 4707 bytes --]

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

end of thread, other threads:[~2014-06-26  5:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-08 22:33 [PATCH RESEND] [SCSI] bfa: Fix undefined bit shift on big-endian architectures with 32-bit DMA address Ben Hutchings
2014-06-25 11:12 ` Christoph Hellwig
2014-06-26  2:21   ` Martin K. Petersen
2014-06-26  5:23     ` Anil Gurumurthy
  -- strict thread matches above, loose matches on Subject: below --
2014-06-08 23:48 Ben Hutchings

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox