]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/memfd: run sysctl tests when PID namespace support is enabled
authorIsaac J. Manjarres <isaacmanjarres@google.com>
Thu, 5 Dec 2024 19:29:41 +0000 (11:29 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Dec 2024 13:02:16 +0000 (14:02 +0100)
commitfcd39809bf673c47a91b7ea1185a4fedd3ac8149
tree758f252eddafc4336a0da10c504aae9387507f60
parentd3e73fe7ca21b0c70ffccd756c9b602567ae2cf5
selftests/memfd: run sysctl tests when PID namespace support is enabled

commit 6a75f19af16ff482cfd6085c77123aa0f464f8dd upstream.

The sysctl tests for vm.memfd_noexec rely on the kernel to support PID
namespaces (i.e.  the kernel is built with CONFIG_PID_NS=y).  If the
kernel the test runs on does not support PID namespaces, the first sysctl
test will fail when attempting to spawn a new thread in a new PID
namespace, abort the test, preventing the remaining tests from being run.

This is not desirable, as not all kernels need PID namespaces, but can
still use the other features provided by memfd.  Therefore, only run the
sysctl tests if the kernel supports PID namespaces.  Otherwise, skip those
tests and emit an informative message to let the user know why the sysctl
tests are not being run.

Link: https://lkml.kernel.org/r/20241205192943.3228757-1-isaacmanjarres@google.com
Fixes: 11f75a01448f ("selftests/memfd: add tests for MFD_NOEXEC_SEAL MFD_EXEC")
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
Reviewed-by: Jeff Xu <jeffxu@google.com>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: <stable@vger.kernel.org> [6.6+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/memfd/memfd_test.c