iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Kees Cook <keescook@chromium.org>
Cc: Semmle Security Reports <security-reports@semmle.com>,
	linux-kernel@vger.kernel.org, Stephen Boyd <swboyd@chromium.org>,
	iommu@lists.linux-foundation.org,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Jesper Dangaard Brouer <brouer@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Laura Abbott <labbott@redhat.com>, Christoph Hellwig <hch@lst.de>,
	Allison Randal <allison@lohutok.net>
Subject: Re: [PATCH v3 1/2] dma-mapping: Add vmap checks to dma_map_single()
Date: Fri, 11 Oct 2019 10:33:17 +0100	[thread overview]
Message-ID: <4f559fe1-a867-c3ca-eed2-1962d01d5346@arm.com> (raw)
In-Reply-To: <20191011050208.GA978459@kroah.com>

On 2019-10-11 6:02 am, Greg Kroah-Hartman wrote:
> On Thu, Oct 10, 2019 at 03:28:28PM -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..ff4e91c66f44 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 (unlikely(is_vmalloc_addr(ptr))) {
>> +		dev_warn_once(dev, "bad map: %zu bytes in vmalloc\n", size);
> 
> Can we get a bit better error text here?  In USB we were at least giving
> people a hint as to what went wrong, "bad map" might not really make
> that much sense to a USB developer as to what they needed to do to fix
> this issue.

Agreed, something along the lines of "dma_map_single of vmalloc'ed 
buffer..." might be clearer. Also I'd be inclined to use dev_WARN_ONCE() 
to include a diagnostically-useful backtrace, as the existing USB code 
would.

Thanks,
Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2019-10-11  9:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-10 22:28 [PATCH v3 0/2] dma-mapping: Add vmap checks to dma_map_single() Kees Cook
2019-10-10 22:28 ` [PATCH v3 1/2] " Kees Cook
2019-10-11  5:02   ` Greg Kroah-Hartman
2019-10-11  9:33     ` Robin Murphy [this message]
2019-10-10 22:28 ` [PATCH v3 2/2] usb: core: Remove redundant vmap checks Kees Cook

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=4f559fe1-a867-c3ca-eed2-1962d01d5346@arm.com \
    --to=robin.murphy@arm.com \
    --cc=allison@lohutok.net \
    --cc=brouer@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=gregkh@linuxfoundation.org \
    --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=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).