Re: [PATCH] crypto: ccp - fix uninitialized list head

2019-10-21 Thread Hook, Gary
On 10/21/19 10:29 AM, Mark Salter wrote: > A NULL-pointer dereference was reported in fedora bz#1762199 while > reshaping a raid6 array after adding a fifth drive to an existing > array. > > [ 47.343549] md/raid:md0: raid level 6 active with 3 out of 5 devices, > algorithm 2 > [ 47.804017] md

[PATCH v2 2/2] crypto: ccp - Verify access to device registers before initializing

2019-10-21 Thread Hook, Gary
Check early whether device registers can be accessed. Some BIOSes have a broken security policy that prevents access to the device registers, and return values from ioread() can be misinterpreted. If a read of a feature register returns a -1, we may not be able to access any device register, so rep

[PATCH v2 1/2] crypto: ccp - Change a message to reflect status instead of failure

2019-10-21 Thread Hook, Gary
If an AMD BIOS makes zero CCP queues available to the driver, the device is unavailable and therefore can't be activated. When this happens, report the status but don't report a (non-existent) failure. The CCP will be unactivated. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev-v5.c |

[PATCH v2 0/2] Improve CCP error handling messages

2019-10-21 Thread Hook, Gary
This pair of patches is intended to clarify the messaging produced by the CCP driver when known, but non-critical, problems arise. The precipitating conditions can be determined based on simple, unalarming messages in the system log. Changes since V1: - Change hex designation '0X' to '0x' in ccp

[PATCH 1/2] crypto: ccp - Change a message to reflect status instead of failure

2019-10-18 Thread Hook, Gary
If an AMD BIOS makes zero CCP queues available to the driver, the device is unavailable and therefore can't be activated. When this happens, report the status but don't report a (non-existent) failure. The CCP will be unactivated. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev-v5.c |

[PATCH 2/2] crypto: ccp - Verify access to device registers before initializing

2019-10-18 Thread Hook, Gary
Check early whether device registers can be accessed. Some BIOSes have a broken security policy that prevents access to the device registers, and return values from ioread() can be misinterpreted. If a read of a feature register returns a -1, we may not be able to access any device register, so rep

[PATCH 3 0/2] Improve CCP error handling messages

2019-10-18 Thread Hook, Gary
This pair of patches is intended to clarify the messaging produced by the CCP driver when known, but non-critical, problems arise. The precipitating conditions can be determined based on simple, unalarming messages in the system log. --- Gary R Hook (2): crypto: ccp - Change a message to re

Re: [PATCH 04/25] crypto: ccp - switch from ablkcipher to skcipher

2019-10-18 Thread Hook, Gary
On 10/14/19 7:18 AM, Ard Biesheuvel wrote: > Commit 7a7ffe65c8c5 ("crypto: skcipher - Add top-level skcipher interface") > dated 20 august 2015 introduced the new skcipher API which is supposed to > replace both blkcipher and ablkcipher. While all consumers of the API have > been converted long ago

RE: Crypto driver callback problem

2019-09-10 Thread Hook, Gary
*ping* Anyone? -Original Message- From: linux-crypto-ow...@vger.kernel.org On Behalf Of Gary R Hook Sent: Thursday, August 15, 2019 5:32 PM To: linux-crypto@vger.kernel.org Subject: Crypto driver callback problem Context: We've run into a possible locking issue when using the AMD CCP d

[PATCH] crypto: ccp - Ignore unconfigured CCP device on suspend/resume

