mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Huacai Chen <chenhuacai@kernel.org>
Cc: WangYuli <wangyuli@uniontech.com>,
	corbet@lwn.net, kernel@xen0n.name, akpm@linux-foundation.org,
	jeffxu@chromium.org, Liam.Howlett@oracle.com, kees@kernel.org,
	hca@linux.ibm.com, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
	xry111@xry111.site, tglx@linutronix.de,
	thomas.weissschuh@linutronix.de, Jason@zx2c4.com,
	zhanjun@uniontech.com, niecheng1@uniontech.com,
	guanwentao@uniontech.com
Subject: Re: [PATCH v2] mseal sysmap: enable LoongArch
Date: Wed, 16 Apr 2025 09:03:16 +0100	[thread overview]
Message-ID: <21558466-962c-4fb9-953b-911d2a586cbc@lucifer.local> (raw)
In-Reply-To: <CAAhV-H4=SZrJjVwVv6fqxTZn9ODP-s1ZEgYKTmHMPH7aoJuvng@mail.gmail.com>

On Wed, Apr 16, 2025 at 03:53:51PM +0800, Huacai Chen wrote:
> Hi, Lorenzo,
>
> On Tue, Apr 15, 2025 at 11:53 PM Lorenzo Stoakes
> <lorenzo.stoakes@oracle.com> wrote:
> >
> > On Tue, Apr 15, 2025 at 11:39:03PM +0800, WangYuli wrote:
> > > Provide support for CONFIG_MSEAL_SYSTEM_MAPPINGS on LoongArch,
> > > covering the vdso.
> >
> > I've also checked and determined that, as far as I can tell, the loongarch
> > arch-specific doe don't appear at any point to rely upon remapping the VDSO
> > or VVAR areas so sealing these should not be problematic.
> What does "remapping the VDSO" mean here? There is a function
> vdso_mremap() in arch/loongarch/kernel/vdso.c.

It means remapping the VDSO (and VVAR) since VMA sealing prevents this. VMA
sealing means that you map, and that's it until process tear down, more or
less...

I mean this is the thing, in my view, anybody enabling a feature that
prevents you from doing X with Y should understand that this is the case,
and explicitly state that no - it appears that we don't need to do X with
Y - in any legitimate operation.

It seems that so far, I am yet to encounter anybody enabling this feature
who does. Which is concerning. But by the by. I guess I will continue to
have to say the same thing to everybody and then go check it myself each
time :)

Anyway, what you're referring to is a hook that is invoked when _userland_
tries to remap the VDSO, which will now be prevented, if the user enables
this feature.

So those using this feature will break a bunch of userspace, namely anybody
who wants/needs to remap the VDSO/VVAR etc. examples are CRIU, rr, etc.

So this is fine.

The problem would be if the _arch_ code itself needed to remap or move the
VDSO or VVAR around. This would be odd, and I think we know of only one
case (and even then it's uncertain), but it's important that people
explicitly check this.

_As far as I can tell_, loongarch doesn't need to do this so it is safe to
enable this there, given the feature is opt-in.

But this kind of concern is precisely why we need arch maintainers to check
this.

I did insist on these limitations and concerns being placed in the
documentation and Kconfig entries so people are aware on review.

Thanks, Lorenzo

>
> Huacai
>
> >
> > >
> > > Link: https://lore.kernel.org/all/25bad37f-273e-4626-999c-e1890be96182@lucifer.local/
> > > Tested-by: Yuli Wang <wangyuli@uniontech.com>
> > > Signed-off-by: Yuli Wang <wangyuli@uniontech.com>
> >
> > LGTM,
> >
> > Acked-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
> >
> > But let's get some R-b's from the arch people please!
> >
> > > ---
> > > Changelog:
> > >  *v1->v2: Modify mseal_sys_mappings/arch-support.txt.
> > > ---
> > >  .../features/core/mseal_sys_mappings/arch-support.txt         | 2 +-
> > >  Documentation/userspace-api/mseal.rst                         | 2 +-
> > >  arch/loongarch/Kconfig                                        | 1 +
> > >  arch/loongarch/kernel/vdso.c                                  | 4 +++-
> > >  4 files changed, 6 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/Documentation/features/core/mseal_sys_mappings/arch-support.txt b/Documentation/features/core/mseal_sys_mappings/arch-support.txt
> > > index c6cab9760d57..a3c24233eb9b 100644
> > > --- a/Documentation/features/core/mseal_sys_mappings/arch-support.txt
> > > +++ b/Documentation/features/core/mseal_sys_mappings/arch-support.txt
> > > @@ -12,7 +12,7 @@
> > >      |       arm64: |  ok  |
> > >      |        csky: |  N/A |
> > >      |     hexagon: |  N/A |
> > > -    |   loongarch: | TODO |
> > > +    |   loongarch: |  ok  |
> > >      |        m68k: |  N/A |
> > >      |  microblaze: |  N/A |
> > >      |        mips: | TODO |
> > > diff --git a/Documentation/userspace-api/mseal.rst b/Documentation/userspace-api/mseal.rst
> > > index 1dabfc29be0d..ef733f69003d 100644
> > > --- a/Documentation/userspace-api/mseal.rst
> > > +++ b/Documentation/userspace-api/mseal.rst
> > > @@ -144,7 +144,7 @@ Use cases
> > >    architecture.
> > >
> > >    The following architectures currently support this feature: x86-64, arm64,
> > > -  and s390.
> > > +  loongarch and s390.
> > >
> > >    WARNING: This feature breaks programs which rely on relocating
> > >    or unmapping system mappings. Known broken software at the time
> > > diff --git a/arch/loongarch/Kconfig b/arch/loongarch/Kconfig
> > > index 067c0b994648..54ed5b59a690 100644
> > > --- a/arch/loongarch/Kconfig
> > > +++ b/arch/loongarch/Kconfig
> > > @@ -69,6 +69,7 @@ config LOONGARCH
> > >       select ARCH_SUPPORTS_INT128 if CC_HAS_INT128
> > >       select ARCH_SUPPORTS_LTO_CLANG
> > >       select ARCH_SUPPORTS_LTO_CLANG_THIN
> > > +     select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS
> > >       select ARCH_SUPPORTS_NUMA_BALANCING
> > >       select ARCH_SUPPORTS_RT
> > >       select ARCH_USE_BUILTIN_BSWAP
> > > diff --git a/arch/loongarch/kernel/vdso.c b/arch/loongarch/kernel/vdso.c
> > > index 10cf1608c7b3..7b888d9085a0 100644
> > > --- a/arch/loongarch/kernel/vdso.c
> > > +++ b/arch/loongarch/kernel/vdso.c
> > > @@ -105,7 +105,9 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
> > >
> > >       vdso_addr = data_addr + VVAR_SIZE;
> > >       vma = _install_special_mapping(mm, vdso_addr, info->size,
> > > -                                    VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
> > > +                                    VM_READ | VM_EXEC |
> > > +                                    VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC |
> > > +                                    VM_SEALED_SYSMAP,
> > >                                      &info->code_mapping);
> > >       if (IS_ERR(vma)) {
> > >               ret = PTR_ERR(vma);
> > > --
> > > 2.49.0
> > >

  reply	other threads:[~2025-04-16  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 15:39 WangYuli
2025-04-15 15:53 ` Lorenzo Stoakes
2025-04-16  7:53   ` Huacai Chen
2025-04-16  8:03     ` Lorenzo Stoakes [this message]
2025-04-16  9:11       ` Huacai Chen
2025-04-16  9:14         ` Lorenzo Stoakes
2025-04-16  9:17           ` Huacai Chen
2025-04-15 20:46 ` Jeff Xu
2025-04-16  0:43 ` Liam R. Howlett

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=21558466-962c-4fb9-953b-911d2a586cbc@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Jason@zx2c4.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenhuacai@kernel.org \
    --cc=corbet@lwn.net \
    --cc=guanwentao@uniontech.com \
    --cc=hca@linux.ibm.com \
    --cc=jeffxu@chromium.org \
    --cc=kees@kernel.org \
    --cc=kernel@xen0n.name \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=loongarch@lists.linux.dev \
    --cc=niecheng1@uniontech.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.weissschuh@linutronix.de \
    --cc=wangyuli@uniontech.com \
    --cc=xry111@xry111.site \
    --cc=zhanjun@uniontech.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

all inboxes | Powered by JetHome®