mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
profiling: fix sampling step on 64-bit big-endian systems
read_profile() stores the sampling step in an unsigned long but copies
only four bytes to userspace. On 64-bit big-endian systems (not common
obviously), this copies the upper 32 bits and discards the rest, causing
/proc/profile to report zero for normal shift values.
Cast to unsigned int so we get the correct 4 bytes, while keeping the
shift calculation in unsigned long.
A small C reproducer under qemu-s390x reproduced this and proved the fix
works for prof_shift=2.
Link: https://lore.kernel.org/20261020101225.917959-1-thnkslprpt@gmail.com
Fixes: 2d186afd04 ("profiling: fix shift-out-of-bounds bugs")
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Bradley Morgan <brads@mainlining.org>
This commit is contained in:
parent
66644b992f
commit
b1d68946a0
|
|
@ -156,7 +156,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
|
|||
unsigned long p = *ppos;
|
||||
ssize_t read;
|
||||
char *pnt;
|
||||
unsigned long sample_step = 1UL << prof_shift;
|
||||
unsigned int sample_step = (unsigned int)(1UL << prof_shift);
|
||||
|
||||
if (p >= (prof_len+1)*sizeof(unsigned int))
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user