- dm-crypt: fix a crash on 32-bit machines

- dm-raid: replace "rdev" with correct loop variable name "r"
 -----BEGIN PGP SIGNATURE-----
 
 iIoEABYIADIWIQRnH8MwLyZDhyYfesYTAyx9YGnhbQUCaFl3iRQcbXBhdG9ja2FA
 cmVkaGF0LmNvbQAKCRATAyx9YGnhbcRMAP92ueTp0NFJr9dJne79HbhpJkBAS+b+
 25/qycKPv2XDfwD/c3/e3sBOhTIK8PohFR7lR62NepdfrOFVaaKubmNUlAU=
 =FD8P
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2025-06-23 15:02:57 -07:00
commit 78f4e737a5
4 changed files with 14 additions and 5 deletions

View File

@ -517,7 +517,10 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv,
{
struct iv_lmk_private *lmk = &cc->iv_gen_private.lmk;
SHASH_DESC_ON_STACK(desc, lmk->hash_tfm);
struct md5_state md5state;
union {
struct md5_state md5state;
u8 state[CRYPTO_MD5_STATESIZE];
} u;
__le32 buf[4];
int i, r;
@ -548,13 +551,13 @@ static int crypt_iv_lmk_one(struct crypt_config *cc, u8 *iv,
return r;
/* No MD5 padding here */
r = crypto_shash_export(desc, &md5state);
r = crypto_shash_export(desc, &u.md5state);
if (r)
return r;
for (i = 0; i < MD5_HASH_WORDS; i++)
__cpu_to_le32s(&md5state.hash[i]);
memcpy(iv, &md5state.hash, cc->iv_size);
__cpu_to_le32s(&u.md5state.hash[i]);
memcpy(iv, &u.md5state.hash, cc->iv_size);
return 0;
}

View File

@ -2407,7 +2407,7 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
*/
sb_retrieve_failed_devices(sb, failed_devices);
rdev_for_each(r, mddev) {
if (test_bit(Journal, &rdev->flags) ||
if (test_bit(Journal, &r->flags) ||
!r->sb_page)
continue;
sb2 = page_address(r->sb_page);

View File

@ -202,6 +202,8 @@ struct shash_desc {
#define HASH_REQUEST_CLONE(name, gfp) \
hash_request_clone(name, sizeof(__##name##_req), gfp)
#define CRYPTO_HASH_STATESIZE(coresize, blocksize) (coresize + blocksize + 1)
/**
* struct shash_alg - synchronous message digest definition
* @init: see struct ahash_alg

View File

@ -2,6 +2,7 @@
#ifndef _CRYPTO_MD5_H
#define _CRYPTO_MD5_H
#include <crypto/hash.h>
#include <linux/types.h>
#define MD5_DIGEST_SIZE 16
@ -15,6 +16,9 @@
#define MD5_H2 0x98badcfeUL
#define MD5_H3 0x10325476UL
#define CRYPTO_MD5_STATESIZE \
CRYPTO_HASH_STATESIZE(MD5_STATE_SIZE, MD5_HMAC_BLOCK_SIZE)
extern const u8 md5_zero_message_hash[MD5_DIGEST_SIZE];
struct md5_state {