[PATCH v2] linux: Add mseal syscall support

Collin Funk collin.funk1@gmail.com
Mon Nov 10 19:43:22 GMT 2025


Hi Adhemerval,

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> +@item ENOSYS
> +The kernel does not support the @code{mseal} syscall.
> +
> +@strong{NB:} The memory sealing changes the lifetime of a mapping, where the
> +sealing memory could not be unmapped until the process terminates or replaces
> +the process image through @code{execve} function.  The sealed mappings are
> +inherited through @code{fork}.
> +
> +@end table
> +@end deftypefun

Shouldn't the section starting with @strong{NB:} be moved outside of the
table? Otherwise it looks as if the text is related to the failed call
with ENOSYS. Can you take a look at the PDF output before and after
moving outside of the table to see what I mean?

> diff --git a/sysdeps/unix/sysv/linux/tst-mseal-pkey.c b/sysdeps/unix/sysv/linux/tst-mseal-pkey.c
> new file mode 100644
> index 00000000000..d194fbaaafe
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/tst-mseal-pkey.c
> @@ -0,0 +1,84 @@
> +/* Basic tests for mseal and pkey.
> +   Copyright (C) 2025 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <errno.h>
> +#include <sys/mman.h>
> +#include <support/check.h>
> +#include <support/xunistd.h>
> +
> +static int
> +do_test (void)
> +{
> +  TEST_VERIFY_EXIT (mseal (MAP_FAILED, 0, 0) == -1);
> +  if (errno == ENOSYS || errno == EPERM)
> +    FAIL_UNSUPPORTED ("kernel does not support mseal");
> +  TEST_COMPARE (errno, EINVAL);

Shouldn't this be TEST_VERIFY instead of TEST_VERIFY_EXIT? Currently it
would exit on 32-bit platforms and not check for mseal being
unsupported.

> +  long pagesize = xsysconf (_SC_PAGESIZE);

Any reason not to use getpagesize () like in the other test? Or should
that one be changed to xsysconf (_SC_PAGESIZE)?

> +#include <support/test-driver.c>
> diff --git a/sysdeps/unix/sysv/linux/tst-mseal.c b/sysdeps/unix/sysv/linux/tst-mseal.c
> new file mode 100644
> index 00000000000..0aff1e9e4c1
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/tst-mseal.c
> @@ -0,0 +1,67 @@
> +/* Basic tests for mseal.
> +   Copyright (C) 2025 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <errno.h>
> +#include <sys/mman.h>
> +#include <support/check.h>
> +#include <support/xunistd.h>
> +
> +static int
> +do_test (void)
> +{
> +  TEST_VERIFY_EXIT (mseal (MAP_FAILED, 0, 0) == -1);
> +  if (errno == ENOSYS || errno == EPERM)
> +    FAIL_UNSUPPORTED ("kernel does not support mseal");
> +  TEST_COMPARE (errno, EINVAL);

Likewise, I think this one should be TEST_VERIFY.

Tested on x86_64 and things are fine, minus math failures seemingly due
to a previous change.

This one should be good after minor local changes, so:

Reviewed-by: Collin Funk <collin.funk1@gmail.com>

Thanks,
Collin


More information about the Libc-alpha mailing list