linux-yocto/tools
Wake Liu 6f9af862a8 selftests/mm: fix thread state check in uffd-unit-tests
commit 632b874d59a36caf829ab5790dafb90f9b350fd6 upstream.

In the thread_state_get() function, the logic to find the thread's state
character was using `sizeof(header) - 1` to calculate the offset from the
"State:\t" string.

The `header` variable is a `const char *` pointer.  `sizeof()` on a
pointer returns the size of the pointer itself, not the length of the
string literal it points to.  This makes the code's behavior dependent on
the architecture's pointer size.

This bug was identified on a 32-bit ARM build (`gsi_tv_arm`) for Android,
running on an ARMv8-based device, compiled with Clang 19.0.1.

On this 32-bit architecture, `sizeof(char *)` is 4.  The expression
`sizeof(header) - 1` resulted in an incorrect offset of 3, causing the
test to read the wrong character from `/proc/[tid]/status` and fail.

On 64-bit architectures, `sizeof(char *)` is 8, so the expression
coincidentally evaluates to 7, which matches the length of "State:\t".
This is why the bug likely remained hidden on 64-bit builds.

To fix this and make the code portable and correct across all
architectures, this patch replaces `sizeof(header) - 1` with
`strlen(header)`.  The `strlen()` function correctly calculates the
string's length, ensuring the correct offset is always used.

Link: https://lkml.kernel.org/r/20251210091408.3781445-1-wakel@google.com
Fixes: f60b6634cd ("mm/selftests: add a test to verify mmap_changing race with -EAGAIN")
Signed-off-by: Wake Liu <wakel@google.com>
Acked-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Bill Wendling <morbo@google.com>
Cc: Justin Stitt <justinstitt@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-01-08 10:17:11 +01:00
..
accounting
arch RISC-V updates for v6.18-rc7 2025-11-22 09:44:50 -08:00
bootconfig
bpf bpftool: Allow bpftool to build with openssl < 3 2025-12-18 14:03:16 +01:00
build perf build: Don't fail fast path feature detection when binutils-devel is not available 2025-11-13 17:16:34 -03:00
certs
cgroup
counter
crypto
debugging
docs
firewire
firmware
gpio
hv
iio
include tools/nolibc/dirent: avoid errno in readdir_r 2025-12-18 14:02:43 +01:00
kvm/kvm_stat
laptop
leds
lib libperf cpumap: Fix perf_cpu_map__max for an empty/NULL map 2026-01-02 12:57:02 +01:00
memory-model
mm tools/mm/page_owner_sort: fix timestamp comparison for stable sorting 2026-01-08 10:17:11 +01:00
net tools: ynl: call nested attribute free function for indexed arrays 2025-11-10 17:18:05 -08:00
objtool objtool: Fix weak symbol detection 2025-12-18 14:02:28 +01:00
pcmcia
perf perf stat: Allow no events to open if this is a "--null" run 2025-12-18 14:03:32 +01:00
power tools/power turbostat: Regression fix Uncore MHz printed in hex 2025-12-18 14:02:36 +01:00
rcu
sched
sched_ext tools/sched_ext: fix scx_show_state.py for scx_root change 2026-01-08 10:16:48 +01:00
scripts
sound
spi
testing selftests/mm: fix thread state check in uffd-unit-tests 2026-01-08 10:17:11 +01:00
thermal
time
tracing rtla/timerlat_bpf: Stop tracing on user latency 2026-01-02 12:57:29 +01:00
usb
verification
virtio
wmi
workqueue
writeback
Makefile