AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/09/30 23:44 flow patch-triage
0m Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "KMSANReasoning": "",
  "NeedsKMSAN": false,
  "Reasoning": "The patch only modifies Documentation and selftests under tools/testing/selftests/ (adding kselftests for nommu mmap and mremap). It does not modify any kernel code, drivers, or compiled kernel artifacts (vmlinux/modules). Therefore, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

1/1 2026/09/30 23:44 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 0c22b5fc2d6afcde135eeeea683fa052d94e6a3d\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Wed Sep 30 23:44:26 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst\nindex 64c0ec7428a27..c35b819947b7b 100644\n--- a/Documentation/dev-tools/kselftest.rst\n+++ b/Documentation/dev-tools/kselftest.rst\n@@ -230,6 +230,20 @@ section::\n \n .. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress\n \n+Build and test on nommu target\n+==============================\n+\n+If you (cross-)build kselftests for nommu targets, or run tests on nommu targets, use\n+``NOMMU=1`` as a make variable/environment setting to tell build system to do the additional\n+checks.  These nommu targets may differ in several ways, such as not supporting fork(2) or\n+using musl or another libc.  Set this variable to apply the necessary build and test adjustments.\n+\n+::\n+\n+  $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=nommu  # \u003c= build-only\n+  $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=nommu\n+  $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p -c nommu\n+\n Contributing new tests\n ======================\n \ndiff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh\nindex 311811dc55a07..ee2c1f0403d9a 100644\n--- a/tools/testing/selftests/kselftest/runner.sh\n+++ b/tools/testing/selftests/kselftest/runner.sh\n@@ -38,8 +38,12 @@ tap_prefix()\n \n tap_timeout()\n {\n+\t# nommu doesn't support timeout command (missing fork(2))\n+\tif [ \"$NOMMU\" = \"1\" ] ; then\n+\t\techo \"timeout isn't supported for NOMMU\"\n+\t\t$1\n \t# Make sure tests will time out if utility is available.\n-\tif [ -x /usr/bin/timeout ] ; then\n+\telif [ -x /usr/bin/timeout ] ; then\n \t\t/usr/bin/timeout --foreground \"$kselftest_timeout\" \\\n \t\t\t/usr/bin/timeout \"$kselftest_timeout\" $1\n \telse\ndiff --git a/tools/testing/selftests/nommu/Makefile b/tools/testing/selftests/nommu/Makefile\nnew file mode 100644\nindex 0000000000000..8e7cd7315c539\n--- /dev/null\n+++ b/tools/testing/selftests/nommu/Makefile\n@@ -0,0 +1,8 @@\n+# SPDX-License-Identifier: GPL-2.0\n+# Makefile for nommu selftests\n+\n+TEST_GEN_PROGS += nommu_mmap_test\n+TEST_GEN_PROGS += nommu_mremap_test\n+\n+include ../lib.mk\n+include local.mk\ndiff --git a/tools/testing/selftests/nommu/local.mk b/tools/testing/selftests/nommu/local.mk\nnew file mode 100644\nindex 0000000000000..0bd1300f00f45\n--- /dev/null\n+++ b/tools/testing/selftests/nommu/local.mk\n@@ -0,0 +1,7 @@\n+# detect if users request NOMMU build or not\n+# User can set NOMMU to 1 to build/test for NOMMU platforms\n+NOMMU ?= 0\n+ifeq ($(NOMMU),1)\n+CFLAGS += -DNOMMU\n+export NOMMU\n+endif\ndiff --git a/tools/testing/selftests/nommu/nommu_mmap_test.c b/tools/testing/selftests/nommu/nommu_mmap_test.c\nnew file mode 100644\nindex 0000000000000..a1f5fdda554a4\n--- /dev/null\n+++ b/tools/testing/selftests/nommu/nommu_mmap_test.c\n@@ -0,0 +1,261 @@\n+// SPDX-License-Identifier: GPL-2.0\n+#define _GNU_SOURCE\n+#include \u003cstdio.h\u003e\n+#include \u003cstdlib.h\u003e\n+#include \u003csys/mman.h\u003e\n+#include \u003cunistd.h\u003e\n+#include \u003cfcntl.h\u003e\n+#include \u003cerrno.h\u003e\n+#include \u003cstring.h\u003e\n+#include \u003climits.h\u003e\n+#include \"kselftest.h\"\n+\n+#include \u003csys/vfs.h\u003e\n+#ifndef RAMFS_MAGIC\n+#define RAMFS_MAGIC 0x858458f6\n+#endif\n+\n+static size_t ps;\n+\n+struct test_case_t {\n+\tconst char *name;\n+\tconst char *pathname;\n+\tint open_flags;\n+\tint mmap_prot;\n+\tint mmap_flags;\n+\tint exp_err;\n+\tint (*resolve_exp_err)(const char *path);\n+};\n+\n+static int get_shm_expected_error(const char *path)\n+{\n+\tstruct statfs fs;\n+\n+\tif (statfs(path, \u0026fs) == 0) {\n+\t\tif (fs.f_type == RAMFS_MAGIC)\n+\t\t\treturn 0; /* ramfs succeed with contiguous memory */\n+\t}\n+\t /* hostfs, etc returns ENODEV due to lack of contiguous allocation */\n+\treturn ENODEV;\n+}\n+\n+static struct test_case_t test_cases[] = {\n+\t{\n+\t\t.name = \"anonymous private allocation\",\n+\t\t.pathname = NULL,\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ | PROT_WRITE,\n+\t\t.mmap_flags = MAP_ANONYMOUS | MAP_PRIVATE,\n+\t\t.exp_err = 0,\n+\t\t.resolve_exp_err = NULL,\n+\t},\n+\t{\n+\t\t.name = \"non-anonymous private file mapping (rw-)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-reg-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ | PROT_WRITE,\n+\t\t.mmap_flags = MAP_PRIVATE,\n+\t\t.exp_err = 0,\n+\t\t.resolve_exp_err = NULL,\n+\t},\n+\t{\n+\t\t.name = \"non-anonymous private file mapping (r--)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-reg-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ,\n+\t\t.mmap_flags = MAP_PRIVATE,\n+\t\t.exp_err = 0,\n+\t\t.resolve_exp_err = NULL,\n+\t},\n+\t{\n+\t\t.name = \"non-anonymous shared file mapping (rw-)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-shm-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ | PROT_WRITE,\n+\t\t.mmap_flags = MAP_SHARED,\n+\t\t.exp_err = 0,\n+#ifdef NOMMU\n+\t\t.resolve_exp_err = get_shm_expected_error,\n+#else\n+\t\t.resolve_exp_err = NULL,\n+#endif\n+\t},\n+\t{\n+\t\t.name = \"non-anonymous shared file mapping (r--)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-shm-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ,\n+\t\t.mmap_flags = MAP_SHARED,\n+\t\t.exp_err = 0,\n+#ifdef NOMMU\n+\t\t.resolve_exp_err = get_shm_expected_error,\n+#else\n+\t\t.resolve_exp_err = 0,\n+#endif\n+\t},\n+};\n+\n+static int run_mapping_matrix_test(struct test_case_t *tcase)\n+{\n+\tint fd;\n+\tvoid *ptr;\n+\tchar path_buf[PATH_MAX];\n+\tconst char *path = tcase-\u003epathname;\n+\tint rc = KSFT_PASS;\n+\tint expected_error;\n+\n+\tksft_print_msg(\"[RUN] %s\\n\", tcase-\u003ename);\n+\n+\tif (tcase-\u003epathname == NULL) {\n+\t\tfd = -1;\n+\t} else if (strstr(tcase-\u003epathname, \"XXXXXX\")) {\n+\t\tstrncpy(path_buf, tcase-\u003epathname, sizeof(path_buf) - 1);\n+\t\tpath_buf[sizeof(path_buf) - 1] = '\\0';\n+\t\tfd = mkstemp(path_buf);\n+\t\tif (fd \u003c 0) {\n+\t\t\tksft_print_msg(\"Failed to setup temp node: %s\\n\",\n+\t\t\t\ttcase-\u003epathname);\n+\t\t\tksft_test_result_skip(\"%s\\n\", tcase-\u003ename);\n+\t\t\treturn KSFT_SKIP;\n+\t\t}\n+\t\tif (ftruncate(fd, ps) != 0) {\n+\t\t\tksft_print_msg(\"ftruncate failed for: %s\\n\", tcase-\u003epathname);\n+\t\t\tksft_test_result_fail(\"%s\\n\", tcase-\u003ename);\n+\t\t\tclose(fd);\n+\t\t\tunlink(path_buf);\n+\t\t\treturn KSFT_FAIL;\n+\t\t}\n+\t\tpath = path_buf;\n+\t} else {\n+\t\tfd = open(tcase-\u003epathname, tcase-\u003eopen_flags, 0600);\n+\t\tif (fd \u003c 0) {\n+\t\t\tksft_print_msg(\"Device node not accessible: %s\\n\",\n+\t\t\t\t       tcase-\u003epathname);\n+\t\t\tksft_test_result_skip(\"%s\\n\", tcase-\u003ename);\n+\t\t\treturn KSFT_SKIP;\n+\t\t}\n+\t}\n+\n+\texpected_error = tcase-\u003eexp_err;\n+\tif (tcase-\u003eresolve_exp_err \u0026\u0026 fd \u003e= 0)\n+\t\texpected_error = tcase-\u003eresolve_exp_err(path);\n+\n+\tptr = mmap(NULL, ps, tcase-\u003emmap_prot, tcase-\u003emmap_flags, fd, 0);\n+\n+\tif (expected_error != 0) {\n+\t\tif (ptr != MAP_FAILED) {\n+\t\t\tksft_print_msg(\"mmap unexpectedly succeeded (exp error %d)\\n\",\n+\t\t\t\t\t      expected_error);\n+\t\t\tksft_test_result_fail(\"%s\\n\", tcase-\u003ename);\n+\t\t\tmunmap(ptr, ps);\n+\t\t\trc = KSFT_FAIL;\n+\t\t\tgoto cleanup;\n+\t\t}\n+\t\tif (errno != expected_error) {\n+\t\t\tksft_print_msg(\"mmap failed with %d (%s), but expected %d\\n\",\n+\t\t\t\terrno, strerror(errno), expected_error);\n+\t\t\tksft_test_result_fail(\"%s\\n\", tcase-\u003ename);\n+\t\t\trc = KSFT_FAIL;\n+\t\t\tgoto cleanup;\n+\t\t}\n+\t\tksft_print_msg(\"Correctly rejected with expected error %s(%d)\\n\",\n+\t\t\tstrerror(expected_error), expected_error);\n+\t\tksft_test_result_pass(\"%s\\n\", tcase-\u003ename);\n+\t\trc = KSFT_PASS;\n+\t\tgoto cleanup;\n+\t}\n+\n+\tif (ptr == MAP_FAILED) {\n+\t\tksft_print_msg(\"mmap failed unexpectedly: %s\\n\", strerror(errno));\n+\t\tksft_test_result_fail(\"%s\\n\", tcase-\u003ename);\n+\t\trc = KSFT_FAIL;\n+\t\tgoto cleanup;\n+\t}\n+\n+\tksft_test_result_pass(\"%s\\n\", tcase-\u003ename);\n+\tmunmap(ptr, ps);\n+\n+cleanup:\n+\tif (fd \u003e= 0) {\n+\t\tclose(fd);\n+\t\tif (tcase-\u003epathname \u0026\u0026 strstr(tcase-\u003epathname, \"XXXXXX\"))\n+\t\t\tunlink(path_buf);\n+\t}\n+\treturn rc;\n+}\n+\n+static int test_map_fixed(void)\n+{\n+\tvoid *fixed_addr;\n+\tvoid *ptr;\n+\n+\tksft_print_msg(\"[RUN] %s\\n\", __func__);\n+\n+\tfixed_addr = mmap(NULL, ps, PROT_READ | PROT_WRITE,\n+\t\t\tMAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n+\tif (fixed_addr == MAP_FAILED) {\n+\t\tksft_print_msg(\"Unable to reserve test address: %s\\n\",\n+\t\t\t\tstrerror(errno));\n+\t\tksft_test_result_skip(\"MAP_FIXED behavior\\n\");\n+\t\treturn KSFT_SKIP;\n+\t}\n+\n+\tif (munmap(fixed_addr, ps)) {\n+\t\tksft_print_msg(\"Unable to release test address: %s\\n\",\n+\t\t\tstrerror(errno));\n+\t\tksft_test_result_fail(\"MAP_FIXED behavior\\n\");\n+\t\treturn KSFT_FAIL;\n+\t}\n+\n+\tptr = mmap(fixed_addr, ps, PROT_READ | PROT_WRITE,\n+\t\tMAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);\n+\n+#ifdef NOMMU\n+\tif (ptr == MAP_FAILED \u0026\u0026 (errno == ENODEV || errno == EINVAL)) {\n+\t\tksft_print_msg(\"MAP_FIXED correctly rejected under nommu\\n\");\n+\t\tksft_test_result_pass(\"MAP_FIXED behavior\\n\");\n+\t\treturn KSFT_PASS;\n+\t}\n+\tif (ptr != MAP_FAILED) {\n+\t\tksft_print_msg(\"MAP_FIXED unexpectedly allowed under nommu\\n\");\n+\t\tksft_test_result_fail(\"MAP_FIXED behavior\\n\");\n+\t\tmunmap(ptr, ps);\n+\t\treturn KSFT_FAIL;\n+\t}\n+\tksft_print_msg(\"MAP_FIXED failed under NOMMU: %s\\n\",\n+\t\t\t      strerror(errno));\n+\tksft_test_result_fail(\"MAP_FIXED behavior\\n\");\n+\treturn KSFT_FAIL;\n+#else\n+\tif (ptr != MAP_FAILED) {\n+\t\tksft_print_msg(\"MAP_FIXED successfully allocated under MMU\\n\");\n+\t\tksft_test_result_pass(\"MAP_FIXED behavior\\n\");\n+\t\tmunmap(ptr, ps);\n+\t\treturn KSFT_PASS;\n+\t}\n+\tksft_print_msg(\"MAP_FIXED failed allocation under MMU\\n\");\n+\tksft_test_result_fail(\"MAP_FIXED behavior\\n\");\n+\treturn KSFT_FAIL;\n+#endif\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tint i;\n+\n+\tps = sysconf(_SC_PAGESIZE);\n+\tksft_print_header();\n+\tksft_set_plan(ARRAY_SIZE(test_cases) + 1);\n+\n+#ifdef NOMMU\n+\tksft_print_msg(\"Running strict MMAP test criteria under nommu architecture\\n\");\n+#else\n+\tksft_print_msg(\"Running MMAP test criteria under MMU architecture\\n\");\n+#endif\n+\n+\ttest_map_fixed();\n+\tfor (i = 0; i \u003c (int)ARRAY_SIZE(test_cases); i++)\n+\t\trun_mapping_matrix_test(\u0026test_cases[i]);\n+\n+\tksft_finished();\n+}\ndiff --git a/tools/testing/selftests/nommu/nommu_mremap_test.c b/tools/testing/selftests/nommu/nommu_mremap_test.c\nnew file mode 100644\nindex 0000000000000..7ccdf65b675f3\n--- /dev/null\n+++ b/tools/testing/selftests/nommu/nommu_mremap_test.c\n@@ -0,0 +1,366 @@\n+// SPDX-License-Identifier: GPL-2.0\n+#define _GNU_SOURCE\n+#include \u003cstdio.h\u003e\n+#include \u003cstdlib.h\u003e\n+#include \u003csys/mman.h\u003e\n+#include \u003cunistd.h\u003e\n+#include \u003cfcntl.h\u003e\n+#include \u003cerrno.h\u003e\n+#include \u003cstring.h\u003e\n+#include \u003climits.h\u003e\n+#include \"kselftest.h\"\n+\n+#include \u003csys/vfs.h\u003e\n+#ifndef RAMFS_MAGIC\n+#define RAMFS_MAGIC 0x858458f6\n+#endif\n+\n+static size_t ps;\n+\n+static long get_fs_type(const char *path)\n+{\n+\tstruct statfs fs;\n+\n+\tif (statfs(path, \u0026fs) == 0)\n+\t\treturn fs.f_type;\n+\n+\treturn 0;\n+}\n+\n+static void munmap_shrink_test(void)\n+{\n+\tvoid *addr;\n+\tint ret;\n+\n+\t/* munmap shrink test */\n+\tfor (int i = 0; i \u003c 4; i++) {\n+\t\taddr = mmap(NULL, ps * 4, PROT_READ | PROT_WRITE,\n+\t\t\t    MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n+\t\tif (addr == MAP_FAILED) {\n+\t\t\tksft_print_msg(\"mmap failed: %s(%d)\\n\", strerror(errno), errno);\n+\t\t\tksft_test_result_fail(\"munmap shrink\\n\");\n+\t\t\treturn;\n+\t\t}\n+\t\tret = munmap((char *)addr + ps * i, ps);\n+\t\tif (ret != 0) {\n+\t\t\tksft_print_msg(\"memory %p isn't unmapped at %p\\n\",\n+\t\t\t\taddr, (char *)addr + ps * i);\n+\t\t\tksft_test_result_fail(\"munmap shrink\\n\");\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tif (i == 0) {\n+\t\t\tif (munmap(addr +  ps, ps * 3))\n+\t\t\t\tgoto error;\n+\t\t} else if (i == 1) {\n+\t\t\tif (munmap(addr, ps) || munmap(addr + (ps * 2), ps * 2))\n+\t\t\t\tgoto error;\n+\t\t} else if (i == 2) {\n+\t\t\tif (munmap(addr, ps * 2) || munmap(addr + (ps * 3), ps))\n+\t\t\t\tgoto error;\n+\t\t} else if (i == 3) {\n+\t\t\tif (munmap(addr, ps * 3))\n+\t\t\t\tgoto error;\n+\t\t}\n+\t}\n+\n+\tksft_test_result_pass(\"munmap shrink\\n\");\n+\treturn;\n+error:\n+\tfor (int j = 0; j \u003c 4; j++)\n+\t\tmunmap((char *)addr + j * ps, ps);\n+\tksft_print_msg(\"clean up failures\\n\");\n+\tksft_test_result_fail(\"munmap shrink\\n\");\n+}\n+\n+static size_t page_align(size_t len)\n+{\n+\treturn (len + ps - 1) / ps * ps;\n+}\n+\n+static void mremap_shrink_test(void)\n+{\n+\tvoid *addr, *addr2;\n+\tsize_t current_len;\n+\tsize_t old_len, new_len;\n+\tstruct param {\n+\t\tsize_t old;\n+\t\tsize_t new;\n+\t} params[] = {\n+\t\t/* should not happen any shrink */\n+\t\t{ .old = ps * 4 - 1, .new = ps * 4 - 2 },\n+\t\t/* should not happen any shrink */\n+\t\t{ .old = ps * 4 - 1, .new = ps * 4 },\n+\t\t{ .old = ps * 4, .new = ps * 2 },\n+\t\t/* should not happen any shrink */\n+\t\t{ .old = ps * 2, .new = ps * 2 - 2 },\n+\t\t{ .old = ps * 2 - 2, .new = ps * 1 },\n+\t};\n+\n+\t/* mremap shrink test */\n+\tcurrent_len = page_align(ps * 4 - 1);\n+\taddr = mmap(NULL, ps * 4 - 1, PROT_READ | PROT_WRITE,\n+\t\t    MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);\n+\tif (addr == MAP_FAILED) {\n+\t\tksft_print_msg(\"mmap failed: %s(%d)\\n\", strerror(errno), errno);\n+\t\tksft_test_result_fail(\"mremap shrink\\n\");\n+\t\treturn;\n+\t}\n+\n+\tfor (int i = 0; i \u003c ARRAY_SIZE(params); i++) {\n+\t\told_len = params[i].old;\n+\t\tnew_len = params[i].new;\n+\t\tcurrent_len = page_align(new_len);\n+\t\taddr2 = mremap(addr, old_len, new_len, MREMAP_MAYMOVE);\n+\t\tif (addr2 == MAP_FAILED) {\n+\t\t\tksft_print_msg(\"memory %p isn't remapped at %p\\n\", addr, addr2);\n+\t\t\tksft_test_result_fail(\"mremap shrink\\n\");\n+\t\t\tmunmap(addr, page_align(old_len));\n+\t\t\treturn;\n+\t\t}\n+\n+\t\taddr = addr2;\n+\t}\n+\n+\tif (munmap(addr, current_len)) {\n+\t\tksft_print_msg(\"cleanup failed: %s\\n\", strerror(errno));\n+\t\tksft_test_result_fail(\"mremap shrink\\n\");\n+\t\treturn;\n+\t}\n+\tksft_test_result_pass(\"mremap shrink\\n\");\n+}\n+\n+static int get_shared_writable_file_expected_error(const char *path)\n+{\n+\tif (get_fs_type(path) == RAMFS_MAGIC)\n+\t\treturn EPERM; /* ramfs failed */\n+\n+\treturn 0;\n+}\n+\n+struct mremap_case_t {\n+\tconst char *name;\n+\tconst char *pathname;\n+\tint open_flags;\n+\tint mmap_prot;\n+\tint mmap_flags;\n+\tint exp_err;\n+\tint (*resolve_exp_err)(const char *path);\n+\tunsigned int old_pages;\n+\tunsigned int new_pages;\n+};\n+\n+static struct mremap_case_t mremap_cases[] = {\n+\t{\n+\t\t.name = \"anonymous shrink (r--)\",\n+\t\t.pathname = NULL,\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ,\n+\t\t.mmap_flags = MAP_ANONYMOUS | MAP_PRIVATE,\n+\t\t.exp_err = 0,\n+\t\t.resolve_exp_err = 0,\n+\t},\n+\t{\n+\t\t.name = \"shared file shrink (r--)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-remap-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ,\n+\t\t.mmap_flags = MAP_SHARED,\n+\t\t.exp_err = 0,\n+#ifdef NOMMU\n+\t\t.resolve_exp_err = get_shared_writable_file_expected_error,\n+#else\n+\t\t.resolve_exp_err = 0,\n+#endif\n+\t},\n+\t{\n+\t\t.name = \"private file unchanged length (r-)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-remap-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ,\n+\t\t.mmap_flags = MAP_PRIVATE,\n+#ifdef NOMMU\n+\t\t.exp_err = EPERM,\n+#else\n+\t\t.exp_err = 0,\n+#endif\n+\t\t.resolve_exp_err = 0,\n+\t\t.old_pages = 4,\n+\t\t.new_pages = 4,\n+\t},\n+\t{\n+\t\t.name = \"private file unchanged length (rw-)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-remap-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ | PROT_WRITE,\n+\t\t.mmap_flags = MAP_PRIVATE,\n+\t\t.exp_err = 0,\n+\t\t.resolve_exp_err = 0,\n+\t\t.old_pages = 4,\n+\t\t.new_pages = 4,\n+\t},\n+\t{\n+\t\t.name = \"private file growth (r-)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-remap-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ,\n+\t\t.mmap_flags = MAP_PRIVATE,\n+#ifdef NOMMU\n+\t\t.exp_err = EPERM,\n+#else\n+\t\t.exp_err = 0,\n+#endif\n+\t\t.resolve_exp_err = 0,\n+\t\t.old_pages = 4,\n+\t\t.new_pages = 8,\n+\t},\n+\t{\n+\t\t.name = \"private file growth (rw-)\",\n+\t\t.pathname = \"/tmp/ksft.nommu-remap-XXXXXX\",\n+\t\t.open_flags = O_CREAT | O_RDWR | O_EXCL,\n+\t\t.mmap_prot = PROT_READ | PROT_WRITE,\n+\t\t.mmap_flags = MAP_PRIVATE,\n+#ifdef NOMMU\n+\t\t.exp_err = ENOMEM,\n+#else\n+\t\t.exp_err = 0,\n+#endif\n+\t\t.resolve_exp_err = 0,\n+\t\t.old_pages = 4,\n+\t\t.new_pages = 8,\n+\t},\n+};\n+\n+static int run_mremap_test(struct mremap_case_t *tcase)\n+{\n+\tint fd = -1;\n+\tvoid *addr, *addr2;\n+\tchar pb[PATH_MAX];\n+\tconst char *path = tcase-\u003epathname;\n+\tint rc = KSFT_PASS;\n+\tint expected_error;\n+\tunsigned int old_pages = tcase-\u003eold_pages ?: 4;\n+\tunsigned int new_pages = tcase-\u003enew_pages ?: 2;\n+\tunsigned int file_pages = old_pages \u003e new_pages ?\n+\t\t\t\t  old_pages : new_pages;\n+\n+\tksft_print_msg(\"[RUN] Testing mremap: %s\\n\", tcase-\u003ename);\n+\n+\tif (tcase-\u003epathname \u0026\u0026 strstr(tcase-\u003epathname, \"XXXXXX\")) {\n+\t\tstrncpy(pb, tcase-\u003epathname, sizeof(pb) - 1);\n+\t\tpb[sizeof(pb) - 1] = '\\0';\n+\t\tfd = mkstemp(pb);\n+\t\tif (fd \u003c 0) {\n+\t\t\tksft_print_msg(\"Failed to setup file backing\\n\");\n+\t\t\tksft_test_result_skip(\"%s\\n\", tcase-\u003ename);\n+\t\t\treturn KSFT_SKIP;\n+\t\t}\n+\t\tif (ftruncate(fd, ps * file_pages) != 0) {\n+\t\t\tksft_print_msg(\"Failed to setup file backing\\n\");\n+\t\t\tksft_test_result_fail(\"%s\\n\", tcase-\u003ename);\n+\t\t\tclose(fd);\n+\t\t\tunlink(pb);\n+\t\t\treturn KSFT_FAIL;\n+\t\t}\n+\n+#ifdef NOMMU\n+\t\tif ((tcase-\u003emmap_flags \u0026 MAP_SHARED) \u0026\u0026 get_fs_type(pb) != RAMFS_MAGIC) {\n+\t\t\tksft_print_msg(\"Skip the test under non-ramfs filesystem (%s)\\n\",\n+\t\t\t\tpb);\n+\t\t\tksft_test_result_skip(\"%s\\n\", tcase-\u003ename);\n+\t\t\tclose(fd);\n+\t\t\tunlink(pb);\n+\t\t\treturn KSFT_SKIP;\n+\t\t}\n+#endif\n+\t\tpath = pb;\n+\t} else if (tcase-\u003epathname) {\n+\t\tfd = open(tcase-\u003epathname, tcase-\u003eopen_flags, 0600);\n+\t\tif (fd \u003c 0) {\n+\t\t\tksft_print_msg(\"Backing node not accessible\\n\");\n+\t\t\tksft_test_result_skip(\"%s\\n\", tcase-\u003ename);\n+\t\t\treturn KSFT_SKIP;\n+\t\t}\n+\n+#ifdef NOMMU\n+\t\tif ((tcase-\u003emmap_flags \u0026 MAP_SHARED) \u0026\u0026\n+\t\t    get_fs_type(tcase-\u003epathname) != RAMFS_MAGIC) {\n+\t\t\tksft_print_msg(\"Skip the test under non-ramfs filesystem (%s)\\n\",\n+\t\t\t\t\t      tcase-\u003epathname);\n+\t\t\tksft_test_result_skip(\"%s\\n\", tcase-\u003ename);\n+\t\t\tclose(fd);\n+\t\t\treturn KSFT_SKIP;\n+\t\t}\n+#endif\n+\t}\n+\n+\taddr = mmap(NULL, ps * old_pages, tcase-\u003emmap_prot,\n+\t\t    tcase-\u003emmap_flags, fd, 0);\n+\tif (addr == MAP_FAILED) {\n+\t\tksft_print_msg(\"mmap mapping failed %s(%d)\\n\", strerror(errno), errno);\n+\t\trc = KSFT_FAIL;\n+\t\tgoto out;\n+\t}\n+\n+\texpected_error = tcase-\u003eexp_err;\n+\tif (tcase-\u003eresolve_exp_err \u0026\u0026 fd \u003e= 0)\n+\t\texpected_error = tcase-\u003eresolve_exp_err(path);\n+\n+\taddr2 = mremap(addr, ps * old_pages, ps * new_pages,\n+\t\t       MREMAP_MAYMOVE);\n+\n+\tif (expected_error != 0) {\n+\t\tif (addr2 != MAP_FAILED) {\n+\t\t\tksft_print_msg(\"Expected error %d, but mremap unexpectedly succeeded\\n\",\n+\t\t\t\t       expected_error);\n+\t\t\trc = KSFT_FAIL;\n+\t\t} else if (errno != expected_error) {\n+\t\t\tksft_print_msg(\"Expected error %d, got %s(%d)\\n\",\n+\t\t\t\t       expected_error, strerror(errno), errno);\n+\t\t\trc = KSFT_FAIL;\n+\t\t} else {\n+\t\t\tksft_print_msg(\"%s: Handled expected error path (errno=%d)\\n\",\n+\t\t\t\t       tcase-\u003ename, expected_error);\n+\t\t}\n+\t} else if (addr2 == MAP_FAILED) {\n+\t\tksft_print_msg(\"mremap shrink failed unexpectedly: %s\\n\",\n+\t\t\t       strerror(errno));\n+\t\trc = KSFT_FAIL;\n+\t} else {\n+\t\tksft_print_msg(\"%s step successful\\n\", tcase-\u003ename);\n+\t}\n+\n+\t/* clean up */\n+\tif (munmap(addr2 == MAP_FAILED ? addr : addr2,\n+\t\t   addr2 == MAP_FAILED ? ps * old_pages : ps * new_pages)) {\n+\t\tksft_print_msg(\"munmap failed: %s\\n\", strerror(errno));\n+\t\trc = KSFT_FAIL;\n+\t}\n+\n+out:\n+\tif (fd \u003e= 0) {\n+\t\tclose(fd);\n+\t\tif (tcase-\u003epathname \u0026\u0026 strstr(tcase-\u003epathname, \"XXXXXX\"))\n+\t\t\tunlink(pb);\n+\t}\n+\n+\tksft_test_result_report(rc, \"%s\\n\", tcase-\u003ename);\n+\treturn rc;\n+}\n+\n+int main(int argc, char **argv)\n+{\n+\tint i;\n+\n+\tps = sysconf(_SC_PAGESIZE);\n+\tksft_print_header();\n+\tksft_set_plan(ARRAY_SIZE(mremap_cases) + 2);\n+\n+\tmunmap_shrink_test();\n+\tmremap_shrink_test();\n+\n+\tfor (i = 0; i \u003c (int)ARRAY_SIZE(mremap_cases); i++)\n+\t\trun_mremap_test(\u0026mremap_cases[i]);\n+\n+\tksft_finished();\n+}\n"
}

