Skip to contentSkip to conversation

x86/mm: only allow memmap=XX!YY over existing RAM

RFC In review Yigal Korman 2 participants 3 messages Jun 19, 2016 – Jun 20, 2016 2 messages not in the archive

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

RFC 1/1 x86/mm: only allow memmap=XX!YY over existing RAM

Before this patch, passing a range that is beyond the physical memory range will succeed, the user will see a /dev/pmem0 and will be able to access it. Reads will always return 0 and writes will be silently ignored.

I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml failing that were eventually tracked down to be wrong values passed to memmap.

This patch prevents the above issue by instead of adding a new memory range, only update a RAM memory range with the PRAM type. This way, passing the wrong memmap will either not give you a pmem at all or give you a smaller one that actually has RAM behind it.

And if someone still needs to fake a pmem that doesn't have RAM behind it, they can simply do memmap=XX@YY,XX!YY.

---
 arch/x86/kernel/e820.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/e820.c +1 -1
index 569c1e4..bcd2ebb1 100644
@@ -877,7 +877,7 @@ static int __init parse_memmap_one(char *p)
 		e820_add_region(start_at, mem_size, E820_RESERVED);
 	} else if (*p == '!') {
 		start_at = memparse(p+1, &p);
-		e820_add_region(start_at, mem_size, E820_PRAM);
+		e820_update_range(start_at, mem_size, E820_RAM, E820_PRAM);
 	} else
 		e820_remove_range(mem_size, ULLONG_MAX - mem_size, E820_RAM, 1);
 
Signature · 1 line
1.9.3

A message that is not in the archive (sent off-list or not yet received): 1466340570-2471502-1-git-send-email-yigal-/[email protected]

#2 lore raw
Quoted 9 lines · Yigal Korman

Before this patch, passing a range that is beyond the physical memory range will succeed, the user will see a /dev/pmem0 and will be able to access it. Reads will always return 0 and writes will be silently ignored.

I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml failing that were eventually tracked down to be wrong values passed to memmap.

Quoted 7 lines

This patch prevents the above issue by instead of adding a new memory range, only update a RAM memory range with the PRAM type. This way, passing the wrong memmap will either not give you a pmem at all or give you a smaller one that actually has RAM behind it.

And if someone still needs to fake a pmem that doesn't have RAM behind it, they can simply do memmap=XX@YY,XX!YY.

Thanks! I've debugged a report like this as well.

A message that is not in the archive (sent off-list or not yet received): CAPcyv4hiOwx5LM+80Hz7jWnidMrKVjY9V5B3zS7y_g7C1KLoYQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#4 lore raw

Hi,
I've sent this to the wrong maintainer by mistake (sorry about that) so I going to re-post it again in a moment.
FYI

Thanks,
Yigal

Quoted 19 lines · Dan Williams
Quoted 9 lines · Yigal Korman

Before this patch, passing a range that is beyond the physical memory range will succeed, the user will see a /dev/pmem0 and will be able to access it. Reads will always return 0 and writes will be silently ignored.

I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml failing that were eventually tracked down to be wrong values passed to memmap.

Quoted 7 lines

This patch prevents the above issue by instead of adding a new memory range, only update a RAM memory range with the PRAM type. This way, passing the wrong memmap will either not give you a pmem at all or give you a smaller one that actually has RAM behind it.

And if someone still needs to fake a pmem that doesn't have RAM behind it, they can simply do memmap=XX@YY,XX!YY.

Thanks! I've debugged a report like this as well.