[PATCH v8 6/8] elf: Add support to memory sealing

Yury Khrustalev yury.khrustalev@arm.com
Fri Jan 31 15:43:44 GMT 2025


Hi Adhemerval,

On Wed, Jan 29, 2025 at 02:22:40PM -0300, Adhemerval Zanella wrote:
> The new Linux mseal syscall allows mark a memory mapping to avoid
>
> ...
>
> diff --git a/sysdeps/aarch64/dl-prop.h b/sysdeps/aarch64/dl-prop.h
> index abca2be7fa..5ffff60cf5 100644
> --- a/sysdeps/aarch64/dl-prop.h
> +++ b/sysdeps/aarch64/dl-prop.h
> @@ -19,6 +19,8 @@
>  #ifndef _DL_PROP_H
>  #define _DL_PROP_H
>  
> +#include <dl-prop-mseal.h>
> +
>  extern void _dl_bti_protect (struct link_map *, int) attribute_hidden;
>  
>  extern void _dl_bti_check (struct link_map *, const char *)
> @@ -50,6 +52,9 @@ static inline int
>  _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
>  			  uint32_t datasz, void *data)
>  {
> +  if (_dl_process_gnu_property_seal (l, fd, type, datasz, data))
> +    return 0;
> +

Returning 0 here prevents other properties from being processed.
Returning 1 seems to fix it, however the whole model of relying
on return value of this function for deciding whether to continue
or stop seem a bit strange.

>    if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
>      {
>
> ...
>
> diff --git a/sysdeps/generic/dl-prop-mseal.h b/sysdeps/generic/dl-prop-mseal.h
> new file mode 100644
> index 0000000000..94ce72b4d2
> --- /dev/null
> +++ b/sysdeps/generic/dl-prop-mseal.h
> @@ -0,0 +1,34 @@
> +/* Support for GNU properties.  Generic version.
> +   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/>.  */
> +
> +#ifndef _DL_PROP_MSEAL_H
> +#define _LD_PROP_MSEAL_H

Should be _DL_PROP_MSEAL_H (typo: DL <-> LD).

> ...

I'm still in the process of reviewing and testing it on AArch64, so expect
more feedback.

Kind regards,
Yury



More information about the Libc-alpha mailing list