Recently (July 2026), this issue became reproducible on debian stable with kernel (7.1.3) from backports. I suspect it's a default hardening of kernel related to recent CVEs.
By tracking error reported, we can see that /proc/self/mem pread from cpu_memory_rw_debug in accel/tcg/user-exec.c returns an error (Input/Output error). Detect this situation directly from our gdb python script, by trying the same thing from current process. If this operation fails, we can gracefully skip the test. Fixes: https://gitlab.com/qemu-project/qemu/-/work_items/3329 Signed-off-by: Pierrick Bouvier <[email protected]> --- tests/tcg/multiarch/gdbstub/prot-none.py | 35 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/tests/tcg/multiarch/gdbstub/prot-none.py b/tests/tcg/multiarch/gdbstub/prot-none.py index e653bc697f6..393626a9798 100644 --- a/tests/tcg/multiarch/gdbstub/prot-none.py +++ b/tests/tcg/multiarch/gdbstub/prot-none.py @@ -5,6 +5,8 @@ SPDX-License-Identifier: GPL-2.0-or-later """ import ctypes +import ctypes.util +import mmap import os from test_gdbstub import gdb_exit, main, report @@ -18,6 +20,34 @@ def probe_proc_self_mem(): except OSError: return False +def probe_proc_self_mem_access_prot_none(): + libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True) + libc.mmap.restype = ctypes.c_void_p + libc.mmap.argtypes = [ctypes.c_void_p, ctypes.c_size_t, ctypes.c_int, + ctypes.c_int, ctypes.c_int, ctypes.c_long] + size = os.sysconf("SC_PAGESIZE") + # mmap a PROT_NONE page + PROT_NONE = 0 + addr = libc.mmap(None, size, PROT_NONE, + mmap.MAP_PRIVATE | mmap.MAP_ANONYMOUS, -1, 0) + assert addr != ctypes.c_void_p(-1).value + fd = os.open("/proc/self/mem", os.O_RDWR) + try: + # read it through /proc/self/mem + data = os.pread(fd, size, addr) + except Exception as e: + print("/proc/self/mem pread error: " + str(e)) + return False + + try: + # write it through /proc/self/mem + os.pwrite(fd, data, addr) + except Exception as e: + print("/proc/self/mem pwrite error: " + str(e)) + return False + + return True + def run_test(): """Run through the tests one by one""" @@ -26,10 +56,9 @@ def run_test(): print("SKIP: /proc/self/mem is not usable") print("----------------------------------") gdb_exit(77) - if "GITLAB_CI" in os.environ: + if not probe_proc_self_mem_access_prot_none(): print("----------------------------------") - print("SKIP: fail on gitlab - " + - "https://gitlab.com/qemu-project/qemu/-/issues/3329") + print("SKIP: /proc/self/mem can't be used to access PROT_NONE page") print("----------------------------------") gdb_exit(77) gdb.Breakpoint("break_here") -- 2.47.3