2019-08-19 Thread Hook, Gary
From: Gary R Hook If a CCP is unconfigured (e.g. there are no available queues) then there will be no data structures allocated for the device. Thus, we must check for validity of a pointer before trying to access structure members. Fixes: 720419f01832f ("crypto: ccp - Introduce the AMD Secure P

[PATCH v2] crypto:ccp - Clean up and exit correctly on allocation failure

2019-07-30 Thread Hook, Gary
From: Gary R Hook Return and fail driver initialization if a DMA pool or coherent memory can't be allocated. Be sure to clean up allocated memory. Fixes: 4b394a232df7 ("crypto: ccp - Let a v5 CCP provide the same function as v3") Signed-off-by: Gary R Hook --- Changes since v1: - Switch to

[PATCH] crypto:ccp - Return from init on allocation failure

2019-07-30 Thread Hook, Gary
Return and fail driver initialization if a DMA pool can't be allocated. Fixes: 4b394a232df7 ("crypto: ccp - Let a v5 CCP provide the same function as v3") Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev-v5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/ccp-d

[PATCH 1/3] crypto: ccp - Fix oops by properly managing allocated structures

2019-07-30 Thread Hook, Gary
From: Gary R Hook A plaintext or ciphertext length of 0 is allowed in AES, in which case no encryption occurs. Ensure that we don't clean up data structures that were never allocated. Fixes: 36cf515b9bbe2 ("crypto: ccp - Enable support for AES GCM on v5 CCPs") Signed-off-by: Gary R Hook --- d

[PATCH 2/3] crypto: ccp - Add support for valid authsize values less than 16

2019-07-30 Thread Hook, Gary
From: Gary R Hook AES GCM encryption allows for authsize values of 4, 8, and 12-16 bytes. Validate the requested authsize, and retain it to save in the request context. Fixes: 36cf515b9bbe2 ("crypto: ccp - Enable support for AES GCM on v5 CCPs") Signed-off-by: Gary R Hook --- drivers/crypto/c

[PATCH 3/3] crypto: ccp - Ignore tag length when decrypting GCM ciphertext

2019-07-30 Thread Hook, Gary
From: Gary R Hook AES GCM input buffers for decryption contain AAD+CTEXT+TAG. Only decrypt the ciphertext, and use the tag for comparison. Fixes: 36cf515b9bbe2 ("crypto: ccp - Enable support for AES GCM on v5 CCPs") Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c | 3 +-- 1 file c

[PATCH 0/3] AES GCM fixes for the CCP crypto driver

2019-07-30 Thread Hook, Gary
Additional testing features added to the crypto framework (including fuzzy probing and variations of the lengths of input parameters such as AAD and authsize) expose some gaps in robustness and function in the CCP driver. Address these gaps: Input text is allowed to be zero bytes in length. In thi

[PATCH v2] crypto: ccp - Log an error message when ccp-crypto fails to load

2019-07-29 Thread Hook, Gary
From: Gary R Hook If there are no CCP devices on the system, ccp-crypto will not load. Write a message to the system log clarifying the reason for the failure of the modprobe operation Signed-off-by: Gary R Hook --- Changes since v1: - Add missing signed-off-by drivers/crypto/ccp/ccp-crypto

[PATCH 2/2] crypto: ccp - Log an error message when ccp-crypto fails to load

2019-07-10 Thread Hook, Gary
If there are no CCP devices on the system, ccp-crypto will not load. Write a message to the system log clarifying the reason for the failure of the modprobe operation --- drivers/crypto/ccp/ccp-crypto-main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/

[PATCH 1/2] crypto: ccp - Include the module name in system log messages

2019-07-10 Thread Hook, Gary
Redefine pr_fmt so that the module name is prefixed to every log message produced by the ccp-crypto module Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-crypto.h | 4 1 file changed, 4 insertions(+) diff --git a/drivers/crypto/ccp/ccp-crypto.h b/drivers/crypto/ccp/ccp-crypto.h inde

[PATCH 0/2] Improve system log messaging in ccp-crypto

2019-07-10 Thread Hook, Gary
From: Gary R Hook Add a prefix to any messages logged by the ccp-crypto module, and add a notice if the module fails to load in the case that no CCPs are defined. Gary R Hook (2): crypto: ccp - Include the module name in system log messages crypto: ccp - Log an error message when ccp-crypto

[PATCH v2] crypto: ccp - memset structure fields to zero before reuse

2019-07-09 Thread Hook, Gary
The AES GCM function reuses an 'op' data structure, which members contain values that must be cleared for each (re)use. This fix resolves a crypto self-test failure: alg: aead: gcm-aes-ccp encryption test failed (wrong result) on test vector 2, cfg="two even aligned splits" Fixes: 36cf515b9bbe (

[PATCH v2 2/4] crypto: ccp - Add a module parameter to specify a queue count

2019-07-09 Thread Hook, Gary
Add a module parameter to limit the number of queues per CCP. The default value (nqueues=0) is to set up every available queue on each device. The count of queues starts from the first one found on the device (which varies based on the device ID). Signed-off-by: Gary R Hook --- drivers/crypto/c

[PATCH v2 4/4] crypto: ccp - Add a module parameter to control registration for DMA

2019-07-09 Thread Hook, Gary
The CCP driver is able to act as a DMA engine. Add a module parameter that allows this feature to be enabled/disabled. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dmaengine.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/ccp/ccp-dmaen

[PATCH v2 3/4] crypto: ccp - module parameter to limit the number of enabled CCPs

2019-07-09 Thread Hook, Gary
Provide the ability to constrain the total number of enabled devices in the system. Once max_devs devices have been configured, subsequently probed devices are ignored. The max_devs parameter may be zero, in which case all CCPs are disabled. PSPs are always enabled and active. Disabling the CCPs

[PATCH v2 1/4] crypto: ccp - Make CCP debugfs support optional

2019-07-09 Thread Hook, Gary
Add a config option to exclude DebugFS support in the CCP driver. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/Kconfig |8 drivers/crypto/ccp/Makefile |4 ++-- drivers/crypto/ccp/ccp-dev-v5.c |4 3 files changed, 14 insertions(+), 2 deletions(-) diff --gi

[PATCH v2 0/4] Add module parameters to control CCP activation

2019-07-09 Thread Hook, Gary
Firstly, add a switch to allow/disallow debugfs code to be built into the CCP driver. This rest of the patch series implements a set of module parameters that allows control over which CCPs on a system are enabled by the driver, and how many queues on each device are activated. A switch to enable

[PATCH] crypto: ccp - memset structure fields to zero before reuse

2019-07-03 Thread Hook, Gary
The AES GCM function reuses an 'op' data structure, which members contain values that must be cleared for each (re)use. Fixes: 36cf515b9bbe ("crypto: ccp - Enable support for AES GCM on v5 CCPs") Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c | 12 +++- 1 file changed, 11

[PATCH] crypto: ccp - Switch to SPDX license identifiers

2019-06-27 Thread Hook, Gary
Add an SPDX identifier and remove any specific statements. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-crypto-aes-cmac.c |5 + drivers/crypto/ccp/ccp-crypto-aes-galois.c |5 + drivers/crypto/ccp/ccp-crypto-aes-xts.c|5 + drivers/crypto/ccp/ccp-crypto-aes.c

[PATCH v2] crypto: ccp - Validate the the error value used to index error messages

2019-06-27 Thread Hook, Gary
The error code read from the queue status register is only 6 bits wide, but we need to verify its value is within range before indexing the error messages. Fixes: 81422badb3907 ("crypto: ccp - Make syslog errors human-readable") Reported-by: Cfir Cohen Signed-off-by: Gary R Hook --- Changes si

[PATCH] crypto: ccp - Validate the the error value used to index error messages

2019-06-25 Thread Hook, Gary
The error code read from the queue status register is only 6 bits wide, but we need to verify its value is within range before indexing the error messages. Also, fill out the array with all possible entries so that any unexpected error codes are reported as "unknown". Fixes: 81422badb3907 ("crypt

[PATCH v2 2/2] crypto: doc - Fix formatting of new crypto engine content

2019-06-25 Thread Hook, Gary
Tidy up the formatting/grammar in crypto_engine.rst. Use bulleted lists where appropriate. Signed-off-by: Gary R Hook --- Documentation/crypto/crypto_engine.rst | 111 +--- 1 file changed, 73 insertions(+), 38 deletions(-) diff --git a/Documentation/crypto/crypto_en

[PATCH v2 0/2] Clean up crypto documentation

2019-06-25 Thread Hook, Gary
Tidy up the crypto documentation by filling in some variable descriptions, make some grammatical corrections, and enhance formatting. Changes since v1: - Remove patch with superfluous change to index (patch 2) - Remove unnecessary markup on function names in patch 3 - Un-add extraneous white sp

[PATCH v2 1/2] crypto: doc - Add parameter documentation

2019-06-25 Thread Hook, Gary
Fill in missing parameter descriptions for the compression algorithm, then pick them up to document for the compression_alg structure. Signed-off-by: Gary R Hook --- Documentation/crypto/api-skcipher.rst |2 +- include/linux/crypto.h| 11 +++ 2 files changed, 12 ins

[PATCH 09/11] crypto: ccp - expose pcibus module parameter in debugfs

2019-06-24 Thread Hook, Gary
Add module parameter pcibus as a read-only variable to the CCP's debugfs info. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-debugfs.c |1 + drivers/crypto/ccp/ccp-dev.h |1 + drivers/crypto/ccp/sp-pci.c | 47 -- 3 files changed, 47

[PATCH 08/11] crypto: ccp - module parameter to allow CCP selection by PCI bus

2019-06-24 Thread Hook, Gary
Add a module parameter that allows specification of one or more CCPs based on PCI bus identifiers. The value of the parameter is a comma- separated list of bus numbers, in no particular order. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/sp-pci.c | 58 +

[PATCH 11/11] crypto: ccp - Expose the registerdma module parameter in DFS

2019-06-24 Thread Hook, Gary
Add a read-only variable to report the value of the parameter Signed-off-by: Gary R Hook --- drivers/crypto/ccp/sp-pci.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index 5b0a9c145c5a..c1c1e05a7c0f 100644 --- a/drivers/crypto/c

[PATCH 10/11] crypto: ccp - Add a module parameter to control registration for DMA

2019-06-24 Thread Hook, Gary
The CCP driver is able to act as a DMA engine. Add a module parameter that allows this feature to be enabled/disabled. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev-v5.c | 11 +++ drivers/crypto/ccp/ccp-dev.h|1 + drivers/crypto/ccp/sp-pci.c |8 3 f

[PATCH 04/11] crypto: ccp - module parameter to limit the number of enabled CCPs

2019-06-24 Thread Hook, Gary
Provide the ability to constrain the total number of enabled devices in the system. Once maxdev devices have been configured, additional devices are ignored. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/sp-pci.c | 16 1 file changed, 16 insertions(+) diff --git a/drivers

[PATCH 05/11] crypto: ccp - Expose maxdev through DebugFS

2019-06-24 Thread Hook, Gary
Add a read-only debugfs entry for the module parameter 'maxdev'. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/sp-pci.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index b81493810689..29177d113c90 100644 --- a/drivers/crypt

[PATCH 06/11] crypto: ccp - Specify a single CCP via PCI device ID

2019-06-24 Thread Hook, Gary
Some processors contain multiple CCPs with differing device IDs. Enable the selection of specific devices based on ID. The parameter value is a single PCI ID. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/sp-pci.c |7 +++ 1 file changed, 7 insertions(+) diff --git a/drivers/crypto/c

[PATCH 07/11] crypto: ccp - expose the pcidev module parameter in debugfs

2019-06-24 Thread Hook, Gary
Add pcidev to the CCP's debugfs information Signed-off-by: Gary R Hook --- drivers/crypto/ccp/sp-pci.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c index b024b92fb749..bcd1e233dce7 100644 --- a/drivers/crypto/ccp/sp-pci.c +++ b/

[PATCH 02/11] crypto: ccp - Add a module parameter to specify a queue count

2019-06-24 Thread Hook, Gary
Add a module parameter to limit the number of queues per CCP. The default (nqueues=0) is to set up every available queue on each device. The count of queues starts from the first one found on the device (which is based on the device ID). Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-dev

[PATCH 03/11] crypto: ccp - Expose the value of nqueues in DebugFS

2019-06-24 Thread Hook, Gary
Make module parameters readable in DebugFS. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-debugfs.c |2 ++ drivers/crypto/ccp/sp-pci.c | 22 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/crypto/ccp/ccp-debugfs.c b/drivers/crypto/ccp/ccp-debugfs

[PATCH 01/11] crypto: ccp - Make CCP debugfs support optional

2019-06-24 Thread Hook, Gary
Add a config option to exclude DebugFS support in the CCP driver. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/Kconfig |9 + drivers/crypto/ccp/Makefile |4 ++-- drivers/crypto/ccp/ccp-dev-v5.c |4 3 files changed, 15 insertions(+), 2 deletions(-) diff --g

[PATCH 00/11] Add module parameters to control CCP activation

2019-06-24 Thread Hook, Gary
Firstly, add a switch to allow/disallow debugfs code to be built into the CCP driver. This rest of the patch series implements a set of module parameters that allow fine-tuned control over which CCPs on a system are enabled by the driver, and how many queues on each device are activated. Lastly,

[PATCH 3/3] crypto: doc - Fix formatting of new crypto engine content

2019-06-24 Thread Hook, Gary
Tidy up the formatting/grammar in crypto_engine.rst. Use lists where appropriate. Signed-off-by: Gary R Hook --- Documentation/crypto/crypto_engine.rst | 120 ++-- 1 file changed, 82 insertions(+), 38 deletions(-) diff --git a/Documentation/crypto/crypto_engine.rst

[PATCH 1/3] crypto: doc - Add parameter documentation

2019-06-24 Thread Hook, Gary
Fill in missing parameter descriptions for the ompression algorithm, then pick them up to document for the compression_alg structure. Signed-off-by: Gary R Hook --- Documentation/crypto/api-skcipher.rst |2 +- include/linux/crypto.h| 11 +++ 2 files changed, 12 inse

[PATCH 2/3] crypto: doc - Describe the crypto engine

2019-06-24 Thread Hook, Gary
Add a reference to the crypto engine documentation to the index. Signed-off-by: Gary R Hook --- Documentation/crypto/index.rst |1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/crypto/index.rst b/Documentation/crypto/index.rst index c4ff5d791233..37cd7fb0ea82 100644 --- a/Docu

[PATCH 0/3] Clean up crypto documentation

2019-06-24 Thread Hook, Gary
Tidy up the crypto documentation by filling in some variable descriptions, make some grammatical corrections, and enhance formatting. --- Gary R Hook (3): crypto: doc - Add parameter documentation crypto: doc - Describe the crypto engine crypto: doc - Fix formatting of new crypt

[PATCH 2/3] crypto: ccp - fix AES CFB error exposed by new test vectors

2019-05-14 Thread Hook, Gary
Updated testmgr will exhibit this error message when loading the ccp-crypto module: alg: skcipher: cfb-aes-ccp encryption failed with err -22 on test vector 3, cfg="in-place" Update the CCP crypto driver to correctly treat CFB as a streaming mode cipher (instead of block mode). Update the config

[PATCH 1/3] crypto: ccp - AES CFB mode is a stream cipher

2019-05-14 Thread Hook, Gary
CFB mode should be treated as a stream cipher, not block. Fixes: 63b945091a07 ('crypto: ccp - CCP device driver and interface support') Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-ops.c |6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/ccp/ccp

[PATCH 3/3] crypto: ccp - Fix 3DES complaint from ccp-crypto module

2019-05-14 Thread Hook, Gary
Crypto self-tests reveal an error: alg: skcipher: cbc-des3-ccp encryption test failed (wrong output IV) on test vector 0, cfg="in-place" The offset value should not be recomputed when retrieving the context. Also, a code path exists which makes decisions based on older (version 3) hardware; a v3

[PATCH] crypto: ccp: fix the SEV probe in kexec boot path

2019-02-07 Thread Hook, Gary
On 1/30/19 2:57 PM, Singh, Brijesh wrote: > A kexec reboot may leave the firmware in INIT or WORKING state. > Currently, we issue PLATFORM_INIT command during the probe without > checking the current state. The PLATFORM_INIT command fails if the > FW is already in INIT state. Lets check the current

[PATCH] crypto/ccp: Update copyright notices and dates

2018-12-18 Thread Hook, Gary
Correct copyright dates for files that have had code added to them in 2018. Signed-off-by: Gary R Hook --- drivers/crypto/ccp/ccp-crypto-aes-cmac.c |2 +- drivers/crypto/ccp/ccp-crypto-sha.c |2 +- drivers/crypto/ccp/ccp-ops.c |2 +- drivers/crypto/ccp/psp-dev.c

Re: [PATCH 2/3] crypto: ccp - return an actual key size from RSA max_size callback

2018-03-02 Thread Hook, Gary
On 3/2/2018 5:15 PM, Maciej S. Szmigiero wrote: On 02.03.2018 17:44, Herbert Xu wrote: On Sat, Feb 24, 2018 at 05:03:21PM +0100, Maciej S. Szmigiero wrote: rsa-pkcs1pad uses a value returned from a RSA implementation max_size callback as a size of an input buffer passed to the RSA implementatio

Re: [PATCH] crypto/ccp: don't disable interrupts while setting up debugfs

2018-02-25 Thread Hook, Gary
On 2/23/2018 5:33 PM, Sebastian Andrzej Siewior wrote: I don't why we need take a single write lock and disable interrupts while setting up debugfs. This is what what happens when we try anyway: There is more than one CCP on some processors. The lock is intended to serialize attempts to initial

Re: [PATCH 1/2] crypto: ccp: Fix sparse, use plain integer as NULL pointer

2018-02-21 Thread Hook, Gary
On 2/15/2018 2:34 PM, Brijesh Singh wrote: Fix sparse warning: Using plain integer as NULL pointer. Replaces assignment of 0 to pointer with NULL assignment. Fixes: 200664d5237f (Add Secure Encrypted Virtualization ...) Cc: Borislav Petkov Cc: Herbert Xu Cc: Gary Hook Cc: Tom Lendacky Signed

Re: [PATCH 2/2] include: psp-sev: Capitalize invalid length enum

2018-02-21 Thread Hook, Gary
On 2/15/2018 2:34 PM, Brijesh Singh wrote: Commit 1d57b17c60ff ("crypto: ccp: Define SEV userspace ioctl and command id") added the invalid length enum but we missed capitalizing it. Fixes: 1d57b17c60ff (crypto: ccp: Define SEV userspace ioctl ...) Cc: Herbert Xu Cc: Borislav Petkov Cc: Tom Le

Re: [PATCH -next] crypto: ccp - Fix non static symbol warning

2016-10-18 Thread Hook, Gary
On 10/17/2016 10:08 AM, Wei Yongjun wrote: > From: Wei Yongjun > > Fixes the following sparse warning: > > drivers/crypto/ccp/ccp-dev.c:44:6: warning: > symbol 'ccp_error_codes' was not declared. Should it be static? > > Signed-off-by: Wei Yongjun > --- > drivers/crypto/ccp/ccp-dev.c | 2 +- >