Skip to content

Commit 6d9529c

Browse files
pdxChenherbertx
authored andcommitted
crypto: hash - initialize entry len for null input in crypto hash sg list walk
For the special case when we have a null input string, we want to initialize the entry len to 0 for the hash/ahash walk, so cyrpto_hash_walk_last will return the correct result indicating that we have completed the scatter list walk. Otherwise we may keep walking the sg list and access bogus memory address. Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 7d1311b commit 6d9529c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎crypto/ahash.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,10 @@ int crypto_hash_walk_first(struct ahash_request *req,
131131
{
132132
walk->total = req->nbytes;
133133

134-
if (!walk->total)
134+
if (!walk->total) {
135+
walk->entrylen = 0;
135136
return 0;
137+
}
136138

137139
walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
138140
walk->sg = req->src;
@@ -147,8 +149,10 @@ int crypto_ahash_walk_first(struct ahash_request *req,
147149
{
148150
walk->total = req->nbytes;
149151

150-
if (!walk->total)
152+
if (!walk->total) {
153+
walk->entrylen = 0;
151154
return 0;
155+
}
152156

153157
walk->alignmask = crypto_ahash_alignmask(crypto_ahash_reqtfm(req));
154158
walk->sg = req->src;
@@ -167,8 +171,10 @@ int crypto_hash_walk_first_compat(struct hash_desc *hdesc,
167171
{
168172
walk->total = len;
169173

170-
if (!walk->total)
174+
if (!walk->total) {
175+
walk->entrylen = 0;
171176
return 0;
177+
}
172178

173179
walk->alignmask = crypto_hash_alignmask(hdesc->tfm);
174180
walk->sg = sg;

0 commit comments

Comments
 (0)