* + selftests-memfd-close-fd-in-sysctl-helpers.patch added to mm-unstable branch
[not found] <20261113071306.1673-1-zhangchujun@cmss.chinamobile.com>
@ 2026-11-22 6:42 ` Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-11-22 6:42 UTC (permalink / raw)
To: mm-commits, shuah, hughd, david, baolin.wang, zhangchujun, akpm
The patch titled
Subject: selftests/memfd: close fd in sysctl helpers
has been added to the -mm mm-unstable branch. Its filename is
selftests-memfd-close-fd-in-sysctl-helpers.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftests-memfd-close-fd-in-sysctl-helpers.patch
This patch will later appear in the mm-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: Zhang Chujun <zhangchujun@cmss.chinamobile.com>
Subject: selftests/memfd: close fd in sysctl helpers
Date: Fri, 13 Nov 2026 15:13:06 +0800
The three sysctl helpers sysctl_assert_write(), sysctl_fail_write()
and sysctl_assert_equal() open /proc/sys/vm/memfd_noexec but never
close the descriptor, leaking one fd on every call. The noexec tests
call these helpers in a loop, so the test can run out of file
descriptors on a system with a low limit.
Close the fd before returning from each helper.
Link: https://patch.msgid.link/20261113071306.1673-1-zhangchujun@cmss.chinamobile.com
Fixes: 6469b66e3f5a ("selftests: improve vm.memfd_noexec sysctl tests")
Signed-off-by: Zhang Chujun <zhangchujun@cmss.chinamobile.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: David Hildenbrand <david@kernel.org>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Shuah Khan <shuah@kernel.org>
tools/testing/selftests/memfd/memfd_test.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/tools/testing/selftests/memfd/memfd_test.c~selftests-memfd-close-fd-in-sysctl-helpers
+++ a/tools/testing/selftests/memfd/memfd_test.c
@@ -126,6 +126,8 @@ static void sysctl_assert_write(const ch
printf("write sysctl %s failed: %m\n", val);
abort();
}
+
+ close(fd);
}
static void sysctl_fail_write(const char *val)
@@ -142,6 +144,8 @@ static void sysctl_fail_write(const char
val);
abort();
}
+
+ close(fd);
}
static void sysctl_assert_equal(const char *val)
@@ -159,6 +163,8 @@ static void sysctl_assert_equal(const ch
abort();
}
+ close(fd);
+
/* Strip trailing whitespace. */
p = buf;
while (!isspace(*p))
_
Patches currently in -mm which might be from zhangchujun@cmss.chinamobile.com are
mm-page_owner-use-%u-to-print-the-stack-depot-handle.patch
selftests-cgroup-test_zswap-check-malloc-return-value.patch
selftests-memfd-close-fd-in-sysctl-helpers.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-22 6:42 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20261113071306.1673-1-zhangchujun@cmss.chinamobile.com>
2026-11-22 6:42 ` + selftests-memfd-close-fd-in-sysctl-helpers.patch added to mm-unstable branch Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox