From: olekstysh@gmail.com (Oleksandr Tyshchenko)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1 2/2] iommu/io-pgtable-arm-v7s: Check for leaf entry before dereferencing it
Date: Mon, 27 Feb 2017 14:30:26 +0200 [thread overview]
Message-ID: <1488198626-1884-3-git-send-email-olekstysh@gmail.com> (raw)
In-Reply-To: <1488198626-1884-1-git-send-email-olekstysh@gmail.com>
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Do a check for already installed leaf entry at the current level before
dereferencing it in order to avoid walking the page table down with
wrong pointer to the next level.
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
CC: Will Deacon <will.deacon@arm.com>
CC: Robin Murphy <robin.murphy@arm.com>
---
drivers/iommu/io-pgtable-arm-v7s.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iommu/io-pgtable-arm-v7s.c b/drivers/iommu/io-pgtable-arm-v7s.c
index 1c049e2..8d6ca28 100644
--- a/drivers/iommu/io-pgtable-arm-v7s.c
+++ b/drivers/iommu/io-pgtable-arm-v7s.c
@@ -422,8 +422,12 @@ static int __arm_v7s_map(struct arm_v7s_io_pgtable *data, unsigned long iova,
pte |= ARM_V7S_ATTR_NS_TABLE;
__arm_v7s_set_pte(ptep, pte, 1, cfg);
- } else {
+ } else if (ARM_V7S_PTE_IS_TABLE(pte, lvl)) {
cptep = iopte_deref(pte, lvl);
+ } else {
+ /* We require an unmap first */
+ WARN_ON(!selftest_running);
+ return -EEXIST;
}
/* Rinse, repeat */
--
2.7.4
next prev parent reply other threads:[~2017-02-27 12:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-27 12:30 [PATCH v1 0/2] Misc fixes for ARM page table allocator (long/short descriptor format) Oleksandr Tyshchenko
2017-02-27 12:30 ` [PATCH v1 1/2] iommu/io-pgtable-arm: Check for leaf entry before dereferencing it Oleksandr Tyshchenko
2017-02-27 12:30 ` Oleksandr Tyshchenko [this message]
2017-03-16 9:19 ` [PATCH v1 0/2] Misc fixes for ARM page table allocator (long/short descriptor format) Oleksandr Tyshchenko
2017-03-16 11:19 ` Robin Murphy
2017-03-16 11:22 ` Oleksandr Tyshchenko
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=1488198626-1884-3-git-send-email-olekstysh@gmail.com \
--to=olekstysh@gmail.com \
--cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).