Skip to contentSkip to conversation

Fix issues with vmalloc flush flag

PATCH Superseded Rick Edgecombe 2 participants 6 messages May 21, 2019 – May 27, 2019

Subsystems (4)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Fix issues with vmalloc flush flag

These two patches address issues with the recently added VM_FLUSH_RESET_PERMS vmalloc flag.

Patch 1 is the most critical and addresses an issue that could cause a crash on x86.

Patch 2 addresses an issue where in a rare case strange arguments could be provided to flush_tlb_kernel_range(). Most arch's should be fine with it, but some may not like them, so we should avoid doing this.

v3->v4:
- Drop patch that switched vm_unmap_alias() calls to regular flush
- Add patch to address correctness previously fixed in dropped patch

v2->v3:
- Split into two patches

v1->v2:
- Update commit message with more detail
- Fix flush end range on !CONFIG_ARCH_HAS_SET_DIRECT_MAP case

Rick Edgecombe (2):
vmalloc: Fix calculation of direct map addr range
vmalloc: Avoid rare case of flushing tlb with weird arguements

 mm/vmalloc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Signature · 1 line
2.20.1
#1 lore raw

PATCH v4 1/2 vmalloc: Fix calculation of direct map addr range

The calculation of the direct map address range to flush was wrong. This could cause problems on x86 if a RO direct map alias ever got loaded into the TLB. This shouldn't normally happen, but it could cause the permissions to remain RO on the direct map alias, and then the page would return from the page allocator to some other component as RO and cause a crash.

So fix fix the address range calculation so the flush will include the direct map range.

Fixes 868b104d7379 ("mm/vmalloc: Add flag for freeing of special permsissions")
Cc Meelis Roos <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Nadav Amit <[email protected]>
---
 mm/vmalloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/vmalloc.c +3 -2
index c42872ed82ac..836888ae01f6 100644
@@ -2159,9 +2159,10 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 	 * the vm_unmap_aliases() flush includes the direct map.
 	 */
 	for (i = 0; i < area->nr_pages; i++) {
-		if (page_address(area->pages[i])) {
+		addr = (unsigned long)page_address(area->pages[i]);
+		if (addr) {
 			start = min(addr, start);
-			end = max(addr, end);
+			end = max(addr + PAGE_SIZE, end);
 		}
 	}
 
Signature · 1 line
2.20.1
#2 lore raw

Re: [PATCH v4 1/2] vmalloc: Fix calculation of direct map addr range

Quoted 31 lines · Rick Edgecombe

The calculation of the direct map address range to flush was wrong. This could cause problems on x86 if a RO direct map alias ever got loaded into the TLB. This shouldn't normally happen, but it could cause the permissions to remain RO on the direct map alias, and then the page would return from the page allocator to some other component as RO and cause a crash.

So fix fix the address range calculation so the flush will include the direct map range.

Fixes 868b104d7379 ("mm/vmalloc: Add flag for freeing of special permsissions")
Cc Meelis Roos <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Nadav Amit <[email protected]>
---
 mm/vmalloc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
mm/vmalloc.c +0 -0
index c42872ed82ac..836888ae01f6 100644
@@ -2159,9 +2159,10 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 	 * the vm_unmap_aliases() flush includes the direct map.
 	 */

mm/vmalloc.c static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages) · line 2168

