Skip to contentSkip to conversation

Misc fixes for ARM page table allocator (long/short descriptor format)

PATCH New Oleksandr Tyshchenko 2 participants 6 messages Feb 27, 2017 – Mar 16, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Misc fixes for ARM page table allocator (long/short descriptor format)

Hi.

There is a small patch series which contains the same fix for both descriptor formats based on the preceding RFC patches:
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020411.html
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020477.html

Oleksandr Tyshchenko (2):
iommu/io-pgtable-arm: Check for leaf entry before dereferencing it iommu/io-pgtable-arm-v7s: Check for leaf entry before dereferencing it

 drivers/iommu/io-pgtable-arm-v7s.c | 6 +++++-
 drivers/iommu/io-pgtable-arm.c     | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 iommu/io-pgtable-arm: Check for leaf entry before dereferencing it

From: Oleksandr Tyshchenko <[email protected]>

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.

---
 drivers/iommu/io-pgtable-arm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/io-pgtable-arm.c +5 -1
index feacc54..f9bc6eb 100644
@@ -335,8 +335,12 @@ static int __arm_lpae_map(struct arm_lpae_io_pgtable *data, unsigned long iova,
 		if (cfg->quirks & IO_PGTABLE_QUIRK_ARM_NS)
 			pte |= ARM_LPAE_PTE_NSTABLE;
 		__arm_lpae_set_pte(ptep, pte, cfg);
-	} else {
+	} else if (!iopte_leaf(pte, lvl)) {
 		cptep = iopte_deref(pte, data);
+	} else {
+		/* We require an unmap first */
+		WARN_ON(!selftest_running);
+		return -EEXIST;
 	}
 
 	/* Rinse, repeat */
Signature · 1 line
2.7.4
#2 lore raw

PATCH 2/2 iommu/io-pgtable-arm-v7s: Check for leaf entry before dereferencing it

In reply to Oleksandr Tyshchenko

From: Oleksandr Tyshchenko <[email protected]>

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.

---
 drivers/iommu/io-pgtable-arm-v7s.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/iommu/io-pgtable-arm-v7s.c +5 -1
index 1c049e2..8d6ca28 100644
@@ -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 */
Signature · 1 line
2.7.4
#3 lore raw

cover Misc fixes for ARM page table allocator (long/short descriptor format)

In reply to Oleksandr Tyshchenko

Hi, all.

Any comments?

Quoted 18 lines · Oleksandr Tyshchenko

Hi.

There is a small patch series which contains the same fix for both descriptor formats based on the preceding RFC patches:
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020411.html
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020477.html

Oleksandr Tyshchenko (2):
iommu/io-pgtable-arm: Check for leaf entry before dereferencing it iommu/io-pgtable-arm-v7s: Check for leaf entry before dereferencing it

 drivers/iommu/io-pgtable-arm-v7s.c | 6 +++++-
 drivers/iommu/io-pgtable-arm.c     | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

--
2.7.4

Signature · 3 lines
Regards,

Oleksandr Tyshchenko
reviewer
#4 lore raw

cover Misc fixes for ARM page table allocator (long/short descriptor format)

Quoted 3 lines · Oleksandr Tyshchenko

Hi, all.

Any comments?

Er, no, but in a good way ;)

Patches look fine to me, and I see Will's already queued them anyway.

Thanks for the respin, and apologies for losing it in my inbox!

Robin.

Quoted 24 lines
Quoted 18 lines · Oleksandr Tyshchenko

Hi.

There is a small patch series which contains the same fix for both descriptor formats based on the preceding RFC patches:
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020411.html
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020477.html

Oleksandr Tyshchenko (2):
iommu/io-pgtable-arm: Check for leaf entry before dereferencing it iommu/io-pgtable-arm-v7s: Check for leaf entry before dereferencing it

 drivers/iommu/io-pgtable-arm-v7s.c | 6 +++++-
 drivers/iommu/io-pgtable-arm.c     | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

--
2.7.4

#5 lore raw

cover Misc fixes for ARM page table allocator (long/short descriptor format)

Quoted 5 lines · Robin Murphy
Quoted 3 lines · Oleksandr Tyshchenko

Hi, all.

Any comments?

Quoted 7 lines

Er, no, but in a good way ;)

Patches look fine to me, and I see Will's already queued them anyway.

Thanks for the respin, and apologies for losing it in my inbox!

Robin.

Great, thank you.

Quoted 26 lines
Quoted 25 lines
Quoted 18 lines · Oleksandr Tyshchenko

Hi.

There is a small patch series which contains the same fix for both descriptor formats based on the preceding RFC patches:
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020411.html
https://lists.linuxfoundation.org/pipermail/iommu/2017-February/020477.html

Oleksandr Tyshchenko (2):
iommu/io-pgtable-arm: Check for leaf entry before dereferencing it iommu/io-pgtable-arm-v7s: Check for leaf entry before dereferencing it

 drivers/iommu/io-pgtable-arm-v7s.c | 6 +++++-
 drivers/iommu/io-pgtable-arm.c     | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

--
2.7.4

Signature · 3 lines
Regards,

Oleksandr Tyshchenko