From: Robin Murphy <robin.murphy@arm.com>
To: Joerg Roedel <joro@8bytes.org>,
XianLiang Huang <huangxianliang@lanxincomputing.com>
Cc: tjeznach@rivosinc.com, markus.elfring@web.de, will@kernel.org,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu, alex@ghiti.fr, iommu@lists.linux.dev,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iommu/riscv: prevent NULL deref in iova_to_phys
Date: Fri, 15 Aug 2025 15:43:25 +0100 [thread overview]
Message-ID: <e87aa091-5c02-4cd6-9636-0cb6c0015768@arm.com> (raw)
In-Reply-To: <aJ8FbvCJEOj2XjT-@8bytes.org>
On 15/08/2025 11:01 am, Joerg Roedel wrote:
> On Fri, Aug 15, 2025 at 03:12:44PM +0800, XianLiang Huang wrote:
>> diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
>> index 2d0d31ba2886..0eae2f4bdc5e 100644
>> --- a/drivers/iommu/riscv/iommu.c
>> +++ b/drivers/iommu/riscv/iommu.c
>> @@ -1283,7 +1283,7 @@ static phys_addr_t riscv_iommu_iova_to_phys(struct iommu_domain *iommu_domain,
>> unsigned long *ptr;
>>
>> ptr = riscv_iommu_pte_fetch(domain, iova, &pte_size);
>> - if (_io_pte_none(*ptr) || !_io_pte_present(*ptr))
>> + if (!ptr)
>> return 0;
>
> Zero is usually not an invalid physical address, or is it on RISC-V?
It's a valid PA on many systems of many architectures, but it's also
been the "not mapped/error" value for the iova_to_phys operation all the
way back to the very very first intel_iommu_iova_to_pfn() nearly 17
years ago, so hey :)
Thanks,
Robin.
next prev parent reply other threads:[~2025-08-15 14:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-15 7:12 XianLiang Huang
2025-08-15 9:03 ` Markus Elfring
2025-08-15 10:01 ` Joerg Roedel
2025-08-15 14:43 ` Robin Murphy [this message]
2025-08-18 16:04 ` Joerg Roedel
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=e87aa091-5c02-4cd6-9636-0cb6c0015768@arm.com \
--to=robin.murphy@arm.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=huangxianliang@lanxincomputing.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=markus.elfring@web.de \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=tjeznach@rivosinc.com \
--cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®