Skip to content

Commit 15539de

Browse files
committed
crypto: af_alg - Forbid the use internal algorithms
The bit CRYPTO_ALG_INTERNAL was added to stop af_alg from accessing internal algorithms. However, af_alg itself was never modified to actually stop that bit from being used by the user. Therefore the user could always override it by specifying the relevant bit in the type and/or mask. This patch silently discards the bit in both type and mask. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 9fcc704 commit 15539de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

crypto/af_alg.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ EXPORT_SYMBOL_GPL(af_alg_release);
127127

128128
static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
129129
{
130+
const u32 forbidden = CRYPTO_ALG_INTERNAL;
130131
struct sock *sk = sock->sk;
131132
struct alg_sock *ask = alg_sk(sk);
132133
struct sockaddr_alg *sa = (void *)uaddr;
@@ -151,7 +152,9 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
151152
if (IS_ERR(type))
152153
return PTR_ERR(type);
153154

154-
private = type->bind(sa->salg_name, sa->salg_feat, sa->salg_mask);
155+
private = type->bind(sa->salg_name,
156+
sa->salg_feat & ~forbidden,
157+
sa->salg_mask & ~forbidden);
155158
if (IS_ERR(private)) {
156159
module_put(type->owner);
157160
return PTR_ERR(private);

0 commit comments

Comments
 (0)