linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Kees Cook <keescook@chromium.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Laura Abbott <labbott@redhat.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Allison Randal <allison@lohutok.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Stephen Boyd <swboyd@chromium.org>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Semmle Security Reports <security-reports@semmle.com>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 1/2] dma-mapping: Add vmap checks to dma_map_single()
Date: Wed, 30 Oct 2019 20:26:40 +0100	[thread overview]
Message-ID: <20191030192640.GC709410@kroah.com> (raw)
In-Reply-To: <20191030180921.GB19366@lst.de>

On Wed, Oct 30, 2019 at 07:09:21PM +0100, Christoph Hellwig wrote:
> On Wed, Oct 30, 2019 at 10:18:49AM +0100, Greg Kroah-Hartman wrote:
> > On Tue, Oct 29, 2019 at 02:34:22PM -0700, Kees Cook wrote:
> > > As we've seen from USB and other areas[1], we need to always do runtime
> > > checks for DMA operating on memory regions that might be remapped. This
> > > adds vmap checks (similar to those already in USB but missing in other
> > > places) into dma_map_single() so all callers benefit from the checking.
> > > 
> > > [1] https://git.kernel.org/linus/3840c5b78803b2b6cc1ff820100a74a092c40cbb
> > > 
> > > Suggested-by: Laura Abbott <labbott@redhat.com>
> > > Signed-off-by: Kees Cook <keescook@chromium.org>
> > > ---
> > >  include/linux/dma-mapping.h | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> > > index 4a1c4fca475a..54de3c496407 100644
> > > --- a/include/linux/dma-mapping.h
> > > +++ b/include/linux/dma-mapping.h
> > > @@ -583,6 +583,12 @@ static inline unsigned long dma_get_merge_boundary(struct device *dev)
> > >  static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
> > >  		size_t size, enum dma_data_direction dir, unsigned long attrs)
> > >  {
> > > +	/* DMA must never operate on areas that might be remapped. */
> > > +	if (dev_WARN_ONCE(dev, is_vmalloc_addr(ptr),
> > > +			  "wanted %zu bytes mapped in vmalloc\n", size)) {
> > > +		return DMA_MAPPING_ERROR;
> > > +	}
> > 
> > That's a very odd error string, I know if I saw it for the first time, I
> > would have no idea what it meant.  The USB message at least gives you a
> > bit more context as to what went wrong and how to fix it.
> > 
> > How about something like "Memory is not DMA capabable, please fix the
> > allocation of it to be correct", or "non-dma-able memory was attempted
> > to be mapped, but this is impossible to to" or something else.
> 
> I've fixed the message to "rejecting DMA map of vmalloc memory" and
> applied the patch.

Looks good!  You can apply patch 2/2 as well if you want to take that
through your tree too.

thanks,

greg k-h

  parent reply	other threads:[~2019-10-30 19:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-29 21:34 [PATCH v4 0/2] dma-mapping: Add vmap checks to dma_map_single() Kees Cook
2019-10-29 21:34 ` [PATCH v4 1/2] " Kees Cook
2019-10-30  9:18   ` Greg Kroah-Hartman
2019-10-30 18:09     ` Christoph Hellwig
2019-10-30 18:26       ` Kees Cook
2019-10-30 19:26       ` Greg Kroah-Hartman [this message]
2019-10-30 19:45         ` Christoph Hellwig
2019-10-31  6:51           ` Greg Kroah-Hartman
2019-10-29 21:34 ` [PATCH v4 2/2] usb: core: Remove redundant vmap checks Kees Cook
2019-10-31  6:50   ` Greg Kroah-Hartman
2019-10-31 17:13   ` Christoph Hellwig

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=20191030192640.GC709410@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=allison@lohutok.net \
    --cc=brouer@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=robin.murphy@arm.com \
    --cc=security-reports@semmle.com \
    --cc=swboyd@chromium.org \
    --cc=tglx@linutronix.de \
    /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).