linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Kees Cook <kees@kernel.org>
Cc: jeffxu@chromium.org, akpm@linux-foundation.org,
	keescook@chromium.org, jannh@google.com,
	torvalds@linux-foundation.org, adhemerval.zanella@linaro.org,
	oleg@redhat.com, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org, linux-mm@kvack.org,
	jorgelo@chromium.org, sroettger@google.com, ojeda@kernel.org,
	adobriyan@gmail.com, anna-maria@linutronix.de,
	mark.rutland@arm.com, linus.walleij@linaro.org, Jason@zx2c4.com,
	deller@gmx.de, rdunlap@infradead.org, davem@davemloft.net,
	hch@lst.de, peterx@redhat.com, hca@linux.ibm.com,
	f.fainelli@gmail.com, gerg@kernel.org,
	dave.hansen@linux.intel.com, mingo@kernel.org, ardb@kernel.org,
	mhocko@suse.com, 42.hyeyoo@gmail.com, peterz@infradead.org,
	ardb@google.com, enh@google.com, rientjes@google.com,
	groeck@chromium.org, mpe@ellerman.id.au,
	Vlastimil Babka <vbabka@suse.cz>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	Andrei Vagin <avagin@gmail.com>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Mike Rapoport <mike.rapoport@gmail.com>,
	Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Subject: Re: [PATCH v4 1/1] exec: seal system mappings
Date: Fri, 3 Jan 2025 15:48:23 -0500	[thread overview]
Message-ID: <htdv44tqzi4jl2b7dwutsdwnh4tgrxq6xdvumi5wwu3hnh7sgw@tfwlal74ukx6> (raw)
In-Reply-To: <202412171248.409B10D@keescook>

* Kees Cook <kees@kernel.org> [241217 17:19]:
> On Mon, Nov 25, 2024 at 08:20:21PM +0000, jeffxu@chromium.org wrote:
> > Seal vdso, vvar, sigpage, uprobes and vsyscall.
> > 
> > Those mappings are readonly or executable only, sealing can protect
> > them from ever changing or unmapped during the life time of the process.
> > For complete descriptions of memory sealing, please see mseal.rst [1].
> > 
> > System mappings such as vdso, vvar, and sigpage (for arm) are
> > generated by the kernel during program initialization, and are
> > sealed after creation.
> > [...]
> >  
> > +	exec.seal_system_mappings = [KNL]
> > +			Format: { no | yes }
> > +			Seal system mappings: vdso, vvar, sigpage, vsyscall,
> > +			uprobe.
> > +			- 'no':  do not seal system mappings.
> > +			- 'yes': seal system mappings.
> > +			This overrides CONFIG_SEAL_SYSTEM_MAPPINGS=(y/n)
> > +			If not specified or invalid, default is the value set by
> > +			CONFIG_SEAL_SYSTEM_MAPPINGS.
> > +			This option has no effect if CONFIG_64BIT=n
> 
> I know there is a v5 coming, but I wanted to give my thoughts to help
> shape it based on the current discussion threads.
> 
> The callers of _install_special_mapping() cover what is mentioned here.
> The vdso is very common (arm, arm64, csky, hexagon, loongarch, mips,
> parisc, powerpc, riscv, s390, sh, sparc, x86, um). For those with vdso,
> some also have vvar (arm, arm64, loongarch, mips, powerpc, riscv, s390,
> sparc, x86). After that, I see a few extra things, in addition to
> sigpage and uprobes as mentioned already in the patch:
> 
> arm sigpage
> arm64 compat vectors (what is this for arm?)
> arm64 compat sigreturn (what is this for arm?)
> nios2 kuser helpers
> uprobes
> 
> As mentioned in the patch, there is also the x86_64 vsyscall mapping which
> eludes a regular grep since it's not using _install_special_mapping() :)
> 
> So I guess the question is: can we mseal all of these universally under
> a common knob? Do the different uses mean we need finer granularity of
> knob, and do different architectures need flexibility here too? The
> patch handles the arch question with CONFIG_ARCH_HAS_SEAL_SYSTEM_MAPPINGS
> (which I think will be renamed with s/SEAL/MSEAL/ if I am following the
> threads). This seems a good solution to me. My question is
> about if sigpage, vectors, and sigreturn can also be included? (It seems
> like the answer is "yes", but I didn't see mention of the arm64 compat
> mappings.)
> 
> Linus has expressed the desire that security features be available by
> default if they don't break existing userspace and that they be compiled
> in if possible (rather than be behind a CONFIG) so that code paths are
> being exercised to gain the most exposure to finding bugs. To that end,
> it's best to have a kernel command line to control it if it isn't safe
> to have always enabled. This is how we've handled _many_ features so that
> the code is built into the kernel, but that end users (e.g. distro users)
> can enable/disable a feature without rebuilding the entire kernel.
> 
> For a "built into the kernel but default disabled unless enabled at boot
> time" example see:
> 
> config RANDOMIZE_KSTACK_OFFSET
>         bool "Support for randomizing kernel stack offset on syscall entry" if EXPERT
>         default y
>         depends on HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
> ...
> config RANDOMIZE_KSTACK_OFFSET_DEFAULT
>         bool "Default state of kernel stack offset randomization"
>         depends on RANDOMIZE_KSTACK_OFFSET
> ...
> #ifdef CONFIG_RANDOMIZE_KSTACK_OFFSET
> DEFINE_STATIC_KEY_MAYBE_RO(CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT,
>                            randomize_kstack_offset);
> ...
> early_param("randomize_kstack_offset", early_randomize_kstack_offset);
> 
> 
> For an example of the older "not built into the kernel but when built in
> can be turned off at boot time" that predated Linus's recommendation see:
> 
> config HARDENED_USERCOPY
>         bool "Harden memory copies between kernel and userspace"
> ...
> static DEFINE_STATIC_KEY_FALSE_RO(bypass_usercopy_checks);
> ...
> __setup("hardened_usercopy=", parse_hardened_usercopy);
> 
> (This should arguably be "default y" in the kernel these days, but
> whatever.)
> 
> So, if we want to have a CONFIG_MSEAL_SYSTEM_MAPPINGS at all, it should
> be "default y" since we have the ...ARCH_HAS... config already, and then
> add a CONFIG_MSEAL_SYSTEM_MAPPINGS_DEFAULT that is off by default (since
> we expect there may be userspace impact) and tie _that_ to the kernel
> command-line so that end users can use it, or system builders can enable
> CONFIG_MSEAL_SYSTEM_MAPPINGS_DEFAULT.

So we have at least two userspace uses that this will breaks: checkpoint
restore and now gVisor, but who knows what else?  How many config
options before we decide this can't be just on by default?

We're also veering off what mimmutable does in bsd, for no good reason.
At what point do we decide that it's not worth pushing this?

I agree that security (and everything else) should be turned on (or
default to on) for everyone, when it doesn't break things for users.  I
think this isn't one of those at this point - it's breaking things by
changing the behaviour.

And we really don't understand what it will impact fully - considering
v4 is still resulting in new things that will be broken.

Thanks,
Liam


  parent reply	other threads:[~2025-01-03 20:49 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-25 20:20 [PATCH v4 0/1] Seal " jeffxu
2024-11-25 20:20 ` [PATCH v4 1/1] exec: seal " jeffxu
2024-11-25 20:40   ` Matthew Wilcox
2024-12-02 17:22     ` Jeff Xu
2024-12-02 17:57       ` Lorenzo Stoakes
2024-12-02 20:05         ` Jeff Xu
2024-12-02 19:57       ` Jeff Xu
2024-12-02 18:29   ` Lorenzo Stoakes
2024-12-02 20:38     ` Jeff Xu
2024-12-03  7:35       ` Lorenzo Stoakes
2024-12-03 18:19         ` Jeff Xu
2024-12-03 20:16           ` Lorenzo Stoakes
2024-12-04 14:04   ` Benjamin Berg
2024-12-04 17:43     ` Jeff Xu
2024-12-04 18:24       ` Benjamin Berg
2024-12-10  4:12   ` Andrei Vagin
2024-12-11 22:46     ` Jeff Xu
2024-12-13  6:33       ` Andrei Vagin
2024-12-16 18:35         ` Jeff Xu
2024-12-16 18:56           ` Liam R. Howlett
2024-12-16 20:20             ` Jeff Xu
2024-12-17 22:18   ` Kees Cook
2025-01-02 19:15     ` Andrei Vagin
2025-01-03 20:48     ` Liam R. Howlett [this message]
2025-01-07  1:17       ` Kees Cook
2025-02-04 18:17       ` Johannes Berg
2025-01-03 21:38     ` Lorenzo Stoakes
2025-01-07  1:12       ` Kees Cook
2025-01-13 21:26         ` Jeff Xu
2025-01-14  4:19           ` Matthew Wilcox
2025-01-15 19:02           ` Jeff Xu
2025-01-15 19:46             ` Lorenzo Stoakes
2025-01-15 20:20               ` Jeff Xu
2025-01-16 15:48                 ` Lorenzo Stoakes
2025-01-16 17:01                   ` Benjamin Berg
2025-01-16 17:16                     ` Lorenzo Stoakes
2025-01-16 17:18                     ` Pedro Falcato
2025-01-17 18:20                       ` Jeff Xu
2025-01-17 19:35                         ` enh
2025-01-17 20:15                           ` Jeff Xu
2025-01-17 22:08                           ` Liam R. Howlett
2025-01-21 15:38                             ` enh
2025-01-22 17:23                               ` Liam R. Howlett
2025-01-22 22:29                                 ` enh
2025-01-23  8:40                                   ` Vlastimil Babka
2025-01-23 21:50                                     ` enh
2025-01-23 22:38                                       ` Matthew Wilcox
2025-02-06 14:19                                         ` enh
2025-02-06 13:20                           ` Thomas Weißschuh
2025-02-06 14:38                             ` enh
2025-02-06 15:28                               ` Thomas Weißschuh
2025-02-06 15:51                                 ` enh
2025-02-06 16:37                                   ` Thomas Weißschuh
2025-01-17 18:08                   ` Jeff Xu
2025-01-15 23:52               ` Kees Cook
2025-01-16  5:26                 ` Christoph Hellwig
2025-01-16 19:40                   ` Kees Cook
2025-01-17 10:14                     ` Heiko Carstens
2025-01-16 15:34                 ` Lorenzo Stoakes
2025-01-16 19:44                   ` Kees Cook
2024-11-26 16:39 ` [PATCH v4 0/1] Seal " Lorenzo Stoakes
2024-12-02 17:28   ` Jeff Xu

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=htdv44tqzi4jl2b7dwutsdwnh4tgrxq6xdvumi5wwu3hnh7sgw@tfwlal74ukx6 \
    --to=liam.howlett@oracle.com \
    --cc=0x7f454c46@gmail.com \
    --cc=42.hyeyoo@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aleksandr.mikhalitsyn@canonical.com \
    --cc=anna-maria@linutronix.de \
    --cc=ardb@google.com \
    --cc=ardb@kernel.org \
    --cc=avagin@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=deller@gmx.de \
    --cc=enh@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=gerg@kernel.org \
    --cc=groeck@chromium.org \
    --cc=hca@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=jannh@google.com \
    --cc=jeffxu@chromium.org \
    --cc=jorgelo@chromium.org \
    --cc=kees@kernel.org \
    --cc=keescook@chromium.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mark.rutland@arm.com \
    --cc=mhocko@suse.com \
    --cc=mike.rapoport@gmail.com \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=ojeda@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterx@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=rientjes@google.com \
    --cc=sroettger@google.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    /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