Patch "random: use lockless method of accessing and updating f->reg_idx" has been added to the 3.18-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
random: use lockless method of accessing and updating f->reg_idx
to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
random-use-lockless-method-of-accessing-and-updating-f-reg_idx.patch
and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
92e75428ffc90e2a0321062379f883f3671cfebeMon Sep 17 00:00:00 2001
From: Theodore Ts'o <[email protected]>
Date: Wed, 7 Jun 2017 19:01:32 -0400
Subject: random: use lockless method of accessing and updating f->reg_idx
From: Theodore Ts'o <[email protected]>
commit 92e75428ffc90e2a0321062379f883f3671cfebe upstream.
Linus pointed out that there is a much more efficient way of avoiding the problem that we were trying to address in commit 9dfa7bba35ac0:
"fix race in drivers/char/random.c:get_reg()".
--- drivers/char/random.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/char/random.c +6 -6
@@ -863,15 +863,15 @@ static void add_interrupt_bench(cycles_tstatic __u32 get_reg (struct fast_pool *f,struct pt_regs *regs) {__u32 *ptr = (__u32 *) regs; -unsigned long flags; +unsigned int idx;if (regs ==NULL )return 0 ; -local_irq_save (flags); -if (f->reg_idx >=sizeof (struct pt_regs ) /sizeof (__u32)) - f->reg_idx =0 ; - ptr += f->reg_idx++; -local_irq_restore (flags); + idx =READ_ONCE (f->reg_idx); +if (idx >=sizeof (struct pt_regs ) /sizeof (__u32)) + idx =0 ; + ptr += idx++; +WRITE_ONCE (f->reg_idx, idx);return *ptr; }
Patches currently in stable-queue which might be from [email protected] are
queue-3.18/fix-race-in-drivers-char-random.c-get_reg.patch queue-3.18/ext4-fix-off-by-one-on-max-nr_pages-in-ext4_find_unwritten_pgoff.patch queue-3.18/random-use-lockless-method-of-accessing-and-updating-f-reg_idx.patch