Skip to content

Commit fbe1a85

Browse files
Ondrej Mosnacekherbertx
authored andcommitted
crypto: lrw - Fix out-of bounds access on counter overflow
When the LRW block counter overflows, the current implementation returns 128 as the index to the precomputed multiplication table, which has 128 entries. This patch fixes it to return the correct value (127). Fixes: 64470f1 ("[CRYPTO] lrw: Liskov Rivest Wagner, a tweakable narrow block cipher mode") Cc: <stable@vger.kernel.org> # 2.6.20+ Reported-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 331351f commit fbe1a85

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎crypto/lrw.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ static inline int get_index128(be128 *block)
143143
return x + ffz(val);
144144
}
145145

146-
return x;
146+
/*
147+
* If we get here, then x == 128 and we are incrementing the counter
148+
* from all ones to all zeros. This means we must return index 127, i.e.
149+
* the one corresponding to key2*{ 1,...,1 }.
150+
*/
151+
return 127;
147152
}
148153

149154
static int post_crypt(struct skcipher_request *req)

0 commit comments

Comments
 (0)