Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1610525

[PATCH 2/2] crypto: ccp - Mark driver as little-endian only

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject [PATCH 2/2] crypto: ccp - Mark driver as little-endian only
Date 2017-03-28 12:10 +0200
Message-ID <tpWeD-62o-43@gated-at.bofh.it> (permalink)
References <tpWeC-62o-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The driver causes a warning when built as big-endian:

drivers/crypto/ccp/ccp-dev-v5.c: In function 'ccp5_perform_des3':
include/uapi/linux/byteorder/big_endian.h:32:26: error: large integer implicitly truncated to unsigned type [-Werror=overflow]
 #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
                          ^
include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
 #define cpu_to_le32 __cpu_to_le32
                     ^~~~~~~~~~~~~
drivers/crypto/ccp/ccp-dev-v5.c:436:28: note: in expansion of macro 'cpu_to_le32'
  CCP5_CMD_KEY_MEM(&desc) = cpu_to_le32(CCP_MEMTYPE_SB);

The warning is correct, doing a 32-bit byte swap on a value that gets
assigned into a bit field cannot work, since we would only write zeroes
in this case, regardless of the input.

In fact, the use of bit fields in hardware defined data structures is
not portable to start with, so until all these bit fields get replaced
by something else, the driver cannot work on big-endian machines, and
I'm adding an annotation here to prevent it from being selected.

The CCPv3 code seems to not suffer from this problem, only v5 uses
bitfields.

Fixes: 4b394a232df7 ("crypto: ccp - Let a v5 CCP provide the same function as v3")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/crypto/ccp/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/ccp/Kconfig b/drivers/crypto/ccp/Kconfig
index 2238f77aa248..07af9ece84f9 100644
--- a/drivers/crypto/ccp/Kconfig
+++ b/drivers/crypto/ccp/Kconfig
@@ -1,6 +1,7 @@
 config CRYPTO_DEV_CCP_DD
 	tristate "Cryptographic Coprocessor device driver"
 	depends on CRYPTO_DEV_CCP
+	depends on !CPU_BIG_ENDIAN || BROKEN
 	default m
 	select HW_RANDOM
 	select DMA_ENGINE
-- 
2.9.0

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] crypto: ccp - Reduce stack frame size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-28 12:10 +0200
  [PATCH 2/2] crypto: ccp - Mark driver as little-endian only Arnd Bergmann <arnd@arndb.de> - 2017-03-28 12:10 +0200
    Re: [PATCH 2/2] crypto: ccp - Mark driver as little-endian only Arnd Bergmann <arnd@arndb.de> - 2017-03-28 17:10 +0200
  Re: [PATCH 1/2] crypto: ccp - Reduce stack frame size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-28 17:10 +0200
  Re: [PATCH 1/2] crypto: ccp - Reduce stack frame size with KASAN Arnd Bergmann <arnd@arndb.de> - 2017-03-28 17:20 +0200

csiph-web