On Wed, Dec 03, 2014 at 08:59:01PM +0100, Stephan Mueller wrote:
>
> +static int rng_recvmsg(struct kiocb *unused, struct socket *sock,
> +                    struct msghdr *msg, size_t len, int flags)
> +{
> +     struct sock *sk = sock->sk;
> +     struct alg_sock *ask = alg_sk(sk);
> +     struct rng_ctx *ctx = ask->private;
> +     int err = -EFAULT;
> +
> +     if (len == 0)
> +             return 0;
> +     if (len > MAXSIZE)
> +             len = MAXSIZE;
> +
> +     lock_sock(sk);

This lock simply protects ctx->result.  Since you're using a
tiny buffer why not just put it on the stack?

> +             u8 *buf = kmalloc(seedsize, GFP_KERNEL);
> +             if (!buf)
> +                     goto err;
> +             get_random_bytes(buf, seedsize);
> +             ret = crypto_rng_reset(private, buf, len);

I think you should leave the seeding and the seed to the user.
Perhaps do it through setsockopt (on the parent socket).

Cheers,
-- 
Email: Herbert Xu <herb...@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to