From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Christoph Hellwig <hch@infradead.org>
Cc: baolu.lu@linux.intel.com, David Woodhouse <dwmw2@infradead.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>
Subject: Re: lack of permission checking with intel-iommu?
Date: Wed, 3 Jul 2024 10:28:42 +0800 [thread overview]
Message-ID: <2107dc15-c669-44b9-b967-b75fc6c977e8@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB52761AAFB5C2E2A42E24B9B38CDD2@BN9PR11MB5276.namprd11.prod.outlook.com>
On 7/3/24 8:56 AM, Tian, Kevin wrote:
>> From: Baolu Lu <baolu.lu@linux.intel.com>
>> Sent: Tuesday, July 2, 2024 5:13 PM
>>
>> On 2024/7/2 16:25, Christoph Hellwig wrote:
>>> On Tue, Jul 02, 2024 at 04:22:25PM +0800, Baolu Lu wrote:
>>>> Is it about IOMMU blocking "device reading from buffer" or "device
>>>> writing to buffer"?
>>>>
>>>> The intel iommu driver might use first-stage translation for kernel DMA.
>>>> It seems not to block the "device reading from buffer" if I remember it
>>>> correctly.
>>> This is about device reading from buffer it is only supposed to write
>>> to (but doesn't).
>>
>> In this case, Intel IOMMU doesn't block device reading as the first-
>> stage page table only grants two types of permissions: Read-only or
>> Read-write. Write-only permission is not available.
>>
>> Do you have a functional requirement for Write-only permission? If so,
>> we can choose the second-stage page table.
>>
>
> Note there could be configurations (e.g. vIOMMU) which only supports
> 1st-stage. So there is no guarantee that write-only permission can be
> always enforced on Intel.
>
> btw according to current code looks write-only even doesn't work on
> 2nd-stage:
>
> __domain_mapping()
> {
> ...
> attr = prot & (DMA_PTE_READ | DMA_PTE_WRITE | DMA_PTE_SNP);
> attr |= DMA_FL_PTE_PRESENT;
> if (domain->use_first_level) {
> ...
> }
> ...
> }
>
> DMA_FL_PTE_PRESENT and DMA_PTE_READ are both bit-0, so
> READ is always set in 2nd-stage. That line should be done only
> for domain->use_first_level==true
This is intended to make the permission consistent between first and
second stage.
Thanks,
baolu
next prev parent reply other threads:[~2024-07-03 2:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 7:46 lack of permission checking with intel-iommu? Christoph Hellwig
2024-07-02 8:02 ` Christoph Hellwig
2024-07-02 8:22 ` Baolu Lu
2024-07-02 8:25 ` Christoph Hellwig
2024-07-02 9:12 ` Baolu Lu
2024-07-02 11:42 ` Christoph Hellwig
2024-07-03 0:56 ` Tian, Kevin
2024-07-03 2:28 ` Baolu Lu [this message]
2024-07-02 8:47 ` Yi Liu
2024-07-02 9:07 ` Baolu Lu
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=2107dc15-c669-44b9-b967-b75fc6c977e8@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=dwmw2@infradead.org \
--cc=hch@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=kevin.tian@intel.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).