All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniele Alessandrelli <daniele.alessandrelli@linux.intel.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "pavel@ucw.cz" <pavel@ucw.cz>,
	"robh@kernel.org" <robh@kernel.org>,
	"Murphy, Paul J" <paul.j.murphy@intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"Shevchenko, Andriy" <andriy.shevchenko@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] soc: keembay: Add Keem Bay IMR driver
Date: Thu, 28 May 2020 13:27:40 +0100	[thread overview]
Message-ID: <0d5fd14a0641b5ac2ed880da1b03458608116058.camel@linux.intel.com> (raw)
In-Reply-To: <CAK8P3a0OK+BRF2t=8V6Pa95b6Ldcfn3AP1VM+GSsruGRVH=MXQ@mail.gmail.com>

On Wed, 2020-05-27 at 20:59 +0200, Arnd Bergmann wrote:
> On Wed, May 27, 2020 at 7:43 PM Daniele Alessandrelli
> <daniele.alessandrelli@linux.intel.com> wrote:
> > On Wed, 2020-05-27 at 16:33 +0200, Arnd Bergmann wrote:
> > > On Wed, May 27, 2020 at 3:31 PM Alessandrelli, Daniele <
> > > daniele.alessandrelli@intel.com> wrote:
> > > 
> > > Adding it back later on with a loadable device driver should
> > > not be a problem, as this is not a violation of the boot
> > > protocol.
> > 
> > Cool, I'll try to do that then, thanks!
> > 
> > I see two ways to do that though:
> > 
> > 1. Create a device driver that gets a reference to the memory
> > region
> > from its DT node and then re-adds the memory to the pool of
> > available
> > memory.
> > 
> > 2. Use a special "compatible" string for my memory region and
> > create a
> > driver to handle it.
> 
> I think the first approach is more common.
> 
> > However, I think that in the second case the driver must be
> > builtin.
> > Would that be okay?
> 
> It's better to avoid that.
> 
> > Also, from a quick look, it seems that I can re-add that memory
> > back by
> > calling memblock_free() (or a similar memblock_* function). Am I on
> > the
> > right track?
> 
> I'm not sure if memblock_free() works after early memory
> initialization
> is complete, but I think there is some way to do it later. Maybe try
> memblock_free() first, and then look for something else if it doesn't
> work.
> 

Brilliant. I will create a new patch using the 1st approach and see if
memblock_free() works; if not, I will look for something else.

Thanks a lot for your valuable feedback and advice.

> > > It seems that just reserving the u-boot area and optionally
> > > freeing it later from a driver solves most of your problem.
> > > I have one related question though: if the kernel itself is
> > > protected, does that mean that any driver that does a DMA
> > > to statically allocated memory inside of the kernel is broken
> > > as well? I think this is something that a couple of USB drivers
> > > do, though it is fairly rare. Does u-boot protect both only
> > > the executable sections of the kernel or also data, and does
> > > the hardware block both read and write on the IMR, or just
> > > writes?
> > 
> > Yes, you're very right. Drivers that do DMA transfers to statically
> > allocated memory inside the kernel will be broken.
> > 
> > We are currently seeing this with our eMMC driver.
> > 
> > Current solution is to add the eMMC controller to the list of
> > allowed
> > "agents" for the IMR. This will reduce the level of protection, but
> > since we expect to have only a few of these exceptions (since, as
> > you
> > pointed out, drivers that do DMA to static kernel memory seem to be
> > quite rare), we think that there is still value in having the
> > Kernel
> > IMR.
> > 
> > Do you see any issue with this?
> 
> I think you should try to fix the driver rather than making an
> exception for it.

Yes, we'll look into that.

> Hot-pluggable drivers are a much more interesting
> case I think, because on the one hand you have no idea what
> users might want to plug in legitimately, but on the other hand
> those are also the most likely attack vectors (driver bugs for
> random USB drivers overwriting kernel memory when faced with
> malicious hardware) that this feature is trying to prevent.
> 
> I also wonder whether we should do something in the normal
> iommu code that prevents one from mapping a page that the
> kernel would consider as protected (kernel .text, freed memory,
> ...) into the iommu in the first place.

Sounds like an iteresting security feature; expecially because it would
apply to any hardware.

> 
>         Arnd




  reply	other threads:[~2020-05-28 12:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 16:36 [PATCH 0/1] Add IMR driver for Keem Bay Daniele Alessandrelli
2020-04-21 16:36 ` [PATCH 1/1] soc: keembay: Add Keem Bay IMR driver Daniele Alessandrelli
2020-05-01  8:10   ` Greg Kroah-Hartman
2020-05-01 11:50     ` Daniele Alessandrelli
2020-05-01 11:59       ` Greg Kroah-Hartman
2020-05-24 21:28       ` Pavel Machek
2020-05-25  8:18         ` Arnd Bergmann
2020-05-27 13:31           ` Alessandrelli, Daniele
2020-05-27 14:33             ` Arnd Bergmann
2020-05-27 17:43               ` Daniele Alessandrelli
2020-05-27 18:59                 ` Arnd Bergmann
2020-05-28 12:27                   ` Daniele Alessandrelli [this message]
2020-05-28 11:22             ` Pavel Machek
2020-05-28 13:00               ` Daniele Alessandrelli
2020-05-07 17:44   ` Pavel Machek
2020-04-30 19:49 ` [PATCH 0/1] Add IMR driver for Keem Bay Alessandrelli, Daniele
2020-04-30 19:49   ` Alessandrelli, Daniele
2020-05-01  7:09   ` gregkh
2020-05-01  7:09     ` gregkh
2020-05-01  7:53     ` Daniele Alessandrelli
2020-05-01  7:53       ` Daniele Alessandrelli
2020-05-01  8:04       ` gregkh
2020-05-01  8:04         ` gregkh

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=0d5fd14a0641b5ac2ed880da1b03458608116058.camel@linux.intel.com \
    --to=daniele.alessandrelli@linux.intel.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.j.murphy@intel.com \
    --cc=pavel@ucw.cz \
    --cc=robh@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.