* + profiling-fix-sampling-step-on-64-bit-big-endian-systems.patch added to mm-nonmm-unstable branch
@ 2026-10-21 0:47 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-21 0:47 UTC (permalink / raw)
To: mm-commits, brads, thnkslprpt, akpm
The patch titled
Subject: profiling: fix sampling step on 64-bit big-endian systems
has been added to the -mm mm-nonmm-unstable branch. Its filename is
profiling-fix-sampling-step-on-64-bit-big-endian-systems.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/profiling-fix-sampling-step-on-64-bit-big-endian-systems.patch
This patch will later appear in the mm-nonmm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Avi Weiss <thnkslprpt@gmail.com>
Subject: profiling: fix sampling step on 64-bit big-endian systems
Date: Tue, 20 Oct 2026 13:12:24 +0300
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: 2d186afd04d6 ("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>
---
kernel/profile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/kernel/profile.c~profiling-fix-sampling-step-on-64-bit-big-endian-systems
+++ a/kernel/profile.c
@@ -156,7 +156,7 @@ read_profile(struct file *file, char __u
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;
_
Patches currently in -mm which might be from thnkslprpt@gmail.com are
profiling-fix-sampling-step-on-64-bit-big-endian-systems.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-21 0:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 0:47 + profiling-fix-sampling-step-on-64-bit-big-endian-systems.patch added to mm-nonmm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.