From: Oleksandr Tyshchenko <olekstysh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: vlad.babchuk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
will.deacon-5wv7dgnIgG8@public.gmane.org,
andrii.anisov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
andr2000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
al1img-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
joculator-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
From: Oleksandr Tyshchenko <oleksandr_tyshchenko-uRwfk40T5oI@public.gmane.org>
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-uRwfk40T5oI@public.gmane.org>
CC: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
CC: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org>
---
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
[not found] ` <1488198626-1884-1-git-send-email-olekstysh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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
[not found] ` <CAPD2p-=3Q7KKct29kjSi0=_-R7e3L5sgC-N4zS=BDa1vGc8uuQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-16 11:19 ` Robin Murphy
[not found] ` <9c726317-6669-91d9-ff42-9ad47c144a3e-5wv7dgnIgG8@public.gmane.org>
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-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=al1img-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=andr2000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=andrii.anisov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=joculator-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=vlad.babchuk-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.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