Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2221641/?format=api
{ "id": 2221641, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2221641/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/patch/20260410023201.18119-1-wegao@suse.com/", "project": { "id": 59, "url": "http://patchwork.ozlabs.org/api/1.2/projects/59/?format=api", "name": "Linux Test Project development", "link_name": "ltp", "list_id": "ltp.lists.linux.it", "list_email": "ltp@lists.linux.it", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260410023201.18119-1-wegao@suse.com>", "list_archive_url": null, "date": "2026-04-10T02:31:52", "name": "[v6] mremap07.c: New case check mremap with MREMAP_DONTUNMAP", "commit_ref": null, "pull_url": null, "state": "needs-review-ack", "archived": false, "hash": "a829c4fa2494737f8b7d977671c814c448526dc1", "submitter": { "id": 85577, "url": "http://patchwork.ozlabs.org/api/1.2/people/85577/?format=api", "name": "Wei Gao", "email": "wegao@suse.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/ltp/patch/20260410023201.18119-1-wegao@suse.com/mbox/", "series": [ { "id": 499381, "url": "http://patchwork.ozlabs.org/api/1.2/series/499381/?format=api", "web_url": "http://patchwork.ozlabs.org/project/ltp/list/?series=499381", "date": "2026-04-10T02:31:52", "name": "[v6] mremap07.c: New case check mremap with MREMAP_DONTUNMAP", "version": 6, "mbox": "http://patchwork.ozlabs.org/series/499381/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2221641/comments/", "check": "warning", "checks": "http://patchwork.ozlabs.org/api/patches/2221641/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "ltp@lists.linux.it" ], "Delivered-To": [ "patchwork-incoming@legolas.ozlabs.org", "ltp@picard.linux.it" ], "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=lists.linux.it header.i=@lists.linux.it\n header.a=rsa-sha256 header.s=picard header.b=IPY4tt06;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256\n header.s=google header.b=J50UxYaB;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it\n (client-ip=2001:1418:10:5::2; helo=picard.linux.it;\n envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsLRx5KSbz1yGb\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 12:32:28 +1000 (AEST)", "from picard.linux.it (localhost [IPv6:::1])\n\tby picard.linux.it (Postfix) with ESMTP id EBBDE3E60AD\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 04:32:25 +0200 (CEST)", "from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature ECDSA (secp384r1))\n (No client certificate requested)\n by picard.linux.it (Postfix) with ESMTPS id 5FF423E602F\n for <ltp@lists.linux.it>; Fri, 10 Apr 2026 04:32:22 +0200 (CEST)", "from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n [IPv6:2a00:1450:4864:20::335])\n (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 9AE90600054\n for <ltp@lists.linux.it>; Fri, 10 Apr 2026 04:32:21 +0200 (CEST)", "by mail-wm1-x335.google.com with SMTP id\n 5b1f17b1804b1-488a4bc360bso8381935e9.0\n for <ltp@lists.linux.it>; Thu, 09 Apr 2026 19:32:21 -0700 (PDT)", "from localhost ([2a07:de40:b240:0:2ad6:ed42:2ad6:ed42])\n by smtp.gmail.com with UTF8SMTPSA id\n 5b1f17b1804b1-488d532ed4dsm36146795e9.4.2026.04.09.19.32.20\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Thu, 09 Apr 2026 19:32:20 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=lists.linux.it;\n i=@lists.linux.it; q=dns/txt; s=picard; t=1775788346; h=to : date :\n message-id : in-reply-to : references : mime-version : subject :\n list-id : list-unsubscribe : list-archive : list-post : list-help :\n list-subscribe : from : reply-to : content-type :\n content-transfer-encoding : sender : from;\n bh=i4COvm1n959OT9k9D1yktuluTcuIcFmDCvWIfDksqrA=;\n b=IPY4tt06N2MIkiGGS+xXfYeUQBmAq2WocbhYpu9ydjVXwwsHrtWVxfHetfNCEnNI3kPJu\n fgzz/f9q3MDzIEUnT/8hkBdPw1cF6YMimvvf+abg6/pbt1JtbIbJHAeghw/k3iH2GH8bg11\n 61YBVszoLrl575vWpg21yErJr0WY/y8=", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=suse.com; s=google; t=1775788341; x=1776393141; darn=lists.linux.it;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=/KQvUyY4hFx23OLHpClhb/xFevHa4DCnMOgwsQfBrYI=;\n b=J50UxYaBdi+ucPvcl4fnxLF9CjWRbiZz43E857GSxkqW6acwlWKXxiiZ0RuMr1dUj6\n hsOZLYMQMfs5ofii3Un6V7amXG74ZwKgYr9twfh9BEcsuj148XZxvXgN+1CaoqAPK3dG\n wuO57WciCh4nmKJmsw7f2o+z81UMzhPlUhdJKdNBVeeRLsjkDQz4v0Ncwd//HG/wF9AV\n cC26HEhjFj2NdnDm+Hak1/7HrWOs+E22FjdU+/olCcWk+WUxehRWCIvpKD9pMIYmcJI0\n 8MBwUaGxvYvtEofQhxoZtLK0agbobMI3Otx4J2AewmCi13zESOs/HvhCB5dTWP3/eRUK\n JaLw==" ], "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775788341; x=1776393141;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=/KQvUyY4hFx23OLHpClhb/xFevHa4DCnMOgwsQfBrYI=;\n b=IfqgpWvdSkh8pp4uTjmQXQFn22uhBSvDNCkp6ixFWn1JGoOgHBl3SsEy+yLP3gvb7o\n 48RqftM8pJC4Xie3RBqQ7v5zukiREsxQfuE+AT2w+O3HYZs0RC0X4PVfqUhOId38e3cl\n NPTzr0ZLDG0ukCKs3ERzTgWTUnww5gXkKUqbnHWK3QipfGgy5+3Egv+Ha61p/JwAGX/I\n FjSFNe93baQcpUvd0e5c5fMUgFuywBslQMneHcCEUe8qfnItagXaSiiphDXpwm27H6C2\n uH6zCrVZbmkpSQq4HOXqaRLqzuAs/pQjfJVyOxwSGVdQjyb7LqHTJ/djrE7ZHAbcrRgM\n nKGw==", "X-Gm-Message-State": "AOJu0YzUlIH9Tt0MGSTUPGOuyhWQdMR9xDX5T41k3DaJ8nkAytF+qXbf\n JihKspO2x7ltRWinDY9Gh6b3vwmxVqm5P5M7CuhRhbDCj5EZSGaOqawMHYNvdIviafkApIKj4Fa\n w1+Q=", "X-Gm-Gg": "AeBDieslQEFUMgYbuO9TBqGYDjBKaXHWT6zsgpkp9BXlJRTj4Ez0JqJLTN3EL7A4Gbl\n 7qAakVSSJfObfXn5rPTemlJxwSrumE2j3Nfy87gR8yMwMaXfmQaYxAKWM9I4m7Y2FFLQ5WZljlO\n 8OTh7+xfCyFgbdVg9kObwKtw2Z0tt/up9h6UJ0I8S7jqzsx4J+KI/FhWPKOxoG3iUXaZdgXPvxs\n 5qddxOwb8To3VvjuTmc0PZnUqPwYtpjyDYdcGmxxUVaUOdthey8SHSGg+4VA0BivwIkCZoJUq+T\n AXBa4qmbqcQigF1nqZGUiZ6ktK6ihYMiAT66w9lQxcyPpgyx76nSv43vULC/TRIhte7FNtFJrBW\n bq4hdfpzTCOLx0PQamMulQ16l6SoqM3PNSBe/MyWbKmqengZHs/62NFvkZ/oIfAept+938Uun+E\n Mn+Lu06yY/w+g=", "X-Received": "by 2002:a05:600c:1987:b0:488:b187:d8ed with SMTP id\n 5b1f17b1804b1-488d67bf765mr13166965e9.2.1775788340739;\n Thu, 09 Apr 2026 19:32:20 -0700 (PDT)", "To": "ltp@lists.linux.it", "Date": "Fri, 10 Apr 2026 02:31:52 +0000", "Message-ID": "<20260410023201.18119-1-wegao@suse.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20260325011605.5957-1-wegao@suse.com>", "References": "<20260325011605.5957-1-wegao@suse.com>", "MIME-Version": "1.0", "X-Spam-Status": "No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID,\n DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS shortcircuit=no\n autolearn=disabled version=4.0.1", "X-Spam-Checker-Version": "SpamAssassin 4.0.1 (2024-03-25) on in-5.smtp.seeweb.it", "X-Virus-Scanned": "clamav-milter 1.0.9 at in-5.smtp.seeweb.it", "X-Virus-Status": "Clean", "Subject": "[LTP] [PATCH v6] mremap07.c: New case check mremap with\n MREMAP_DONTUNMAP", "X-BeenThere": "ltp@lists.linux.it", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Linux Test Project <ltp.lists.linux.it>", "List-Unsubscribe": "<https://lists.linux.it/options/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=unsubscribe>", "List-Archive": "<http://lists.linux.it/pipermail/ltp/>", "List-Post": "<mailto:ltp@lists.linux.it>", "List-Help": "<mailto:ltp-request@lists.linux.it?subject=help>", "List-Subscribe": "<https://lists.linux.it/listinfo/ltp>,\n <mailto:ltp-request@lists.linux.it?subject=subscribe>", "From": "Wei Gao via ltp <ltp@lists.linux.it>", "Reply-To": "Wei Gao <wegao@suse.com>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it", "Sender": "\"ltp\" <ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it>" }, "content": "This case test mremap() with MREMAP_DONTUNMAP and use userfaultfd\nverifies fault which triggered by accessing old memory region.\n\nFixes: https://github.com/linux-test-project/ltp/issues/1168\nSigned-off-by: Wei Gao <wegao@suse.com>\n---\nv5->v6:\n- Refined the test description header\n- Added a missing return NULL to the fault_handler_thread\n- Replaced a manual strcmp and tst_res conditional block with the TST_EXP_EQ_STR macro\n configure.ac | 1 +\n runtest/syscalls | 1 +\n testcases/kernel/syscalls/mremap/.gitignore | 1 +\n testcases/kernel/syscalls/mremap/Makefile | 1 +\n testcases/kernel/syscalls/mremap/mremap07.c | 158 ++++++++++++++++++++\n 5 files changed, 162 insertions(+)\n create mode 100644 testcases/kernel/syscalls/mremap/mremap07.c", "diff": "diff --git a/configure.ac b/configure.ac\nindex 812f17d8b..211aaa8ad 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -46,6 +46,7 @@ AC_CHECK_DECLS([MADV_MERGEABLE],,,[#include <sys/mman.h>])\n AC_CHECK_DECLS([NFTA_CHAIN_ID, NFTA_VERDICT_CHAIN_ID],,,[#include <linux/netfilter/nf_tables.h>])\n AC_CHECK_DECLS([PR_CAPBSET_DROP, PR_CAPBSET_READ],,,[#include <sys/prctl.h>])\n AC_CHECK_DECLS([SEM_STAT_ANY],,,[#include <sys/sem.h>])\n+AC_CHECK_DECLS([MREMAP_DONTUNMAP],,,[#include <linux/mman.h>])\n \n AC_CHECK_HEADERS_ONCE([ \\\n aio.h \\\ndiff --git a/runtest/syscalls b/runtest/syscalls\nindex d72fceb5e..b9a9ce5fe 100644\n--- a/runtest/syscalls\n+++ b/runtest/syscalls\n@@ -927,6 +927,7 @@ mremap03 mremap03\n mremap04 mremap04\n mremap05 mremap05\n mremap06 mremap06\n+mremap07 mremap07\n \n mseal01 mseal01\n mseal02 mseal02\ndiff --git a/testcases/kernel/syscalls/mremap/.gitignore b/testcases/kernel/syscalls/mremap/.gitignore\nindex ec15a19cd..292899e03 100644\n--- a/testcases/kernel/syscalls/mremap/.gitignore\n+++ b/testcases/kernel/syscalls/mremap/.gitignore\n@@ -4,3 +4,4 @@\n /mremap04\n /mremap05\n /mremap06\n+/mremap07\ndiff --git a/testcases/kernel/syscalls/mremap/Makefile b/testcases/kernel/syscalls/mremap/Makefile\nindex 9f5aca9ec..8811b887e 100644\n--- a/testcases/kernel/syscalls/mremap/Makefile\n+++ b/testcases/kernel/syscalls/mremap/Makefile\n@@ -8,5 +8,6 @@ LTPLIBS = ipc\n include $(top_srcdir)/include/mk/testcases.mk\n \n mremap04: LTPLDLIBS = -lltpipc\n+mremap07: LDLIBS += -lpthread\n \n include $(top_srcdir)/include/mk/generic_leaf_target.mk\ndiff --git a/testcases/kernel/syscalls/mremap/mremap07.c b/testcases/kernel/syscalls/mremap/mremap07.c\nnew file mode 100644\nindex 000000000..0510fdfe1\n--- /dev/null\n+++ b/testcases/kernel/syscalls/mremap/mremap07.c\n@@ -0,0 +1,158 @@\n+// SPDX-License-Identifier: GPL-2.0-or-later\n+/*\n+ * Copyright (c) 2025 Wei Gao <wegao@suse.com>\n+ */\n+\n+/*\\\n+ * LTP test case for mremap() with MREMAP_DONTUNMAP and userfaultfd.\n+ *\n+ * Test mremap() with MREMAP_DONTUNMAP and verify that accessing the\n+ * old memory region triggers a page fault, which is then correctly\n+ * handled by a userfaultfd handler.\n+ */\n+\n+#define _GNU_SOURCE\n+#include <poll.h>\n+#include <pthread.h>\n+#include <linux/mman.h>\n+\n+#include \"tst_test.h\"\n+#include \"tst_safe_pthread.h\"\n+#include \"lapi/userfaultfd.h\"\n+#include \"config.h\"\n+\n+#if HAVE_DECL_MREMAP_DONTUNMAP\n+\n+static int page_size;\n+static int uffd = -1;\n+static char *fault_addr;\n+static char *new_remap_addr;\n+\n+static const char *test_string = \"Hello, world! This is a test string that fills up a page.\";\n+\n+static void *fault_handler_thread(void *arg LTP_ATTRIBUTE_UNUSED)\n+{\n+\tstruct uffd_msg msg;\n+\tstruct uffdio_copy uffdio_copy;\n+\n+\tTST_CHECKPOINT_WAIT(0);\n+\n+\tstruct pollfd pollfd;\n+\n+\tpollfd.fd = uffd;\n+\tpollfd.events = POLLIN;\n+\n+\tint nready = poll(&pollfd, 1, -1);\n+\n+\tif (nready == -1)\n+\t\ttst_brk(TBROK | TERRNO, \"poll() failed\");\n+\n+\tif (nready == 0)\n+\t\ttst_brk(TBROK, \"poll() timed out unexpectedly\");\n+\n+\tSAFE_READ(1, uffd, &msg, sizeof(msg));\n+\n+\tif (msg.event != UFFD_EVENT_PAGEFAULT)\n+\t\ttst_brk(TBROK, \"Received unexpected UFFD_EVENT: %d\", msg.event);\n+\n+\tif ((char *)msg.arg.pagefault.address != fault_addr)\n+\t\ttst_brk(TBROK, \"Page fault on unexpected address: %p\", (void *)msg.arg.pagefault.address);\n+\n+\ttst_res(TINFO, \"Userfaultfd handler caught a page fault at %p\", (void *)msg.arg.pagefault.address);\n+\n+\tuffdio_copy.src = (unsigned long)new_remap_addr;\n+\tuffdio_copy.dst = (unsigned long)fault_addr;\n+\tuffdio_copy.len = page_size;\n+\tuffdio_copy.mode = 0;\n+\tuffdio_copy.copy = 0;\n+\n+\tSAFE_IOCTL(uffd, UFFDIO_COPY, &uffdio_copy);\n+\ttst_res(TPASS, \"Userfaultfd handler successfully handled the fault\");\n+\n+\treturn NULL;\n+}\n+\n+static void setup(void)\n+{\n+\tpage_size = getpagesize();\n+\tstruct uffdio_api uffdio_api;\n+\tstruct uffdio_register uffdio_register;\n+\n+\tuffd = SAFE_USERFAULTFD(O_CLOEXEC | O_NONBLOCK, true);\n+\n+\tuffdio_api.api = UFFD_API;\n+\tuffdio_api.features = 0;\n+\tSAFE_IOCTL(uffd, UFFDIO_API, &uffdio_api);\n+\n+\tfault_addr = SAFE_MMAP(NULL, page_size,\n+\t\tPROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n+\n+\ttst_res(TINFO, \"Original mapping created at %p\", (void *)fault_addr);\n+\n+\tstrcpy(fault_addr, \"ABCD\");\n+\n+\tuffdio_register.range.start = (unsigned long)fault_addr;\n+\tuffdio_register.range.len = page_size;\n+\tuffdio_register.mode = UFFDIO_REGISTER_MODE_MISSING;\n+\tSAFE_IOCTL(uffd, UFFDIO_REGISTER, &uffdio_register);\n+}\n+\n+static void cleanup(void)\n+{\n+\tif (new_remap_addr && new_remap_addr != MAP_FAILED)\n+\t\tSAFE_MUNMAP(new_remap_addr, page_size);\n+\n+\tif (fault_addr && fault_addr != MAP_FAILED)\n+\t\tSAFE_MUNMAP(fault_addr, page_size);\n+\n+\tif (uffd != -1)\n+\t\tSAFE_CLOSE(uffd);\n+}\n+\n+static void run(void)\n+{\n+\tpthread_t handler_thread;\n+\n+\tSAFE_PTHREAD_CREATE(&handler_thread, NULL,\n+\t\tfault_handler_thread, NULL);\n+\n+\tnew_remap_addr = mremap(fault_addr, page_size, page_size,\n+\t\tMREMAP_DONTUNMAP | MREMAP_MAYMOVE, NULL);\n+\n+\tif (new_remap_addr == MAP_FAILED)\n+\t\ttst_brk(TBROK | TERRNO, \"mremap failed\");\n+\n+\ttst_res(TINFO, \"New mapping created at %p\", (void *)new_remap_addr);\n+\n+\tstrcpy(new_remap_addr, test_string);\n+\n+\tTST_CHECKPOINT_WAKE(0);\n+\n+\ttst_res(TINFO, \"Main thread accessing old address %p to trigger fault\",\n+\t\t\t(void *)fault_addr);\n+\n+\t(void)*(volatile char *)fault_addr;\n+\n+\tSAFE_PTHREAD_JOIN(handler_thread, NULL);\n+\n+\tTST_EXP_EQ_STR(fault_addr, test_string);\n+\n+\tSAFE_MUNMAP(new_remap_addr, page_size);\n+\tnew_remap_addr = NULL;\n+}\n+\n+static struct tst_test test = {\n+\t.test_all = run,\n+\t.setup = setup,\n+\t.needs_checkpoints = 1,\n+\t.cleanup = cleanup,\n+\t.needs_kconfigs = (const char *[]) {\n+\t\t\"CONFIG_USERFAULTFD=y\",\n+\t\tNULL,\n+\t},\n+\t.min_kver = \"5.7\",\n+};\n+\n+#else\n+TST_TEST_TCONF(\"Missing MREMAP_DONTUNMAP in <linux/mman.h>\");\n+#endif\n", "prefixes": [ "v6" ] }