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]
Message-ID: <20120131155955.GA24356@thunk.org>
Date:	Tue, 31 Jan 2012 10:59:55 -0500
From:	Ted Ts'o <tytso@....edu>
To:	Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Cc:	Matt Mackall <mpm@...enic.com>,
	Greg Kroah-Hartman <greg@...ah.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] char random: fix boot id uniqueness race

On Sun, Jan 29, 2012 at 11:40:12PM -0500, Mathieu Desnoyers wrote:
> Index: linux-2.6-lttng/drivers/char/random.c
> ===================================================================
> --- linux-2.6-lttng.orig/drivers/char/random.c
> +++ linux-2.6-lttng/drivers/char/random.c
> @@ -1231,6 +1231,8 @@ static int min_read_thresh = 8, min_writ
>  static int max_read_thresh = INPUT_POOL_WORDS * 32;
>  static int max_write_thresh = INPUT_POOL_WORDS * 32;
>  static char sysctl_bootid[16];
> +static int boot_id_generated;
> +static DEFINE_MUTEX(boot_id_mutex);

My preference would be to put these statics in proc_do_uuid(), but
that's arguably a nit.

> +	} else {
> +		if (unlikely(!ACCESS_ONCE(boot_id_generated))) {
> +			mutex_lock(&boot_id_mutex);
> +			if (!boot_id_generated) {
> +				generate_random_uuid(uuid);
> +				/* Store uuid before boot_id_generated. */
> +				smp_wmb();
> +				boot_id_generated = 1;
> +			}
> +			mutex_unlock(&boot_id_mutex);
> +		} else {
> +			/* Load boot_id_generated before uuid */
> +			smp_rmb();
> +		}
> +	}

I don't believe the smp_wmb() and smp_rmb() are necessary here; the
mutex_lock() and mutex_unlock() should put the necessary memory
barriers in place.

Regards,

						- Ted
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