2/1 2026/09/30 23:44 agent patch-evaluator
0m Model:
core

Args:
null

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies Documentation and selftests under tools/testing/selftests/ (adding kselftests for nommu mmap and mremap). It does not modify any kernel code, drivers, or compiled kernel artifacts (vmlinux/modules). Therefore, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 0c22b5fc2d6afcde135eeeea683fa052d94e6a3d
Author: syz-cluster <triage@syzkaller.com>
Date:   Wed Sep 30 23:44:26 2026 +0000

    syz-cluster: applied patch under review

diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst
index 64c0ec7428a27..c35b819947b7b 100644
--- a/Documentation/dev-tools/kselftest.rst
+++ b/Documentation/dev-tools/kselftest.rst
@@ -230,6 +230,20 @@ section::
 
 .. _tar's auto-compress: https://www.gnu.org/software/tar/manual/html_node/gzip.html#auto_002dcompress
 
+Build and test on nommu target
+==============================
+
+If you (cross-)build kselftests for nommu targets, or run tests on nommu targets, use
+``NOMMU=1`` as a make variable/environment setting to tell build system to do the additional
+checks.  These nommu targets may differ in several ways, such as not supporting fork(2) or
+using musl or another libc.  Set this variable to apply the necessary build and test adjustments.
+
+::
+
+  $ make ARCH=um NOMMU=1 O=build kselftest-all TARGETS=nommu  # <= build-only
+  $ make ARCH=um NOMMU=1 O=build kselftest-install TARGETS=nommu
+  $ NOMMU=1 ./build/kselftest/kselftest_install/run_kselftest.sh -p -c nommu
+
 Contributing new tests
 ======================
 
diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
index 311811dc55a07..ee2c1f0403d9a 100644
--- a/tools/testing/selftests/kselftest/runner.sh
+++ b/tools/testing/selftests/kselftest/runner.sh
@@ -38,8 +38,12 @@ tap_prefix()
 
 tap_timeout()
 {
+	# nommu doesn't support timeout command (missing fork(2))
+	if [ "$NOMMU" = "1" ] ; then
+		echo "timeout isn't supported for NOMMU"
+		$1
 	# Make sure tests will time out if utility is available.
-	if [ -x /usr/bin/timeout ] ; then
+	elif [ -x /usr/bin/timeout ] ; then
 		/usr/bin/timeout --foreground "$kselftest_timeout" \
 			/usr/bin/timeout "$kselftest_timeout" $1
 	else
diff --git a/tools/testing/selftests/nommu/Makefile b/tools/testing/selftests/nommu/Makefile
new file mode 100644
index 0000000000000..8e7cd7315c539
--- /dev/null
+++ b/tools/testing/selftests/nommu/Makefile
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+# Makefile for nommu selftests
+
+TEST_GEN_PROGS += nommu_mmap_test
+TEST_GEN_PROGS += nommu_mremap_test
+
+include ../lib.mk
+include local.mk
diff --git a/tools/testing/selftests/nommu/local.mk b/tools/testing/selftests/nommu/local.mk
new file mode 100644
index 0000000000000..0bd1300f00f45
--- /dev/null
+++ b/tools/testing/selftests/nommu/local.mk
@@ -0,0 +1,7 @@
+# detect if users request NOMMU build or not
+# User can set NOMMU to 1 to build/test for NOMMU platforms
+NOMMU ?= 0
+ifeq ($(NOMMU),1)
+CFLAGS += -DNOMMU
+export NOMMU
+endif
diff --git a/tools/testing/selftests/nommu/nommu_mmap_test.c b/tools/testing/selftests/nommu/nommu_mmap_test.c
new file mode 100644
index 0000000000000..a1f5fdda554a4
--- /dev/null
+++ b/tools/testing/selftests/nommu/nommu_mmap_test.c
@@ -0,0 +1,261 @@
+// SPDX-License-Identifier: GPL-2.0
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <limits.h>
+#include "kselftest.h"
+
+#include <sys/vfs.h>
+#ifndef RAMFS_MAGIC
+#define RAMFS_MAGIC 0x858458f6
+#endif
+
+static size_t ps;
+
+struct test_case_t {
+	const char *name;
+	const char *pathname;
+	int open_flags;
+	int mmap_prot;
+	int mmap_flags;
+	int exp_err;
+	int (*resolve_exp_err)(const char *path);
+};
+
+static int get_shm_expected_error(const char *path)
+{
+	struct statfs fs;
+
+	if (statfs(path, &fs) == 0) {
+		if (fs.f_type == RAMFS_MAGIC)
+			return 0; /* ramfs succeed with contiguous memory */
+	}
+	 /* hostfs, etc returns ENODEV due to lack of contiguous allocation */
+	return ENODEV;
+}
+
+static struct test_case_t test_cases[] = {
+	{
+		.name = "anonymous private allocation",
+		.pathname = NULL,
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ | PROT_WRITE,
+		.mmap_flags = MAP_ANONYMOUS | MAP_PRIVATE,
+		.exp_err = 0,
+		.resolve_exp_err = NULL,
+	},
+	{
+		.name = "non-anonymous private file mapping (rw-)",
+		.pathname = "/tmp/ksft.nommu-reg-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ | PROT_WRITE,
+		.mmap_flags = MAP_PRIVATE,
+		.exp_err = 0,
+		.resolve_exp_err = NULL,
+	},
+	{
+		.name = "non-anonymous private file mapping (r--)",
+		.pathname = "/tmp/ksft.nommu-reg-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ,
+		.mmap_flags = MAP_PRIVATE,
+		.exp_err = 0,
+		.resolve_exp_err = NULL,
+	},
+	{
+		.name = "non-anonymous shared file mapping (rw-)",
+		.pathname = "/tmp/ksft.nommu-shm-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ | PROT_WRITE,
+		.mmap_flags = MAP_SHARED,
+		.exp_err = 0,
+#ifdef NOMMU
+		.resolve_exp_err = get_shm_expected_error,
+#else
+		.resolve_exp_err = NULL,
+#endif
+	},
+	{
+		.name = "non-anonymous shared file mapping (r--)",
+		.pathname = "/tmp/ksft.nommu-shm-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ,
+		.mmap_flags = MAP_SHARED,
+		.exp_err = 0,
+#ifdef NOMMU
+		.resolve_exp_err = get_shm_expected_error,
+#else
+		.resolve_exp_err = 0,
+#endif
+	},
+};
+
+static int run_mapping_matrix_test(struct test_case_t *tcase)
+{
+	int fd;
+	void *ptr;
+	char path_buf[PATH_MAX];
+	const char *path = tcase->pathname;
+	int rc = KSFT_PASS;
+	int expected_error;
+
+	ksft_print_msg("[RUN] %s\n", tcase->name);
+
+	if (tcase->pathname == NULL) {
+		fd = -1;
+	} else if (strstr(tcase->pathname, "XXXXXX")) {
+		strncpy(path_buf, tcase->pathname, sizeof(path_buf) - 1);
+		path_buf[sizeof(path_buf) - 1] = '\0';
+		fd = mkstemp(path_buf);
+		if (fd < 0) {
+			ksft_print_msg("Failed to setup temp node: %s\n",
+				tcase->pathname);
+			ksft_test_result_skip("%s\n", tcase->name);
+			return KSFT_SKIP;
+		}
+		if (ftruncate(fd, ps) != 0) {
+			ksft_print_msg("ftruncate failed for: %s\n", tcase->pathname);
+			ksft_test_result_fail("%s\n", tcase->name);
+			close(fd);
+			unlink(path_buf);
+			return KSFT_FAIL;
+		}
+		path = path_buf;
+	} else {
+		fd = open(tcase->pathname, tcase->open_flags, 0600);
+		if (fd < 0) {
+			ksft_print_msg("Device node not accessible: %s\n",
+				       tcase->pathname);
+			ksft_test_result_skip("%s\n", tcase->name);
+			return KSFT_SKIP;
+		}
+	}
+
+	expected_error = tcase->exp_err;
+	if (tcase->resolve_exp_err && fd >= 0)
+		expected_error = tcase->resolve_exp_err(path);
+
+	ptr = mmap(NULL, ps, tcase->mmap_prot, tcase->mmap_flags, fd, 0);
+
+	if (expected_error != 0) {
+		if (ptr != MAP_FAILED) {
+			ksft_print_msg("mmap unexpectedly succeeded (exp error %d)\n",
+					      expected_error);
+			ksft_test_result_fail("%s\n", tcase->name);
+			munmap(ptr, ps);
+			rc = KSFT_FAIL;
+			goto cleanup;
+		}
+		if (errno != expected_error) {
+			ksft_print_msg("mmap failed with %d (%s), but expected %d\n",
+				errno, strerror(errno), expected_error);
+			ksft_test_result_fail("%s\n", tcase->name);
+			rc = KSFT_FAIL;
+			goto cleanup;
+		}
+		ksft_print_msg("Correctly rejected with expected error %s(%d)\n",
+			strerror(expected_error), expected_error);
+		ksft_test_result_pass("%s\n", tcase->name);
+		rc = KSFT_PASS;
+		goto cleanup;
+	}
+
+	if (ptr == MAP_FAILED) {
+		ksft_print_msg("mmap failed unexpectedly: %s\n", strerror(errno));
+		ksft_test_result_fail("%s\n", tcase->name);
+		rc = KSFT_FAIL;
+		goto cleanup;
+	}
+
+	ksft_test_result_pass("%s\n", tcase->name);
+	munmap(ptr, ps);
+
+cleanup:
+	if (fd >= 0) {
+		close(fd);
+		if (tcase->pathname && strstr(tcase->pathname, "XXXXXX"))
+			unlink(path_buf);
+	}
+	return rc;
+}
+
+static int test_map_fixed(void)
+{
+	void *fixed_addr;
+	void *ptr;
+
+	ksft_print_msg("[RUN] %s\n", __func__);
+
+	fixed_addr = mmap(NULL, ps, PROT_READ | PROT_WRITE,
+			MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+	if (fixed_addr == MAP_FAILED) {
+		ksft_print_msg("Unable to reserve test address: %s\n",
+				strerror(errno));
+		ksft_test_result_skip("MAP_FIXED behavior\n");
+		return KSFT_SKIP;
+	}
+
+	if (munmap(fixed_addr, ps)) {
+		ksft_print_msg("Unable to release test address: %s\n",
+			strerror(errno));
+		ksft_test_result_fail("MAP_FIXED behavior\n");
+		return KSFT_FAIL;
+	}
+
+	ptr = mmap(fixed_addr, ps, PROT_READ | PROT_WRITE,
+		MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
+
+#ifdef NOMMU
+	if (ptr == MAP_FAILED && (errno == ENODEV || errno == EINVAL)) {
+		ksft_print_msg("MAP_FIXED correctly rejected under nommu\n");
+		ksft_test_result_pass("MAP_FIXED behavior\n");
+		return KSFT_PASS;
+	}
+	if (ptr != MAP_FAILED) {
+		ksft_print_msg("MAP_FIXED unexpectedly allowed under nommu\n");
+		ksft_test_result_fail("MAP_FIXED behavior\n");
+		munmap(ptr, ps);
+		return KSFT_FAIL;
+	}
+	ksft_print_msg("MAP_FIXED failed under NOMMU: %s\n",
+			      strerror(errno));
+	ksft_test_result_fail("MAP_FIXED behavior\n");
+	return KSFT_FAIL;
+#else
+	if (ptr != MAP_FAILED) {
+		ksft_print_msg("MAP_FIXED successfully allocated under MMU\n");
+		ksft_test_result_pass("MAP_FIXED behavior\n");
+		munmap(ptr, ps);
+		return KSFT_PASS;
+	}
+	ksft_print_msg("MAP_FIXED failed allocation under MMU\n");
+	ksft_test_result_fail("MAP_FIXED behavior\n");
+	return KSFT_FAIL;
+#endif
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+
+	ps = sysconf(_SC_PAGESIZE);
+	ksft_print_header();
+	ksft_set_plan(ARRAY_SIZE(test_cases) + 1);
+
+#ifdef NOMMU
+	ksft_print_msg("Running strict MMAP test criteria under nommu architecture\n");
+#else
+	ksft_print_msg("Running MMAP test criteria under MMU architecture\n");
+#endif
+
+	test_map_fixed();
+	for (i = 0; i < (int)ARRAY_SIZE(test_cases); i++)
+		run_mapping_matrix_test(&test_cases[i]);
+
+	ksft_finished();
+}
diff --git a/tools/testing/selftests/nommu/nommu_mremap_test.c b/tools/testing/selftests/nommu/nommu_mremap_test.c
new file mode 100644
index 0000000000000..7ccdf65b675f3
--- /dev/null
+++ b/tools/testing/selftests/nommu/nommu_mremap_test.c
@@ -0,0 +1,366 @@
+// SPDX-License-Identifier: GPL-2.0
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#include <limits.h>
+#include "kselftest.h"
+
+#include <sys/vfs.h>
+#ifndef RAMFS_MAGIC
+#define RAMFS_MAGIC 0x858458f6
+#endif
+
+static size_t ps;
+
+static long get_fs_type(const char *path)
+{
+	struct statfs fs;
+
+	if (statfs(path, &fs) == 0)
+		return fs.f_type;
+
+	return 0;
+}
+
+static void munmap_shrink_test(void)
+{
+	void *addr;
+	int ret;
+
+	/* munmap shrink test */
+	for (int i = 0; i < 4; i++) {
+		addr = mmap(NULL, ps * 4, PROT_READ | PROT_WRITE,
+			    MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+		if (addr == MAP_FAILED) {
+			ksft_print_msg("mmap failed: %s(%d)\n", strerror(errno), errno);
+			ksft_test_result_fail("munmap shrink\n");
+			return;
+		}
+		ret = munmap((char *)addr + ps * i, ps);
+		if (ret != 0) {
+			ksft_print_msg("memory %p isn't unmapped at %p\n",
+				addr, (char *)addr + ps * i);
+			ksft_test_result_fail("munmap shrink\n");
+			return;
+		}
+
+		if (i == 0) {
+			if (munmap(addr +  ps, ps * 3))
+				goto error;
+		} else if (i == 1) {
+			if (munmap(addr, ps) || munmap(addr + (ps * 2), ps * 2))
+				goto error;
+		} else if (i == 2) {
+			if (munmap(addr, ps * 2) || munmap(addr + (ps * 3), ps))
+				goto error;
+		} else if (i == 3) {
+			if (munmap(addr, ps * 3))
+				goto error;
+		}
+	}
+
+	ksft_test_result_pass("munmap shrink\n");
+	return;
+error:
+	for (int j = 0; j < 4; j++)
+		munmap((char *)addr + j * ps, ps);
+	ksft_print_msg("clean up failures\n");
+	ksft_test_result_fail("munmap shrink\n");
+}
+
+static size_t page_align(size_t len)
+{
+	return (len + ps - 1) / ps * ps;
+}
+
+static void mremap_shrink_test(void)
+{
+	void *addr, *addr2;
+	size_t current_len;
+	size_t old_len, new_len;
+	struct param {
+		size_t old;
+		size_t new;
+	} params[] = {
+		/* should not happen any shrink */
+		{ .old = ps * 4 - 1, .new = ps * 4 - 2 },
+		/* should not happen any shrink */
+		{ .old = ps * 4 - 1, .new = ps * 4 },
+		{ .old = ps * 4, .new = ps * 2 },
+		/* should not happen any shrink */
+		{ .old = ps * 2, .new = ps * 2 - 2 },
+		{ .old = ps * 2 - 2, .new = ps * 1 },
+	};
+
+	/* mremap shrink test */
+	current_len = page_align(ps * 4 - 1);
+	addr = mmap(NULL, ps * 4 - 1, PROT_READ | PROT_WRITE,
+		    MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
+	if (addr == MAP_FAILED) {
+		ksft_print_msg("mmap failed: %s(%d)\n", strerror(errno), errno);
+		ksft_test_result_fail("mremap shrink\n");
+		return;
+	}
+
+	for (int i = 0; i < ARRAY_SIZE(params); i++) {
+		old_len = params[i].old;
+		new_len = params[i].new;
+		current_len = page_align(new_len);
+		addr2 = mremap(addr, old_len, new_len, MREMAP_MAYMOVE);
+		if (addr2 == MAP_FAILED) {
+			ksft_print_msg("memory %p isn't remapped at %p\n", addr, addr2);
+			ksft_test_result_fail("mremap shrink\n");
+			munmap(addr, page_align(old_len));
+			return;
+		}
+
+		addr = addr2;
+	}
+
+	if (munmap(addr, current_len)) {
+		ksft_print_msg("cleanup failed: %s\n", strerror(errno));
+		ksft_test_result_fail("mremap shrink\n");
+		return;
+	}
+	ksft_test_result_pass("mremap shrink\n");
+}
+
+static int get_shared_writable_file_expected_error(const char *path)
+{
+	if (get_fs_type(path) == RAMFS_MAGIC)
+		return EPERM; /* ramfs failed */
+
+	return 0;
+}
+
+struct mremap_case_t {
+	const char *name;
+	const char *pathname;
+	int open_flags;
+	int mmap_prot;
+	int mmap_flags;
+	int exp_err;
+	int (*resolve_exp_err)(const char *path);
+	unsigned int old_pages;
+	unsigned int new_pages;
+};
+
+static struct mremap_case_t mremap_cases[] = {
+	{
+		.name = "anonymous shrink (r--)",
+		.pathname = NULL,
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ,
+		.mmap_flags = MAP_ANONYMOUS | MAP_PRIVATE,
+		.exp_err = 0,
+		.resolve_exp_err = 0,
+	},
+	{
+		.name = "shared file shrink (r--)",
+		.pathname = "/tmp/ksft.nommu-remap-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ,
+		.mmap_flags = MAP_SHARED,
+		.exp_err = 0,
+#ifdef NOMMU
+		.resolve_exp_err = get_shared_writable_file_expected_error,
+#else
+		.resolve_exp_err = 0,
+#endif
+	},
+	{
+		.name = "private file unchanged length (r-)",
+		.pathname = "/tmp/ksft.nommu-remap-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ,
+		.mmap_flags = MAP_PRIVATE,
+#ifdef NOMMU
+		.exp_err = EPERM,
+#else
+		.exp_err = 0,
+#endif
+		.resolve_exp_err = 0,
+		.old_pages = 4,
+		.new_pages = 4,
+	},
+	{
+		.name = "private file unchanged length (rw-)",
+		.pathname = "/tmp/ksft.nommu-remap-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ | PROT_WRITE,
+		.mmap_flags = MAP_PRIVATE,
+		.exp_err = 0,
+		.resolve_exp_err = 0,
+		.old_pages = 4,
+		.new_pages = 4,
+	},
+	{
+		.name = "private file growth (r-)",
+		.pathname = "/tmp/ksft.nommu-remap-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ,
+		.mmap_flags = MAP_PRIVATE,
+#ifdef NOMMU
+		.exp_err = EPERM,
+#else
+		.exp_err = 0,
+#endif
+		.resolve_exp_err = 0,
+		.old_pages = 4,
+		.new_pages = 8,
+	},
+	{
+		.name = "private file growth (rw-)",
+		.pathname = "/tmp/ksft.nommu-remap-XXXXXX",
+		.open_flags = O_CREAT | O_RDWR | O_EXCL,
+		.mmap_prot = PROT_READ | PROT_WRITE,
+		.mmap_flags = MAP_PRIVATE,
+#ifdef NOMMU
+		.exp_err = ENOMEM,
+#else
+		.exp_err = 0,
+#endif
+		.resolve_exp_err = 0,
+		.old_pages = 4,
+		.new_pages = 8,
+	},
+};
+
+static int run_mremap_test(struct mremap_case_t *tcase)
+{
+	int fd = -1;
+	void *addr, *addr2;
+	char pb[PATH_MAX];
+	const char *path = tcase->pathname;
+	int rc = KSFT_PASS;
+	int expected_error;
+	unsigned int old_pages = tcase->old_pages ?: 4;
+	unsigned int new_pages = tcase->new_pages ?: 2;
+	unsigned int file_pages = old_pages > new_pages ?
+				  old_pages : new_pages;
+
+	ksft_print_msg("[RUN] Testing mremap: %s\n", tcase->name);
+
+	if (tcase->pathname && strstr(tcase->pathname, "XXXXXX")) {
+		strncpy(pb, tcase->pathname, sizeof(pb) - 1);
+		pb[sizeof(pb) - 1] = '\0';
+		fd = mkstemp(pb);
+		if (fd < 0) {
+			ksft_print_msg("Failed to setup file backing\n");
+			ksft_test_result_skip("%s\n", tcase->name);
+			return KSFT_SKIP;
+		}
+		if (ftruncate(fd, ps * file_pages) != 0) {
+			ksft_print_msg("Failed to setup file backing\n");
+			ksft_test_result_fail("%s\n", tcase->name);
+			close(fd);
+			unlink(pb);
+			return KSFT_FAIL;
+		}
+
+#ifdef NOMMU
+		if ((tcase->mmap_flags & MAP_SHARED) && get_fs_type(pb) != RAMFS_MAGIC) {
+			ksft_print_msg("Skip the test under non-ramfs filesystem (%s)\n",
+				pb);
+			ksft_test_result_skip("%s\n", tcase->name);
+			close(fd);
+			unlink(pb);
+			return KSFT_SKIP;
+		}
+#endif
+		path = pb;
+	} else if (tcase->pathname) {
+		fd = open(tcase->pathname, tcase->open_flags, 0600);
+		if (fd < 0) {
+			ksft_print_msg("Backing node not accessible\n");
+			ksft_test_result_skip("%s\n", tcase->name);
+			return KSFT_SKIP;
+		}
+
+#ifdef NOMMU
+		if ((tcase->mmap_flags & MAP_SHARED) &&
+		    get_fs_type(tcase->pathname) != RAMFS_MAGIC) {
+			ksft_print_msg("Skip the test under non-ramfs filesystem (%s)\n",
+					      tcase->pathname);
+			ksft_test_result_skip("%s\n", tcase->name);
+			close(fd);
+			return KSFT_SKIP;
+		}
+#endif
+	}
+
+	addr = mmap(NULL, ps * old_pages, tcase->mmap_prot,
+		    tcase->mmap_flags, fd, 0);
+	if (addr == MAP_FAILED) {
+		ksft_print_msg("mmap mapping failed %s(%d)\n", strerror(errno), errno);
+		rc = KSFT_FAIL;
+		goto out;
+	}
+
+	expected_error = tcase->exp_err;
+	if (tcase->resolve_exp_err && fd >= 0)
+		expected_error = tcase->resolve_exp_err(path);
+
+	addr2 = mremap(addr, ps * old_pages, ps * new_pages,
+		       MREMAP_MAYMOVE);
+
+	if (expected_error != 0) {
+		if (addr2 != MAP_FAILED) {
+			ksft_print_msg("Expected error %d, but mremap unexpectedly succeeded\n",
+				       expected_error);
+			rc = KSFT_FAIL;
+		} else if (errno != expected_error) {
+			ksft_print_msg("Expected error %d, got %s(%d)\n",
+				       expected_error, strerror(errno), errno);
+			rc = KSFT_FAIL;
+		} else {
+			ksft_print_msg("%s: Handled expected error path (errno=%d)\n",
+				       tcase->name, expected_error);
+		}
+	} else if (addr2 == MAP_FAILED) {
+		ksft_print_msg("mremap shrink failed unexpectedly: %s\n",
+			       strerror(errno));
+		rc = KSFT_FAIL;
+	} else {
+		ksft_print_msg("%s step successful\n", tcase->name);
+	}
+
+	/* clean up */
+	if (munmap(addr2 == MAP_FAILED ? addr : addr2,
+		   addr2 == MAP_FAILED ? ps * old_pages : ps * new_pages)) {
+		ksft_print_msg("munmap failed: %s\n", strerror(errno));
+		rc = KSFT_FAIL;
+	}
+
+out:
+	if (fd >= 0) {
+		close(fd);
+		if (tcase->pathname && strstr(tcase->pathname, "XXXXXX"))
+			unlink(pb);
+	}
+
+	ksft_test_result_report(rc, "%s\n", tcase->name);
+	return rc;
+}
+
+int main(int argc, char **argv)
+{
+	int i;
+
+	ps = sysconf(_SC_PAGESIZE);
+	ksft_print_header();
+	ksft_set_plan(ARRAY_SIZE(mremap_cases) + 2);
+
+	munmap_shrink_test();
+	mremap_shrink_test();
+
+	for (i = 0; i < (int)ARRAY_SIZE(mremap_cases); i++)
+		run_mremap_test(&mremap_cases[i]);
+
+	ksft_finished();
+}

3/2 2026/09/30 23:44 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 10948
							output: 95
							thoughts: 453
						

Thoughts:
**Patch Review: WorthFuzzing Determination**

Okay, let's take a look at this patch commit. First, I need to understand what's been changed. The diff includes: `Documentation/dev-tools/kselftest.rst`, `tools/testing/selftests/kselftest/runner.sh`, and several files within `tools/testing/selftests/nommu/`: `Makefile`, `local.mk`, `nommu_mmap_test.c`, and `nommu_mremap_test.c`.

Right, so all the modifications are confined to either the `Documentation/` directory or the `tools/testing/selftests/` subtree. Time to apply the triage criteria. The critical question is: Does this impact the kernel image (vmlinux) or kernel modules? The negative criteria dictate that we set `WorthFuzzing=false` if *all* changes are non-kernel, non-executable, falling into categories like documentation, comments, or user-space self-tests and scripts that don't affect the compiled kernel image.

Based on the file paths, it's clear these changes fall squarely within the "user-space self-tests" category. None of these files directly modify the kernel image or modules. Therefore, following the triage guidelines, `WorthFuzzing` must be false.

Just to be absolutely certain, and to generate the correct output, let me confirm this with `set-results`:

```
WorthFuzzing: false
Reasoning: The patch only modifies Documentation and user-space kselftests under tools/testing/selftests/, with no changes to the kernel image or modules.
EnableConfigs: []
FocusSymbols: []
```

Excellent, that's what I expected. The output from `set-results` confirms our assessment. The "set-results" tool was correctly used, as required by the analysis guidelines. This satisfies the requirements, so it's time to move on.



4/2 2026/09/30 23:44 tool set-results
0m Args:
{
  "EnableConfigs": [],
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies Documentation and selftests under tools/testing/selftests/ (adding kselftests for nommu mmap and mremap). It does not modify any kernel code, drivers, or compiled kernel artifacts (vmlinux/modules). Therefore, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

Results:
{
  "EnableConfigs": null,
  "FocusSymbols": [],
  "Reasoning": "The patch only modifies Documentation and selftests under tools/testing/selftests/ (adding kselftests for nommu mmap and mremap). It does not modify any kernel code, drivers, or compiled kernel artifacts (vmlinux/modules). Therefore, it does not warrant fuzzing.",
  "WorthFuzzing": false
}

5/1 2026/09/30 23:44 action If
0m Args:
{
  "WorthFuzzing": false
}

Results:
null

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)