Skip to content

Commit 3d053d5

Browse files
Kamil Koniecznyherbertx
authored andcommitted
crypto: hash - Prevent use of req->result in ahash update
Prevent improper use of req->result field in ahash update, init, export and import functions in drivers code. A driver should use ahash request context if it needs to save internal state. Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 5bfa7ac commit 3d053d5

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎include/crypto/hash.h‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ struct ahash_request {
7474
* @init: **[mandatory]** Initialize the transformation context. Intended only to initialize the
7575
* state of the HASH transformation at the beginning. This shall fill in
7676
* the internal structures used during the entire duration of the whole
77-
* transformation. No data processing happens at this point.
77+
* transformation. No data processing happens at this point. Driver code
78+
* implementation must not use req->result.
7879
* @update: **[mandatory]** Push a chunk of data into the driver for transformation. This
7980
* function actually pushes blocks of data from upper layers into the
8081
* driver, which then passes those to the hardware as seen fit. This
@@ -83,7 +84,8 @@ struct ahash_request {
8384
* transformation. This function shall not modify the transformation
8485
* context, as this function may be called in parallel with the same
8586
* transformation object. Data processing can happen synchronously
86-
* [SHASH] or asynchronously [AHASH] at this point.
87+
* [SHASH] or asynchronously [AHASH] at this point. Driver must not use
88+
* req->result.
8789
* @final: **[mandatory]** Retrieve result from the driver. This function finalizes the
8890
* transformation and retrieves the resulting hash from the driver and
8991
* pushes it back to upper layers. No data processing happens at this
@@ -120,11 +122,12 @@ struct ahash_request {
120122
* you want to save partial result of the transformation after
121123
* processing certain amount of data and reload this partial result
122124
* multiple times later on for multiple re-use. No data processing
123-
* happens at this point.
125+
* happens at this point. Driver must not use req->result.
124126
* @import: Import partial state of the transformation. This function loads the
125127
* entire state of the ongoing transformation from a provided block of
126128
* data so the transformation can continue from this point onward. No
127-
* data processing happens at this point.
129+
* data processing happens at this point. Driver must not use
130+
* req->result.
128131
* @halg: see struct hash_alg_common
129132
*/
130133
struct ahash_alg {

0 commit comments

Comments
 (0)