diff options
author | 2024-09-19 14:45:08 +0200 | |
---|---|---|
committer | 2024-10-10 13:37:22 +0200 | |
commit | 830003c73d190259e45d0a99a0e3d14cb73e0af0 (patch) | |
tree | daedac01201d5591775c58f044b3ee0d169560c5 | |
parent | um: Calculate stub data address relative to stub code (diff) | |
download | wireguard-linux-830003c73d190259e45d0a99a0e3d14cb73e0af0.tar.xz wireguard-linux-830003c73d190259e45d0a99a0e3d14cb73e0af0.zip |
um: Limit TASK_SIZE to the addressable range
We may have a TASK_SIZE from the host that is bigger than UML is able to
address with a three-level pagetable on 64-bit. Guard against that by
clipping the maximum TASK_SIZE to the maximum addressable area.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Link: https://patch.msgid.link/20240919124511.282088-8-benjamin@sipsolutions.net
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r-- | arch/um/kernel/um_arch.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/um/kernel/um_arch.c b/arch/um/kernel/um_arch.c index 427024f32b9f..4452df4f2c4b 100644 --- a/arch/um/kernel/um_arch.c +++ b/arch/um/kernel/um_arch.c @@ -331,11 +331,16 @@ int __init linux_main(int argc, char **argv) stub_start -= PAGE_SIZE; host_task_size = stub_start; + /* Limit TASK_SIZE to what is addressable by the page table */ + task_size = host_task_size; + if (task_size > (unsigned long long) PTRS_PER_PGD * PGDIR_SIZE) + task_size = PTRS_PER_PGD * PGDIR_SIZE; + /* * TASK_SIZE needs to be PGDIR_SIZE aligned or else exit_mmap craps * out */ - task_size = host_task_size & PGDIR_MASK; + task_size = task_size & PGDIR_MASK; /* OS sanity checks that need to happen before the kernel runs */ os_early_checks(); |