summaryrefslogtreecommitdiff
path: root/kernel/vm.c
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2022-08-12 13:22:10 -0400
committerFrans Kaashoek <[email protected]>2022-08-12 13:22:10 -0400
commit899cc02660232092209a5db57b326ab7b49813dd (patch)
treeabde95c343fb06294fba1c30036a3d6564602693 /kernel/vm.c
parent8f58cc7df99e9f697ca3843886802ecab5cb8991 (diff)
downloadxv6-labs-899cc02660232092209a5db57b326ab7b49813dd.tar.gz
xv6-labs-899cc02660232092209a5db57b326ab7b49813dd.tar.bz2
xv6-labs-899cc02660232092209a5db57b326ab7b49813dd.zip
Experiment with being more precise setting permissions for user pages.
Growing adds R|W pages (without X). Exec() marks the stack only R|W. Probably could setup permissions for text and data better if we call ld with --no-omagic instead of -N.
Diffstat (limited to 'kernel/vm.c')
-rw-r--r--kernel/vm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/vm.c b/kernel/vm.c
index 3c6f295..284b72d 100644
--- a/kernel/vm.c
+++ b/kernel/vm.c
@@ -218,7 +218,7 @@ uvmfirst(pagetable_t pagetable, uchar *src, uint sz)
// Allocate PTEs and physical memory to grow process from oldsz to
// newsz, which need not be page aligned. Returns new size or 0 on error.
uint64
-uvmalloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz)
+uvmalloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz, int xperm)
{
char *mem;
uint64 a;
@@ -234,7 +234,7 @@ uvmalloc(pagetable_t pagetable, uint64 oldsz, uint64 newsz)
return 0;
}
memset(mem, 0, PGSIZE);
- if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_W|PTE_X|PTE_R|PTE_U) != 0){
+ if(mappages(pagetable, a, PGSIZE, (uint64)mem, PTE_R|PTE_U|xperm) != 0){
kfree(mem);
uvmdealloc(pagetable, a, oldsz);
return 0;