From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,shuah@kernel.org,hughd@google.com,
david@kernel.org,baolin.wang@linux.alibaba.com,
zhangchujun@cmss.chinamobile.com,akpm@linux-foundation.org
Subject: + selftests-memfd-close-fd-in-sysctl-helpers.patch added to mm-unstable branch
Date: Sat, 21 Nov 2026 22:42:38 -0800 [thread overview]
Message-ID: <20261122064238.CEB021F000D1@smtp.kernel.org> (raw)
In-Reply-To: <20261113071306.1673-1-zhangchujun@cmss.chinamobile.com>
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
parent reply other threads:[~2026-11-22 6:42 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20261113071306.1673-1-zhangchujun@cmss.chinamobile.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261122064238.CEB021F000D1@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=david@kernel.org \
--cc=hughd@google.com \
--cc=mm-commits@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=zhangchujun@cmss.chinamobile.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox