Re: [RFC PATCH v5 0/7] mseal system mappings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 18, 2025 at 6:18 PM Pedro Falcato <pedro.falcato@xxxxxxxxx> wrote:
>
> On Thu, Feb 13, 2025 at 8:47 PM Kees Cook <kees@xxxxxxxxxx> wrote:
> >
> > On Thu, Feb 13, 2025 at 07:59:48PM +0000, Pedro Falcato wrote:
> > > On Wed, Feb 12, 2025 at 2:02 PM Lorenzo Stoakes
> > > <lorenzo.stoakes@xxxxxxxxxx> wrote:
> > > >
> > > > (sorry I really am struggling to reply to mail as lore still seems to be
> > > > broken).
> > > >
> > > > On Wed, Feb 12, 2025 at 12:37:50PM +0000, Pedro Falcato wrote:
> > > > > On Wed, Feb 12, 2025 at 11:25 AM Lorenzo Stoakes
> > > > > <lorenzo.stoakes@xxxxxxxxxx> wrote:
> > > > > >
> > > > > > On Wed, Feb 12, 2025 at 03:21:48AM +0000, jeffxu@xxxxxxxxxxxx wrote:
> > > > > > > From: Jeff Xu <jeffxu@xxxxxxxxxxxx>
> > > > > > >
> > > > > > > The commit message in the first patch contains the full description of
> > > > > > > this series.
> > > > > >
> > > > [...]
> > > > >
> > > > > FWIW, although it would (at the moment) be hard to pull off in the
> > > > > libc, I still much prefer it to playing these weird games with CONFIG
> > > > > options and kernel command line options and prctl and personality and
> > > > > whatnot. It seems to me like we're trying to stick policy where it
> > > > > doesn't belong.
> > > >
> > > > The problem is, as a security feature, you don't want to make it trivially
> > > > easy to disable.
> > > >
> > > > I mean we _need_ a config option to be able to strictly enforce only making
> > > > the feature enable-able on architectures and configuration option
> > > > combinations that work.
> > > >
> > > > But if there is userspace that will be broken, we really have to have some
> > > > way of avoiding the disconnect between somebody making policy decision at
> > > > the kernel level and somebody trying to run something.
> > > >
> > > > Because I can easily envision somebody enabling this as a 'good security
> > > > feature' for a distro release or such, only for somebody else to later try
> > > > rr, CRIU, or whatever else and for it to just not work or fail subtly and
> > > > to have no idea why.
> > >
> > > Ok so I went looking around for the glibc patchset. It seems they're
> > > moving away from tunables and there was a nice
> > > GNU_PROPERTY_MEMORY_SEAL added to binutils.
> > > So my proposal is to parse this property on the binfmt_elf.c side, and
> > > mm would use this to know if we should seal these mappings. This seems
> > > to tackle compatibility problems,
> > > and glibc isn't sealing programs without this program header anyway. Thoughts?
> >
> > It seems to me that doing this ties it to the binary, rather than
> > execution context, which may want to seal/not-seal, etc. I have a sense
> > that it's be better as a secure bit, or prctl, or something like that. The
> > properties seem to be better suited for "this binary _can_ do a thing"
> > or "this binary _requires_ a thing", like the GNU_STACK bits, etc. But
> > maybe there's more to this I'm not considering?
>
> Doesn't this exactly kind of Just Work though? "This binary can
> do/tolerate sealing". I would blindly guess that we don't have very
> opinionated shared libraries that do this kind of shenanigans
> unilaterally, so that's probably not something we really need to worry
> about (though I admittedly need to read through the glibc patchset,
> and nail down what they're thinking about doing with linking
> mseal-ready and mseal-non-ready ELF execs/shared objects together).
> The problem with something like prctl is that we either indirectly
> provide some kind of limited form of munseal, or we require some sort
> of handover (like personality(2) + execve(2)), which both sound like a
> huge PITA and still don't solve any of our backwards compat issues...
> all binaries would need to be patched with this
> prctl/personality()/whatever call, and old ones wouldn't work.
>
> The semantics behind GNU_PROPERTY_MEMORY_SEAL are unclear to me (maybe
> the toolchain folks could shed some light?), but it sounds like it'd
> fit perfectly.
> I suspect we probably want to parse this on the kernel's side anyway
> (to seal the main program/interp's segments)[1], then extending them
> to the kernel system mappings should be somewhat trivial...
> I don't think we'll ever get a program that can't cope with sealing
> the system mappings but can cope with sealing itself (and if we do, we
> just won't seal the entire thing and that's _okay_).
>
> Deploying mseal-ready programs could then be done in a phased way by
> distros. e.g chromeOS and android could simply enable the
> corresponding linker option in LDFLAGS and let it rip. Other more
> mainstream distros could obviously take a little longer or test/deploy
> this on all programs not named gVisor and/or after CRIU is okay with
> all of this. We then might not need a user-configurable CONFIG_ (only
> an arch HAS_SYSTEM_MAPPINGS_MSEAL or whatever), nor a sysctl, and
> everyone is happy.
>
> I glanced through libc-alpha again and it seems like the glibc folks
> also seem to have reached the same idea, but I'd love to hear from
> Adhemerval.
>
> Am I missing anything?

Android's a bit interesting because there isn't really a "binary" in
the usual sense. an Android app is basically a shared library of JNI
code dlopen()ed into a clone() of an already-initialized Java runtime
(the "zygote").

that said, i'm not expecting sealing the vdso to be problematic (even
if i'm not sure how useful it is to do so, being unaware of any
exploit that's ever used this?).

for me the tricky part is when it's used for regular user shared
libraries which seems the most convincing use case to me, albeit
mainly for app compat reasons ["stopping apps from poking at
implementation details they shouldn't, which later causes breakage if
the implementation detail changes"]. the irony being that it'll
_cause_ app compat problems by breaking all such things all at once.
so that'll be "fun" for someone to try to roll out!

it also breaks dlclose() (unless your dlopen() was with RTLD_NODELETE,
which is not the default on Android either). that's fine for OS
libraries that have already been loaded by the zygote, but hard to
make a default. that said, i do expect games and banking apps to be
interested to try this when they hear about it.

anyway, in general i think an ELF property per-library sounds
reasonable, matching what we have for arm64 BTI. i have no strong
opinion on the system mappings and what if anything executables should
do, for the reasons given above, but the elf property sounds
reasonable.

> [1] we should probably nail this responsibility handover down before
> glibc msealing (or bionic) makes it to a release. It'd probably be a
> little nicer if we could mseal these segments from the kernel instead
> of forcing the libc to take care of this, now that we have this
> property.
>
> --
> Pedro





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux