linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Robert Foss <robert.foss@collabora.com>
To: Will Drewry <wad@chromium.org>,
	"Kirill A. Shutemov" <kirill@shutemov.name>
Cc: 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 11:31:50 -0400	[thread overview]
Message-ID: <160c3fc3-6d75-18d3-8575-98bb41e0543a@collabora.com> (raw)
In-Reply-To: <CAAFS_9HiuMt=Xy=YXmvw0+kqcXw=8qXTx2-2bXaqPc_rjtRZgw@mail.gmail.com>



On 2016-08-29 11:25 AM, Will Drewry wrote:
>
>
> On Fri, Aug 26, 2016 at 4:32 PM, Kirill A. Shutemov
> <kirill@shutemov.name <mailto:kirill@shutemov.name>> wrote:
>
>     On Fri, Aug 26, 2016 at 12:30:04PM -0400, robert.foss@collabora.com
>     <mailto:robert.foss@collabora.com> wrote:
>     > From: Will Drewry <wad@chromium.org <mailto: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. :)

Splendid, patch dropped!
Thanks Will and Kirill!


Rob.

>
>
>
>     > 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/
> <https://lwn.net/Articles/455256/> ) which predated memfd_create().
>  memfd_create() is the right solution to this problem!
>
>
> Thanks again!
> will

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

      reply	other threads:[~2016-08-29 15:31 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
2016-08-29 15:31     ` Robert Foss [this message]

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=160c3fc3-6d75-18d3-8575-98bb41e0543a@collabora.com \
    --to=robert.foss@collabora.com \
    --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=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=wad@chromium.org \
    --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