2014-11-16 02:26:58

by Stephan Müller

[permalink] [raw]
Subject: [PATCH v2 06/10] crypto: AF_ALG: make setkey optional

The current AF_ALG implementation requires that a userspace interface
implementation must provide a callback for setkey. Such a call is not
appliable to random number generators.

To prepare AF_ALG for the addition of a random number generator user
space interface, this function callback invocation is made optional.

Signed-off-by: Stephan Mueller <[email protected]>
---
crypto/af_alg.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 635140b..47a199c 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -177,6 +177,9 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
u8 *key;
int err;

+ if (!type->setkey)
+ return -EOPNOTSUPP;
+
key = sock_kmalloc(sk, keylen, GFP_KERNEL);
if (!key)
return -ENOMEM;
--
2.1.0


2014-11-18 14:10:19

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] crypto: AF_ALG: make setkey optional

On Sun, Nov 16, 2014 at 03:26:58AM +0100, Stephan Mueller wrote:
> The current AF_ALG implementation requires that a userspace interface
> implementation must provide a callback for setkey. Such a call is not
> appliable to random number generators.
>
> To prepare AF_ALG for the addition of a random number generator user
> space interface, this function callback invocation is made optional.
>
> Signed-off-by: Stephan Mueller <[email protected]>

Did you actually try this? AFAICS setkey is already optional.

Cheers,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

2014-11-19 02:36:45

by Stephan Müller

[permalink] [raw]
Subject: Re: [PATCH v2 06/10] crypto: AF_ALG: make setkey optional

Am Dienstag, 18. November 2014, 22:10:13 schrieb Herbert Xu:

Hi Herbert,

> On Sun, Nov 16, 2014 at 03:26:58AM +0100, Stephan Mueller wrote:
> > The current AF_ALG implementation requires that a userspace interface
> > implementation must provide a callback for setkey. Such a call is not
> > appliable to random number generators.
> >
> > To prepare AF_ALG for the addition of a random number generator user
> > space interface, this function callback invocation is made optional.
> >
> > Signed-off-by: Stephan Mueller <[email protected]>
>
> Did you actually try this? AFAICS setkey is already optional.

You are correct. I tested the kernel without my patch and the setkey on the
RNG handle is rejected. I now also see the check already present in the
alg_setkey function.

This patch will be removed from a new patchset.
>
> Cheers,


--
Ciao
Stephan