linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Will Drewry <wad@chromium.org>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Robert Foss <robert.foss@collabora.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	kirill.shutemov@linux.intel.com, vbabka@suse.cz, mhocko@suse.com,
	mingo@kernel.org, dave.hansen@linux.intel.com,
	hannes@cmpxchg.org, dan.j.williams@intel.com,
	iamjoonsoo.kim@lge.com, acme@redhat.com,
	Kees Cook <keescook@chromium.org>,
	mgorman@techsingularity.net, atomlin@redhat.com,
	Hugh Dickins <hughd@google.com>,
	dyoung@redhat.com, Al Viro <viro@zeniv.linux.org.uk>,
	Daniel Cashman <dcashman@google.com>,
	w@1wt.eu, idryomov@gmail.com, yang.shi@linaro.org,
	vkuznets@redhat.com, vdavydov@virtuozzo.com,
	vitalywool@gmail.com, oleg@redhat.com, gang.chen.5i5j@gmail.com,
	koct9i@gmail.com, aarcange@redhat.com, aryabinin@virtuozzo.com,
	kuleshovmail@gmail.com, minchan@kernel.org, mguzik@redhat.com,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Ivan Krasin <krasin@google.com>,
	Roland McGrath <mcgrathr@chromium.org>,
	Mandeep Singh Baines <msb@chromium.org>,
	Ben Zhang <benzh@chromium.org>,
	Filipe Brandenburger <filbranden@chromium.org>
Subject: Re: [PATCH v1] mm, sysctl: Add sysctl for controlling VM_MAYEXEC taint
Date: Mon, 29 Aug 2016 10:25:02 -0500	[thread overview]
Message-ID: <CAAFS_9HiuMt=Xy=YXmvw0+kqcXw=8qXTx2-2bXaqPc_rjtRZgw@mail.gmail.com> (raw)
In-Reply-To: <20160826213227.GA11393@node.shutemov.name>

[-- Attachment #1: Type: text/plain, Size: 2485 bytes --]

On Fri, Aug 26, 2016 at 4:32 PM, Kirill A. Shutemov <kirill@shutemov.name>
wrote:

> On Fri, Aug 26, 2016 at 12:30:04PM -0400, robert.foss@collabora.com wrote:
> > From: Will Drewry <wad@chromium.org>
> >
> > This patch proposes a sysctl knob that allows a privileged user to
> > disable ~VM_MAYEXEC tainting when mapping in a vma from a MNT_NOEXEC
> > mountpoint.  It does not alter the normal behavior resulting from
> > attempting to directly mmap(PROT_EXEC) a vma (-EPERM) nor the behavior
> > of any other subsystems checking MNT_NOEXEC.
>
> Wouldn't it be equal to remounting all filesystems without noexec from
> attacker POV? It's hardly a fence to make additional mprotect(PROT_EXEC)
> call, before starting executing code from such filesystems.
>
> If administrator of the system wants this, he can just mount filesystem
> without noexec, no new kernel code required. And it's more fine-grained
> than this.
>
> So, no, I don't think we should add knob like this. Unless I miss
> something.
>

I don't believe this patch is necessary anymore (though, thank you Robert
for testing and re-sending!).

The primary offenders wrt to needing to mmap/mprotect a file in /dev/shm
was the older nvidia
driver (binary only iirc) and the Chrome Native Client code.

The reason why half-exec is an "ok" (half) mitigation is because it blocks
simple gadgets and other paths for using loadable libraries or binaries
(via glibc) as it disallows mmap(PROT_EXEC) even though it allows
mprotect(PROT_EXEC).  This stops ld in its tracks since it does the obvious
thing and uses mmap(PROT_EXEC).

I think time has marched on and this patch is now something I can toss in
the dustbin of history. Both Chrome's Native Client and an older nvidia
driver relied on creating-then-unlinking a file in tmpfs, but there is now
a better facility!


> NAK.
>

Agreed - this is old and software that predicated it should be gone.. I
hope. :)


>
> > It is motivated by a common /dev/shm, /tmp usecase. There are few
> > facilities for creating a shared memory segment that can be remapped in
> > the same process address space with different permissions.
>
> What about using memfd_create(2) for such cases? You'll get a file
> descriptor from in-kernel tmpfs (shm_mnt) which is not exposed to
> userspace for remount as noexec.
>

This is a relatively old patch ( https://lwn.net/Articles/455256/ ) which
predated memfd_create().  memfd_create() is the right solution to this
problem!


Thanks again!
will

[-- Attachment #2: Type: text/html, Size: 3739 bytes --]

  reply	other threads:[~2016-08-29 15:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 16:30 robert.foss
2016-08-26 17:17 ` kbuild test robot
2016-08-26 21:32 ` Kirill A. Shutemov
2016-08-29 15:25   ` Will Drewry [this message]
2016-08-29 15:31     ` Robert Foss

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='CAAFS_9HiuMt=Xy=YXmvw0+kqcXw=8qXTx2-2bXaqPc_rjtRZgw@mail.gmail.com' \
    --to=wad@chromium.org \
    --cc=aarcange@redhat.com \
    --cc=acme@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.com \
    --cc=atomlin@redhat.com \
    --cc=benzh@chromium.org \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dcashman@google.com \
    --cc=dyoung@redhat.com \
    --cc=filbranden@chromium.org \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=idryomov@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=kirill@shutemov.name \
    --cc=koct9i@gmail.com \
    --cc=krasin@google.com \
    --cc=kuleshovmail@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mcgrathr@chromium.org \
    --cc=mgorman@techsingularity.net \
    --cc=mguzik@redhat.com \
    --cc=mhocko@suse.com \
    --cc=minchan@kernel.org \
    --cc=mingo@kernel.org \
    --cc=msb@chromium.org \
    --cc=oleg@redhat.com \
    --cc=robert.foss@collabora.com \
    --cc=vbabka@suse.cz \
    --cc=vdavydov@virtuozzo.com \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vitalywool@gmail.com \
    --cc=vkuznets@redhat.com \
    --cc=w@1wt.eu \
    --cc=yang.shi@linaro.org \
    /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