Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 133841c

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fix from Herbert Xu: "This fixes a crash in the crypto layer exposed by an SCTP test tool" * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: algboss - Hold ref count on larval
2 parents 6554431 + 939e177 commit 133841c

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

crypto/algboss.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ struct cryptomgr_param {
4545
} nu32;
4646
} attrs[CRYPTO_MAX_ATTRS];
4747

48-
char larval[CRYPTO_MAX_ALG_NAME];
4948
char template[CRYPTO_MAX_ALG_NAME];
5049

51-
struct completion *completion;
50+
struct crypto_larval *larval;
5251

5352
u32 otype;
5453
u32 omask;
@@ -87,7 +86,8 @@ static int cryptomgr_probe(void *data)
8786
crypto_tmpl_put(tmpl);
8887

8988
out:
90-
complete_all(param->completion);
89+
complete_all(&param->larval->completion);
90+
crypto_alg_put(&param->larval->alg);
9191
kfree(param);
9292
module_put_and_exit(0);
9393
}
@@ -187,18 +187,19 @@ static int cryptomgr_schedule_probe(struct crypto_larval *larval)
187187
param->otype = larval->alg.cra_flags;
188188
param->omask = larval->mask;
189189

190-
memcpy(param->larval, larval->alg.cra_name, CRYPTO_MAX_ALG_NAME);
191-
192-
param->completion = &larval->completion;
190+
crypto_alg_get(&larval->alg);
191+
param->larval = larval;
193192

194193
thread = kthread_run(cryptomgr_probe, param, "cryptomgr_probe");
195194
if (IS_ERR(thread))
196-
goto err_free_param;
195+
goto err_put_larval;
197196

198197
wait_for_completion_interruptible(&larval->completion);
199198

200199
return NOTIFY_STOP;
201200

201+
err_put_larval:
202+
crypto_alg_put(&larval->alg);
202203
err_free_param:
203204
kfree(param);
204205
err_put_module:

crypto/api.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ EXPORT_SYMBOL_GPL(crypto_alg_sem);
3434
BLOCKING_NOTIFIER_HEAD(crypto_chain);
3535
EXPORT_SYMBOL_GPL(crypto_chain);
3636

37-
static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
38-
{
39-
atomic_inc(&alg->cra_refcnt);
40-
return alg;
41-
}
42-
4337
struct crypto_alg *crypto_mod_get(struct crypto_alg *alg)
4438
{
4539
return try_module_get(alg->cra_module) ? crypto_alg_get(alg) : NULL;

crypto/internal.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ int crypto_register_notifier(struct notifier_block *nb);
103103
int crypto_unregister_notifier(struct notifier_block *nb);
104104
int crypto_probing_notify(unsigned long val, void *v);
105105

106+
static inline struct crypto_alg *crypto_alg_get(struct crypto_alg *alg)
107+
{
108+
atomic_inc(&alg->cra_refcnt);
109+
return alg;
110+
}
111+
106112
static inline void crypto_alg_put(struct crypto_alg *alg)
107113
{
108114
if (atomic_dec_and_test(&alg->cra_refcnt) && alg->cra_destroy)

0 commit comments

Comments
 (0)