lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 10 Feb 2009 15:57:49 +1100
From:	Herbert Xu <herbert@...dor.apana.org.au>
To:	Alexander Clouter <alex@...riz.org.uk>
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
Subject: Re: [PATCHv2] hw_random: add timeriomem-rng driver

On Sat, Feb 07, 2009 at 09:53:17AM +0000, Alexander Clouter wrote:
>
> +/*
> + * have data return 1, however return 0 if we have nothing
> + */
> +static int timeriomem_rng_data_present(struct hwrng *rng, int wait)
> +{
> +	s32 delay;
> +
> +	if (rng->priv == 0)
> +		return 1;
> +
> +	if (del_timer_sync(&timeriomem_rng_timer)) {
> +		if (!wait)
> +			return 0;
> +
> +		delay = timeriomem_rng_timer.expires - jiffies;
> +
> +		schedule_timeout_uninterruptible(delay);
> +	}

Sorry, but this just doesn't work for O_NONBLOCK reads.  What'll
happen is that the first failed read will return -EAGAIN, and when
we're called again immediately (because hwrng polling support is
non-existant), it'll just read the data right away because now
there is no timer.

> +static int timeriomem_rng_data_read(struct hwrng *rng, u32 *data)
> +{
> +	unsigned long cur;
> +	s32 delay;
> +
> +	*data = readl(timeriomem_rng_data->address);
> +
> +	if (rng->priv != 0) {
> +		cur = jiffies;
> +
> +		delay = cur - timeriomem_rng_timer.expires;
> +		delay = rng->priv - (delay % rng->priv);
> +
> +		timeriomem_rng_timer.expires = cur + delay;
> +		add_timer(&timeriomem_rng_timer);
> +	}

Instead of deleting the timer above, why not create a rng->present
variable which you set to zero here, and the timer sets it to
non-zero.  Then you just need to return rng->present in your
data_present function.

> +static void timeriomem_rng_trigger(unsigned long dummy)
> +{
> +	del_timer_sync(&timeriomem_rng_timer);
> +}

This is going to create an infinite loop.  There is no point in
deleting yourself.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@...dor.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-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists