All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Walter Wu <walter-zh.wu@mediatek.com>
Cc: wsd_upstream <wsd_upstream@mediatek.com>,
	linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	linux-mediatek@lists.infradead.org,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Christoph Hellwig <hch@lst.de>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Tue, 2 Nov 2021 07:41:55 +0100	[thread overview]
Message-ID: <20211102064155.GA27749@lst.de> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>

As others pointed out, DMA_ATTR_NO_KERNEL_MAPPING just means the
caller can't rely on a kernel mapping.  So the "fix" here is
wrong.  That being said for cases where we can easily remove a page
from the kernel mapping it would be nice to do to:

 a) improve security
 b) as a debug check to see that no one actually tries to access it

> +		/* remove kernel mapping for pages */
> +		set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)),

Please avoid overly long lines.  Also this function only exists for arm64
also and others pointed out won't work for all cases.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Walter Wu <walter-zh.wu@mediatek.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	wsd_upstream <wsd_upstream@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Tue, 2 Nov 2021 07:41:55 +0100	[thread overview]
Message-ID: <20211102064155.GA27749@lst.de> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>

As others pointed out, DMA_ATTR_NO_KERNEL_MAPPING just means the
caller can't rely on a kernel mapping.  So the "fix" here is
wrong.  That being said for cases where we can easily remove a page
from the kernel mapping it would be nice to do to:

 a) improve security
 b) as a debug check to see that no one actually tries to access it

> +		/* remove kernel mapping for pages */
> +		set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)),

Please avoid overly long lines.  Also this function only exists for arm64
also and others pointed out won't work for all cases.

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Walter Wu <walter-zh.wu@mediatek.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	wsd_upstream <wsd_upstream@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Tue, 2 Nov 2021 07:41:55 +0100	[thread overview]
Message-ID: <20211102064155.GA27749@lst.de> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>

As others pointed out, DMA_ATTR_NO_KERNEL_MAPPING just means the
caller can't rely on a kernel mapping.  So the "fix" here is
wrong.  That being said for cases where we can easily remove a page
from the kernel mapping it would be nice to do to:

 a) improve security
 b) as a debug check to see that no one actually tries to access it

> +		/* remove kernel mapping for pages */
> +		set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)),

Please avoid overly long lines.  Also this function only exists for arm64
also and others pointed out won't work for all cases.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Walter Wu <walter-zh.wu@mediatek.com>
Cc: Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	wsd_upstream <wsd_upstream@mediatek.com>,
	linux-mediatek@lists.infradead.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING
Date: Tue, 2 Nov 2021 07:41:55 +0100	[thread overview]
Message-ID: <20211102064155.GA27749@lst.de> (raw)
In-Reply-To: <20211101031558.7184-1-walter-zh.wu@mediatek.com>

As others pointed out, DMA_ATTR_NO_KERNEL_MAPPING just means the
caller can't rely on a kernel mapping.  So the "fix" here is
wrong.  That being said for cases where we can easily remove a page
from the kernel mapping it would be nice to do to:

 a) improve security
 b) as a debug check to see that no one actually tries to access it

> +		/* remove kernel mapping for pages */
> +		set_memory_valid((unsigned long)phys_to_virt(dma_to_phys(dev, *dma_handle)),

Please avoid overly long lines.  Also this function only exists for arm64
also and others pointed out won't work for all cases.

  parent reply	other threads:[~2021-11-02  6:42 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01  3:15 [PATCH] dma-direct: fix DMA_ATTR_NO_KERNEL_MAPPING Walter Wu
2021-11-01  3:15 ` Walter Wu
2021-11-01  3:15 ` Walter Wu
2021-11-01  3:15 ` Walter Wu
2021-11-01  6:10 ` kernel test robot
2021-11-01  6:10   ` kernel test robot
2021-11-01  6:10   ` kernel test robot
2021-11-01  6:10   ` kernel test robot
2021-11-01  6:10   ` kernel test robot
2021-11-01  8:34 ` Ard Biesheuvel
2021-11-01  8:34   ` Ard Biesheuvel
2021-11-01  8:34   ` Ard Biesheuvel
2021-11-01  8:34   ` Ard Biesheuvel
2021-11-01 12:20   ` Walter Wu
2021-11-01 12:20     ` Walter Wu
2021-11-01 12:20     ` Walter Wu
2021-11-01 12:20     ` Walter Wu
2021-11-01 14:17     ` Ard Biesheuvel
2021-11-01 14:17       ` Ard Biesheuvel
2021-11-01 14:17       ` Ard Biesheuvel
2021-11-01 14:17       ` Ard Biesheuvel
2021-11-02  3:21       ` Walter Wu
2021-11-02  3:21         ` Walter Wu
2021-11-02  3:21         ` Walter Wu
2021-11-02  3:21         ` Walter Wu
2021-11-02  6:43         ` Christoph Hellwig
2021-11-02  6:43           ` Christoph Hellwig
2021-11-02  6:43           ` Christoph Hellwig
2021-11-02  6:43           ` Christoph Hellwig
2021-11-01 10:29 ` Robin Murphy
2021-11-01 10:29   ` Robin Murphy
2021-11-01 10:29   ` Robin Murphy
2021-11-01 10:29   ` Robin Murphy
2021-11-01 12:07   ` Walter Wu
2021-11-01 12:07     ` Walter Wu
2021-11-01 12:07     ` Walter Wu
2021-11-01 12:07     ` Walter Wu
2021-11-02  6:41 ` Christoph Hellwig [this message]
2021-11-02  6:41   ` Christoph Hellwig
2021-11-02  6:41   ` Christoph Hellwig
2021-11-02  6:41   ` Christoph Hellwig
2021-11-02  7:08   ` Walter Wu
2021-11-02  7:08     ` Walter Wu
2021-11-02  7:08     ` Walter Wu
2021-11-02  7:08     ` Walter Wu
2021-11-02  7:26   ` Walter Wu
2021-11-02  7:26     ` Walter Wu
2021-11-02  7:26     ` Walter Wu
2021-11-02  7:26     ` Walter Wu

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=20211102064155.GA27749@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robin.murphy@arm.com \
    --cc=walter-zh.wu@mediatek.com \
    --cc=wsd_upstream@mediatek.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 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.