Skip to content

Commit 78f4e73

Browse files
committed
Merge tag 'for-6.16/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm
Pull device mapper fixes from Mikulas Patocka: - dm-crypt: fix a crash on 32-bit machines - dm-raid: replace "rdev" with correct loop variable name "r" * tag 'for-6.16/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm: dm-raid: fix variable in journal device check dm-crypt: Extend state buffer size in crypt_iv_lmk_one
2 parents cb0de0e + db53805 commit 78f4e73

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

drivers/md/dm-crypt.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv,
517517
{
518518
struct iv_lmk_private *lmk = &cc->iv_gen_private.lmk;
519519
SHASH_DESC_ON_STACK(desc, lmk->hash_tfm);
520-
struct md5_state md5state;
520+
union {
521+
struct md5_state md5state;
522+
u8 state[CRYPTO_MD5_STATESIZE];
523+
} u;
521524
__le32 buf[4];
522525
int i, r;
523526

@@ -548,13 +551,13 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv,
548551
return r;
549552

550553
/* No MD5 padding here */
551-
r = crypto_shash_export(desc, &md5state);
554+
r = crypto_shash_export(desc, &u.md5state);
552555
if (r)
553556
return r;
554557

555558
for (i = 0; i < MD5_HASH_WORDS; i++)
556-
__cpu_to_le32s(&md5state.hash[i]);
557-
memcpy(iv, &md5state.hash, cc->iv_size);
559+
__cpu_to_le32s(&u.md5state.hash[i]);
560+
memcpy(iv, &u.md5state.hash, cc->iv_size);
558561

559562
return 0;
560563
}

drivers/md/dm-raid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2407,7 +2407,7 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
24072407
*/
24082408
sb_retrieve_failed_devices(sb, failed_devices);
24092409
rdev_for_each(r, mddev) {
2410-
if (test_bit(Journal, &rdev->flags) ||
2410+
if (test_bit(Journal, &r->flags) ||
24112411
!r->sb_page)
24122412
continue;
24132413
sb2 = page_address(r->sb_page);

include/crypto/hash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,8 @@ struct shash_desc {
202202
#define HASH_REQUEST_CLONE(name, gfp) \
203203
hash_request_clone(name, sizeof(__##name##_req), gfp)
204204

205+
#define CRYPTO_HASH_STATESIZE(coresize, blocksize) (coresize + blocksize + 1)
206+
205207
/**
206208
* struct shash_alg - synchronous message digest definition
207209
* @init: see struct ahash_alg

include/crypto/md5.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#ifndef _CRYPTO_MD5_H
33
#define _CRYPTO_MD5_H
44

5+
#include <crypto/hash.h>
56
#include <linux/types.h>
67

78
#define MD5_DIGEST_SIZE 16
@@ -15,6 +16,9 @@
1516
#define MD5_H2 0x98badcfeUL
1617
#define MD5_H3 0x10325476UL
1718

19+
#define CRYPTO_MD5_STATESIZE \
20+
CRYPTO_HASH_STATESIZE(MD5_STATE_SIZE, MD5_HMAC_BLOCK_SIZE)
21+
1822
extern const u8 md5_zero_message_hash[MD5_DIGEST_SIZE];
1923

2024
struct md5_state {

0 commit comments

Comments
 (0)