netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Ruhl, Michael J" <michael.j.ruhl@intel.com>,
	Leon Romanovsky <leon@kernel.org>,
	Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Feras Daoud <ferasda@mellanox.com>,
	Haggai Eran <haggaie@mellanox.com>,
	Saeed Mahameed <saeedm@mellanox.com>,
	linux-netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH rdma-next 3/6] RDMA/ucontext: Do not allow BAR mappings to be executable
Date: Thu, 18 Apr 2019 02:23:26 -0500	[thread overview]
Message-ID: <CAGXu5jKE-o11YeYyLOL4arJA-O5_BKYdtrdfLthFsm2pfjGnGg@mail.gmail.com> (raw)
In-Reply-To: <20190418070128.GE3206@ziepe.ca>

On Thu, Apr 18, 2019 at 2:01 AM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> On Thu, Apr 18, 2019 at 01:30:07AM -0500, Kees Cook wrote:
>
> > Anything running with READ_IMPLIES_EXEC (i.e. a gnu stack marked WITH
> > execute) should be considered broken. Now, the trouble is that this
> > personality flag is carried across execve(), so if you have a launcher
> > that doesn't fix up the personality for children, you'll see this
> > spread all over your process tree. What is doing rdma mmap calls with
> > an executable stack? That really feels to me like the real source of
> > the problem.
>
> Apparently the Fortran runtime forces the READ_IMPLIES_EXEC and
> requires it for some real reason or another - Fortran and RDMA go
> together in alot of cases.

That's pretty unfortunate for the security of the resulting proceses. :(

> > Is the file for the driver coming out of /dev? Seems like that should
> > be mounted noexec and it would solve this too. (Though now I wonder
> > why /dev isn't noexec by default? /dev/pts is noexec...
>
> Yes - maybe?

I've found why /dev isn't noexec: to support old tools that mapped
/dev/zero with VM_EXEC to get executable mappings (instead of using
MAP_ANON). Seems like maybe this could change now?

> > Regardless, if you wanted to add a "ignore READ_IMPLIES_EXEC" flag to
> > struct file, maybe this bit could be populated by drivers?
>
> This would solve our problem.. How about a flag in struct
> file_operations?

Oh! That seems like it'd be pretty clean, I think. There's no flags
field currently, which vaguely surprises me...

I wonder if we could simply make devtmpfs ignore READ_IMPLIES_EXEC
entirely, though? And I wonder if we could defang READ_IMPLIES_EXEC a
bit in general. It was _supposed_ to be for the cases where binaries
were missing exec bits and a processor was just gaining NX ability. I
know this has been discussed before... ah-ha, here it is:
http://lkml.kernel.org/r/1462963502-11636-1-git-send-email-hecmargi@upv.es

> Do you agree it is worth drivers banning VM_EXEC for these truely
> non-executable pages?

I do: I think it's reasonable defense-in-depth.

--
Kees Cook

  reply	other threads:[~2019-04-18  7:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-16 11:07 [PATCH rdma-next 0/6] BAR mappings fixes in RDMA Leon Romanovsky
2019-04-16 11:07 ` [PATCH rdma-next 1/6] RDMA/mlx5: Do not allow the user to write to the clock page Leon Romanovsky
2019-04-16 11:07 ` [PATCH rdma-next 2/6] RDMA/mlx5: Use rdma_user_map_io for mapping BAR pages Leon Romanovsky
2019-04-16 11:07 ` [PATCH rdma-next 3/6] RDMA/ucontext: Do not allow BAR mappings to be executable Leon Romanovsky
2019-04-17 19:05   ` Ruhl, Michael J
2019-04-18  5:58     ` Jason Gunthorpe
2019-04-18  6:30       ` Kees Cook
2019-04-18  7:01         ` Jason Gunthorpe
2019-04-18  7:23           ` Kees Cook [this message]
2019-04-22 12:51             ` Jason Gunthorpe
2019-04-16 11:07 ` [PATCH rdma-next 4/6] RDMA/ucontext: Fix regression with disassociate Leon Romanovsky
2019-04-16 11:07 ` [PATCH mlx5-next 5/6] RDMA/mlx5: Use get_zeroed_page() for clock_info Leon Romanovsky
2019-04-16 11:07 ` [PATCH rdma-next 6/6] RDMA: Remove rdma_user_mmap_page Leon Romanovsky
2019-04-24 19:24 ` [PATCH rdma-next 0/6] BAR mappings fixes in RDMA Jason Gunthorpe

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=CAGXu5jKE-o11YeYyLOL4arJA-O5_BKYdtrdfLthFsm2pfjGnGg@mail.gmail.com \
    --to=keescook@chromium.org \
    --cc=aarcange@redhat.com \
    --cc=dledford@redhat.com \
    --cc=ferasda@mellanox.com \
    --cc=haggaie@mellanox.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=michael.j.ruhl@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.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;
as well as URLs for NNTP newsgroup(s).