Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'v6.1-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fix from Herbert Xu:
"Fix an alignment crash in x86/polyval"

* tag 'v6.1-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: x86/polyval - Fix crashes when keys are not 16-byte aligned

+14 -5
+14 -5
arch/x86/crypto/polyval-clmulni_glue.c
··· 27 27 #include <asm/cpu_device_id.h> 28 28 #include <asm/simd.h> 29 29 30 + #define POLYVAL_ALIGN 16 31 + #define POLYVAL_ALIGN_ATTR __aligned(POLYVAL_ALIGN) 32 + #define POLYVAL_ALIGN_EXTRA ((POLYVAL_ALIGN - 1) & ~(CRYPTO_MINALIGN - 1)) 33 + #define POLYVAL_CTX_SIZE (sizeof(struct polyval_tfm_ctx) + POLYVAL_ALIGN_EXTRA) 30 34 #define NUM_KEY_POWERS 8 31 35 32 36 struct polyval_tfm_ctx { 33 37 /* 34 38 * These powers must be in the order h^8, ..., h^1. 35 39 */ 36 - u8 key_powers[NUM_KEY_POWERS][POLYVAL_BLOCK_SIZE]; 40 + u8 key_powers[NUM_KEY_POWERS][POLYVAL_BLOCK_SIZE] POLYVAL_ALIGN_ATTR; 37 41 }; 38 42 39 43 struct polyval_desc_ctx { ··· 48 44 asmlinkage void clmul_polyval_update(const struct polyval_tfm_ctx *keys, 49 45 const u8 *in, size_t nblocks, u8 *accumulator); 50 46 asmlinkage void clmul_polyval_mul(u8 *op1, const u8 *op2); 47 + 48 + static inline struct polyval_tfm_ctx *polyval_tfm_ctx(struct crypto_shash *tfm) 49 + { 50 + return PTR_ALIGN(crypto_shash_ctx(tfm), POLYVAL_ALIGN); 51 + } 51 52 52 53 static void internal_polyval_update(const struct polyval_tfm_ctx *keys, 53 54 const u8 *in, size_t nblocks, u8 *accumulator) ··· 81 72 static int polyval_x86_setkey(struct crypto_shash *tfm, 82 73 const u8 *key, unsigned int keylen) 83 74 { 84 - struct polyval_tfm_ctx *tctx = crypto_shash_ctx(tfm); 75 + struct polyval_tfm_ctx *tctx = polyval_tfm_ctx(tfm); 85 76 int i; 86 77 87 78 if (keylen != POLYVAL_BLOCK_SIZE) ··· 111 102 const u8 *src, unsigned int srclen) 112 103 { 113 104 struct polyval_desc_ctx *dctx = shash_desc_ctx(desc); 114 - const struct polyval_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); 105 + const struct polyval_tfm_ctx *tctx = polyval_tfm_ctx(desc->tfm); 115 106 u8 *pos; 116 107 unsigned int nblocks; 117 108 unsigned int n; ··· 152 143 static int polyval_x86_final(struct shash_desc *desc, u8 *dst) 153 144 { 154 145 struct polyval_desc_ctx *dctx = shash_desc_ctx(desc); 155 - const struct polyval_tfm_ctx *tctx = crypto_shash_ctx(desc->tfm); 146 + const struct polyval_tfm_ctx *tctx = polyval_tfm_ctx(desc->tfm); 156 147 157 148 if (dctx->bytes) { 158 149 internal_polyval_mul(dctx->buffer, ··· 176 167 .cra_driver_name = "polyval-clmulni", 177 168 .cra_priority = 200, 178 169 .cra_blocksize = POLYVAL_BLOCK_SIZE, 179 - .cra_ctxsize = sizeof(struct polyval_tfm_ctx), 170 + .cra_ctxsize = POLYVAL_CTX_SIZE, 180 171 .cra_module = THIS_MODULE, 181 172 }, 182 173 };