Skip to content

Commit 6d7e3d8

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Merge the crypto tree for 4.1 to pull in the changeset that disables algif_aead.
2 parents d725332 + f858c7b commit 6d7e3d8

13 files changed

Lines changed: 77 additions & 42 deletions

File tree

‎arch/arm64/crypto/crc32-arm64.c‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,21 @@ static int chksum_final(struct shash_desc *desc, u8 *out)
147147
{
148148
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
149149

150+
put_unaligned_le32(ctx->crc, out);
151+
return 0;
152+
}
153+
154+
static int chksumc_final(struct shash_desc *desc, u8 *out)
155+
{
156+
struct chksum_desc_ctx *ctx = shash_desc_ctx(desc);
157+
150158
put_unaligned_le32(~ctx->crc, out);
151159
return 0;
152160
}
153161

154162
static int __chksum_finup(u32 crc, const u8 *data, unsigned int len, u8 *out)
155163
{
156-
put_unaligned_le32(~crc32_arm64_le_hw(crc, data, len), out);
164+
put_unaligned_le32(crc32_arm64_le_hw(crc, data, len), out);
157165
return 0;
158166
}
159167

@@ -199,6 +207,14 @@ static int crc32_cra_init(struct crypto_tfm *tfm)
199207
{
200208
struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
201209

210+
mctx->key = 0;
211+
return 0;
212+
}
213+
214+
static int crc32c_cra_init(struct crypto_tfm *tfm)
215+
{
216+
struct chksum_ctx *mctx = crypto_tfm_ctx(tfm);
217+
202218
mctx->key = ~0;
203219
return 0;
204220
}
@@ -229,7 +245,7 @@ static struct shash_alg crc32c_alg = {
229245
.setkey = chksum_setkey,
230246
.init = chksum_init,
231247
.update = chksumc_update,
232-
.final = chksum_final,
248+
.final = chksumc_final,
233249
.finup = chksumc_finup,
234250
.digest = chksumc_digest,
235251
.descsize = sizeof(struct chksum_desc_ctx),
@@ -241,7 +257,7 @@ static struct shash_alg crc32c_alg = {
241257
.cra_alignmask = 0,
242258
.cra_ctxsize = sizeof(struct chksum_ctx),
243259
.cra_module = THIS_MODULE,
244-
.cra_init = crc32_cra_init,
260+
.cra_init = crc32c_cra_init,
245261
}
246262
};
247263