Quoted 10 lines
mm/vmalloc.c +3 -2
 	for (i = 0; i < area->nr_pages; i++) {
-		if (page_address(area->pages[i])) {
+		addr = (unsigned long)page_address(area->pages[i]);
+		if (addr) {
 			start = min(addr, start);
-			end = max(addr, end);
+			end = max(addr + PAGE_SIZE, end);
 		}
 	}
 

Indeed; howevr I'm thinking this bug was caused to exist by the dual use of @addr in this function, so should we not, perhaps, do something like the below instead?

Also; having looked at this, it makes me question the use of flush_tlb_kernel_range() in _vm_unmap_aliases() and __purge_vmap_area_lazy(), it's potentially combining multiple ranges, which never really works well.

Arguably, we should just do flush_tlb_all() here, but that's for another patch I'm thinking.

---

mm/vmalloc.c +5 -5
@@ -2123,7 +2123,6 @@ static inline void set_area_direct_map(c
 /* Handle removing and resetting vm mappings related to the vm_struct. */
 static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 {
-	unsigned long addr = (unsigned long)area->addr;
 	unsigned long start = ULONG_MAX, end = 0;
 	int flush_reset = area->flags & VM_FLUSH_RESET_PERMS;
 	int i;
@@ -2135,8 +2134,8 @@ static void vm_remove_mappings(struct vm
 	 * execute permissions, without leaving a RW+X window.
 	 */
 	if (flush_reset && !IS_ENABLED(CONFIG_ARCH_HAS_SET_DIRECT_MAP)) {
-		set_memory_nx(addr, area->nr_pages);
-		set_memory_rw(addr, area->nr_pages);
+		set_memory_nx((unsigned long)area->addr, area->nr_pages);
+		set_memory_rw((unsigned long)area->addr, area->nr_pages);
 	}
 
 	remove_vm_area(area->addr);
@@ -2160,9 +2159,10 @@ static void vm_remove_mappings(struct vm
 	 * the vm_unmap_aliases() flush includes the direct map.
 	 */
 	for (i = 0; i < area->nr_pages; i++) {
-		if (page_address(area->pages[i])) {
+		unsigned long addr = (unsigned long)page_address(area->pages[i]);
+		if (addr) {
 			start = min(addr, start);
-			end = max(addr, end);
+			end = max(addr + PAGE_SIZE, end);
 		}
 	}
 
#3 lore raw

Re: [PATCH v4 1/2] vmalloc: Fix calculation of direct map addr range

T24gTW9uLCAyMDE5LTA1LTI3IGF0IDE0OjIwICswMjAwLCBQZXRlciBaaWpsc3RyYSB3cm90ZToN Cj4gT24gVHVlLCBNYXkgMjEsIDIwMTkgYXQgMDE6NTE6MzZQTSAtMDcwMCwgUmljayBFZGdlY29t YmUgd3JvdGU6DQo+ID4gVGhlIGNhbGN1bGF0aW9uIG9mIHRoZSBkaXJlY3QgbWFwIGFkZHJlc3Mg cmFuZ2UgdG8gZmx1c2ggd2FzIHdy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fbngoYWRkciwgYXJlYS0+bnJfcGFnZXMpOw0KPiAtCQlzZXRf bWVtb3J5X3J3KGFkZHIsIGFyZWEtPm5yX3BhZ2VzKTsNCj4gKwkJc2V0X21lbW9yeV9ueCgodW5z aWduZWQgbG9uZylhcmVhLT5hZGRyLCBhcmVhLQ0KPiA+bnJfcGFnZXMpOw0KPiArCQlzZXRfbWVt b3J5X3J3KCh1bnNpZ25lZCBsb25nKWFyZWEtPmFkZHIsIGFyZWEtDQo+ID5ucl9wYWdlcyk7DQo+ ICAJfQ0KPiAgDQo+ICAJcmVtb3ZlX3ZtX2FyZWEoYXJlYS0+YWRkcik7DQo+IEBAIC0yMTYwLDkg KzIxNTksMTAgQEAgc3RhdGljIHZvaWQgdm1fcmVtb3ZlX21hcHBpbmdzKHN0cnVjdCB2bQ0KPiAg CSAqIHRoZSB2bV91bm1hcF9hbGlhc2VzKCkgZmx1c2ggaW5jbHVkZXMgdGhlIGRpcmVjdCBtYXAu DQo+ICAJICovDQo+ICAJZm9yIChpID0gMDsgaSA8IGFyZWEtPm5yX3BhZ2VzOyBpKyspIHsNCj4g LQkJaWYgKHBhZ2VfYWRkcmVzcyhhcmVhLT5wYWdlc1tpXSkpIHsNCj4gKwkJdW5zaWduZWQgbG9u ZyBhZGRyID0gKHVuc2lnbmVkIGxvbmcpcGFnZV9hZGRyZXNzKGFyZWEtDQo+ID5wYWdlc1tpXSk7 DQo+ICsJCWlmIChhZGRyKSB7DQo+ICAJCQlzdGFydCA9IG1pbihhZGRyLCBzdGFydCk7DQo+IC0J CQllbmQgPSBtYXgoYWRkciwgZW5kKTsNCj4gKwkJCWVuZCA9IG1heChhZGRyICsgUEFHRV9TSVpF LCBlbmQpOw0KPiAgCQl9DQo+ICAJfQ0KPiAgDQo

#4 lore raw

PATCH v4 2/2 vmalloc: Avoid rare case of flushing tlb with weird arguements

In reply to Rick Edgecombe

In a rare case, flush_tlb_kernel_range() could be called with a start higher than the end. Most architectures should be fine with with this, but some may not like it, so avoid doing this.

In vm_remove_mappings(), in case page_address() returns 0 for all pages, _vm_unmap_aliases() will be called with start = ULONG_MAX, end = 0 and flush = 1.

If at the same time, the vmalloc purge operation is triggered by something else while the current operation is between remove_vm_area() and _vm_unmap_aliases(), then the vm mapping just removed will be already purged. In this case the call of vm_unmap_aliases() may not find any other mappings to flush and so end up flushing start = ULONG_MAX, end = 0. So only set flush = true if we find something in the direct mapping that we need to flush, and this way this can't happen.

Fixes 868b104d7379 ("mm/vmalloc: Add flag for freeing of special permsissions")
Cc Meelis Roos <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Nadav Amit <[email protected]>
---
 mm/vmalloc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/vmalloc.c +3 -1
index 836888ae01f6..537d1134b40e 100644
@@ -2125,6 +2125,7 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 	unsigned long addr = (unsigned long)area->addr;
 	unsigned long start = ULONG_MAX, end = 0;
 	int flush_reset = area->flags & VM_FLUSH_RESET_PERMS;
+	int flush_dmap = 0;
 	int i;
 
 	/*
@@ -2163,6 +2164,7 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 		if (addr) {
 			start = min(addr, start);
 			end = max(addr + PAGE_SIZE, end);
+			flush_dmap = 1;
 		}
 	}
 
@@ -2172,7 +2174,7 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 	 * reset the direct map permissions to the default.
 	 */
 	set_area_direct_map(area, set_direct_map_invalid_noflush);
-	_vm_unmap_aliases(start, end, 1);
+	_vm_unmap_aliases(start, end, flush_dmap);
 	set_area_direct_map(area, set_direct_map_default_noflush);
 }
 
Signature · 1 line
2.20.1
#5 lore raw

Re: [PATCH v4 2/2] vmalloc: Avoid rare case of flushing tlb with weird arguements

Quoted 51 lines · Rick Edgecombe

In a rare case, flush_tlb_kernel_range() could be called with a start higher than the end. Most architectures should be fine with with this, but some may not like it, so avoid doing this.

In vm_remove_mappings(), in case page_address() returns 0 for all pages, _vm_unmap_aliases() will be called with start = ULONG_MAX, end = 0 and flush = 1.

If at the same time, the vmalloc purge operation is triggered by something else while the current operation is between remove_vm_area() and _vm_unmap_aliases(), then the vm mapping just removed will be already purged. In this case the call of vm_unmap_aliases() may not find any other mappings to flush and so end up flushing start = ULONG_MAX, end = 0. So only set flush = true if we find something in the direct mapping that we need to flush, and this way this can't happen.

Fixes 868b104d7379 ("mm/vmalloc: Add flag for freeing of special permsissions")
Cc Meelis Roos <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc Dave Hansen <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Andy Lutomirski <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Nadav Amit <[email protected]>
---
 mm/vmalloc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
mm/vmalloc.c +2 -0
index 836888ae01f6..537d1134b40e 100644
@@ -2125,6 +2125,7 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 	unsigned long addr = (unsigned long)area->addr;
 	unsigned long start = ULONG_MAX, end = 0;
 	int flush_reset = area->flags & VM_FLUSH_RESET_PERMS;
+	int flush_dmap = 0;
 	int i;
 
 	/*
@@ -2163,6 +2164,7 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 		if (addr) {
 			start = min(addr, start);
 			end = max(addr + PAGE_SIZE, end);
+			flush_dmap = 1;
 		}
 	}
 

mm/vmalloc.c static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages) · line 2179

Quoted 7 lines
mm/vmalloc.c +1 -1
@@ -2172,7 +2174,7 @@ static void vm_remove_mappings(struct vm_struct *area, int deallocate_pages)
 	 * reset the direct map permissions to the default.
 	 */
 	set_area_direct_map(area, set_direct_map_invalid_noflush);
-	_vm_unmap_aliases(start, end, 1);
+	_vm_unmap_aliases(start, end, flush_dmap);
 	set_area_direct_map(area, set_direct_map_default_noflush);
 }

Hurmph.. another clue that this range flushing is crap I feel. The phys addrs of the page array can be scattered all over the place, a range doesn't properly represent things.

But yes, this seems like a minimal fix in spirit with the existing code.