提交 92d483a8 编写于 作者: J Jason A. Donenfeld 提交者: Zheng Zengkai

random: round-robin registers as ulong, not u32

stable inclusion
from stable-v5.10.119
commit c47f215ab36d678e41dd3aa7710b542e79b0fed1
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5L6BB

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c47f215ab36d678e41dd3aa7710b542e79b0fed1

--------------------------------

commit da3951eb upstream.

When the interrupt handler does not have a valid cycle counter, it calls
get_reg() to read a register from the irq stack, in round-robin.
Currently it does this assuming that registers are 32-bit. This is
_probably_ the case, and probably all platforms without cycle counters
are in fact 32-bit platforms. But maybe not, and either way, it's not
quite correct. This commit fixes that to deal with `unsigned long`
rather than `u32`.

Cc: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: NDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 e229318a
......@@ -1261,15 +1261,15 @@ int random_online_cpu(unsigned int cpu)
}
#endif
static u32 get_reg(struct fast_pool *f, struct pt_regs *regs)
static unsigned long get_reg(struct fast_pool *f, struct pt_regs *regs)
{
u32 *ptr = (u32 *)regs;
unsigned long *ptr = (unsigned long *)regs;
unsigned int idx;
if (regs == NULL)
return 0;
idx = READ_ONCE(f->reg_idx);
if (idx >= sizeof(struct pt_regs) / sizeof(u32))
if (idx >= sizeof(struct pt_regs) / sizeof(unsigned long))
idx = 0;
ptr += idx++;
WRITE_ONCE(f->reg_idx, idx);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册