‎arch/arm64/crypto/sha1-ce-glue.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ static int sha1_ce_finup(struct shash_desc *desc, const u8 *data,
7474

7575
static int sha1_ce_final(struct shash_desc *desc, u8 *out)
7676
{
77+
struct sha1_ce_state *sctx = shash_desc_ctx(desc);
78+
79+
sctx->finalize = 0;
7780
kernel_neon_begin_partial(16);
7881
sha1_base_do_finalize(desc, (sha1_block_fn *)sha1_ce_transform);
7982
kernel_neon_end();

‎arch/arm64/crypto/sha2-ce-glue.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ static int sha256_ce_finup(struct shash_desc *desc, const u8 *data,
7575

7676
static int sha256_ce_final(struct shash_desc *desc, u8 *out)
7777
{
78+
struct sha256_ce_state *sctx = shash_desc_ctx(desc);
79+
80+
sctx->finalize = 0;
7881
kernel_neon_begin_partial(28);
7982
sha256_base_do_finalize(desc, (sha256_block_fn *)sha2_ce_transform);
8083
kernel_neon_end();

‎arch/s390/crypto/ghash_s390.c‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,23 @@
1616
#define GHASH_DIGEST_SIZE 16
1717

1818
struct ghash_ctx {
19-
u8 icv[16];
20-
u8 key[16];
19+
u8 key[GHASH_BLOCK_SIZE];
2120
};
2221

2322
struct ghash_desc_ctx {
23+
u8 icv[GHASH_BLOCK_SIZE];
24+
u8 key[GHASH_BLOCK_SIZE];
2425
u8 buffer[GHASH_BLOCK_SIZE];
2526
u32 bytes;
2627
};
2728

2829
static int ghash_init(struct shash_desc *desc)
2930
{
3031
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
32+
struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
3133

3234
memset(dctx, 0, sizeof(*dctx));
35+
memcpy(dctx->key, ctx->key, GHASH_BLOCK_SIZE);
3336

3437
return 0;
3538
}
@@ -45,7 +48,6 @@ static int ghash_setkey(struct crypto_shash *tfm,
4548
}
4649

4750
memcpy(ctx->key, key, GHASH_BLOCK_SIZE);
48-
memset(ctx->icv, 0, GHASH_BLOCK_SIZE);
4951

5052
return 0;
5153
}
@@ -54,7 +56,6 @@ static int ghash_update(struct shash_desc *desc,
5456
const u8 *src, unsigned int srclen)
5557
{
5658
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
57-
struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
5859
unsigned int n;
5960
u8 *buf = dctx->buffer;
6061
int ret;
@@ -70,7 +71,7 @@ static int ghash_update(struct shash_desc *desc,
7071
src += n;
7172

7273
if (!dctx->bytes) {
73-
ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf,
74+
ret = crypt_s390_kimd(KIMD_GHASH, dctx, buf,
7475
GHASH_BLOCK_SIZE);
7576
if (ret != GHASH_BLOCK_SIZE)
7677
return -EIO;
@@ -79,7 +80,7 @@ static int ghash_update(struct shash_desc *desc,
7980

8081
n = srclen & ~(GHASH_BLOCK_SIZE - 1);
8182
if (n) {
82-
ret = crypt_s390_kimd(KIMD_GHASH, ctx, src, n);
83+
ret = crypt_s390_kimd(KIMD_GHASH, dctx, src, n);
8384
if (ret != n)
8485
return -EIO;
8586
src += n;
@@ -94,7 +95,7 @@ static int ghash_update(struct shash_desc *desc,
9495
return 0;
9596
}
9697

97-
static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx)
98+
static int ghash_flush(struct ghash_desc_ctx *dctx)
9899
{
99100
u8 *buf = dctx->buffer;
100101
int ret;
@@ -104,24 +105,24 @@ static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx)
104105

105106
memset(pos, 0, dctx->bytes);
106107

107-
ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, GHASH_BLOCK_SIZE);
108+
ret = crypt_s390_kimd(KIMD_GHASH, dctx, buf, GHASH_BLOCK_SIZE);
108109
if (ret != GHASH_BLOCK_SIZE)
109110
return -EIO;
111+
112+
dctx->bytes = 0;
110113
}
111114

112-
dctx->bytes = 0;
113115
return 0;
114116
}
115117

116118
static int ghash_final(struct shash_desc *desc, u8 *dst)
117119
{
118120
struct ghash_desc_ctx *dctx = shash_desc_ctx(desc);
119-
struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm);
120121
int ret;
121122

122-
ret = ghash_flush(ctx, dctx);
123+
ret = ghash_flush(dctx);
123124
if (!ret)
124-
memcpy(dst, ctx->icv, GHASH_BLOCK_SIZE);
125+
memcpy(dst, dctx->icv, GHASH_BLOCK_SIZE);
125126
return ret;
126127
}
127128

‎arch/x86/crypto/sha512-avx2-asm.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ NUM_BLKS = %rdx
7979
c = %rcx
8080
d = %r8
8181
e = %rdx
82-
y3 = %rdi
82+
y3 = %rsi
8383

8484
TBL = %rbp
8585

‎crypto/Kconfig‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,15 +1532,6 @@ config CRYPTO_USER_API_RNG
15321532
This option enables the user-spaces interface for random
15331533
number generator algorithms.
15341534

1535-
config CRYPTO_USER_API_AEAD
1536-
tristate "User-space interface for AEAD cipher algorithms"
1537-
depends on NET
1538-
select CRYPTO_AEAD
1539-
select CRYPTO_USER_API
1540-
help
1541-
This option enables the user-spaces interface for AEAD
1542-
cipher algorithms.
1543-
15441535
config CRYPTO_HASH_INFO
15451536
bool
15461537

‎crypto/algif_aead.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct aead_ctx {
3434
/*
3535
* RSGL_MAX_ENTRIES is an artificial limit where user space at maximum
3636
* can cause the kernel to allocate RSGL_MAX_ENTRIES * ALG_MAX_PAGES
37-
* bytes
37+
* pages
3838
*/
3939
#define RSGL_MAX_ENTRIES ALG_MAX_PAGES
4040
struct af_alg_sgl rsgl[RSGL_MAX_ENTRIES];
@@ -436,11 +436,10 @@ static int aead_recvmsg(struct socket *sock, struct msghdr *msg, size_t ignored,
436436
if (err < 0)
437437
goto unlock;
438438
usedpages += err;
439-
/* chain the new scatterlist with initial list */
439+
/* chain the new scatterlist with previous one */
440440
if (cnt)
441-
scatterwalk_crypto_chain(ctx->rsgl[0].sg,
442-
ctx->rsgl[cnt].sg, 1,
443-
sg_nents(ctx->rsgl[cnt-1].sg));
441+
af_alg_link_sg(&ctx->rsgl[cnt-1], &ctx->rsgl[cnt]);
442+
444443
/* we do not need more iovecs as we have sufficient memory */
445444
if (outlen <= usedpages)
446445
break;

‎drivers/char/hw_random/bcm63xx-rng.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void bcm63xx_rng_cleanup(struct hwrng *rng)
5757
val &= ~RNG_EN;
5858
__raw_writel(val, priv->regs + RNG_CTRL);
5959

60-
clk_didsable_unprepare(prov->clk);
60+
clk_disable_unprepare(priv->clk);
6161
}
6262

6363
static int bcm63xx_rng_data_present(struct hwrng *rng, int wait)
@@ -97,14 +97,14 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
9797
priv->rng.name = pdev->name;
9898
priv->rng.init = bcm63xx_rng_init;
9999
priv->rng.cleanup = bcm63xx_rng_cleanup;
100-
prov->rng.data_present = bcm63xx_rng_data_present;
100+
priv->rng.data_present = bcm63xx_rng_data_present;
101101
priv->rng.data_read = bcm63xx_rng_data_read;
102102

103103
priv->clk = devm_clk_get(&pdev->dev, "ipsec");
104104
if (IS_ERR(priv->clk)) {
105-
error = PTR_ERR(priv->clk);
106-
dev_err(&pdev->dev, "no clock for device: %d\n", error);
107-
return error;
105+
ret = PTR_ERR(priv->clk);
106+
dev_err(&pdev->dev, "no clock for device: %d\n", ret);
107+
return ret;
108108
}
109109

110110
if (!devm_request_mem_region(&pdev->dev, r->start,
@@ -120,11 +120,11 @@ static int bcm63xx_rng_probe(struct platform_device *pdev)
120120
return -ENOMEM;
121121
}
122122

123-
error = devm_hwrng_register(&pdev->dev, &priv->rng);
124-
if (error) {
123+
ret = devm_hwrng_register(&pdev->dev, &priv->rng);
124+
if (ret) {
125125
dev_err(&pdev->dev, "failed to register rng device: %d\n",
126-
error);
127-
return error;
126+
ret);
127+
return ret;
128128
}
129129

130130
dev_info(&pdev->dev, "registered RNG driver\n");

‎drivers/crypto/Kconfig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,9 @@ config CRYPTO_DEV_VMX
466466
source "drivers/crypto/vmx/Kconfig"
467467

468468
config CRYPTO_DEV_IMGTEC_HASH
469-
depends on MIPS || COMPILE_TEST
470469
tristate "Imagination Technologies hardware hash accelerator"
470+
depends on MIPS || COMPILE_TEST
471+
depends on HAS_DMA
471472
select CRYPTO_ALGAPI
472473
select CRYPTO_MD5
473474
select CRYPTO_SHA1

‎include/linux/compiler-gcc.h‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,24 @@
99
+ __GNUC_MINOR__ * 100 \
1010
+ __GNUC_PATCHLEVEL__)
1111

12-
1312
/* Optimization barrier */
13+
1414
/* The "volatile" is due to gcc bugs */
1515
#define barrier() __asm__ __volatile__("": : :"memory")
16+
/*
17+
* This version is i.e. to prevent dead stores elimination on @ptr
18+
* where gcc and llvm may behave differently when otherwise using
19+
* normal barrier(): while gcc behavior gets along with a normal
20+
* barrier(), llvm needs an explicit input variable to be assumed
21+
* clobbered. The issue is as follows: while the inline asm might
22+
* access any memory it wants, the compiler could have fit all of
23+
* @ptr into memory registers instead, and since @ptr never escaped
24+
* from that, it proofed that the inline asm wasn't touching any of
25+
* it. This version works well with both compilers, i.e. we're telling
26+
* the compiler that the inline asm absolutely may see the contents
27+
* of @ptr. See also: https://llvm.org/bugs/show_bug.cgi?id=15495
28+
*/
29+
#define barrier_data(ptr) __asm__ __volatile__("": :"r"(ptr) :"memory")
1630

1731
/*
1832
* This macro obfuscates arithmetic on a variable address so that gcc

0 commit comments

Comments
 (0)