From 241c068066c51e9e06adf6d45834b97a50d029cf Mon Sep 17 00:00:00 2001 From: Cam Tenny Date: Wed, 24 Oct 2012 18:52:40 -0400 Subject: [PATCH 1/2] Prevent extra rebuild of fs.img by keeping intermediate object files. --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 33bfb0a..20cb884 100644 --- a/Makefile +++ b/Makefile @@ -148,6 +148,12 @@ _forktest: forktest.o $(ULIB) mkfs: mkfs.c fs.h gcc -Werror -Wall -o mkfs mkfs.c +# Prevent deletion of intermediate files, e.g. cat.o, after first build, so +# that disk image changes after first build are persistent until clean. More +# details: +# http://www.gnu.org/software/make/manual/html_node/Chained-Rules.html +.PRECIOUS: %.o + UPROGS=\ _cat\ _echo\ From ff2783442ea2801a4bf6c76f198f36a6e985e7dd Mon Sep 17 00:00:00 2001 From: Stephen Tu Date: Mon, 4 Mar 2013 16:16:54 -0500 Subject: [PATCH 2/2] Correct a security bug in copyuvm() copyuvm() should not allow new copied pages to inherit more permissions than the original pages. --- mmu.h | 1 + vm.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mmu.h b/mmu.h index 5c9ab60..685f51d 100644 --- a/mmu.h +++ b/mmu.h @@ -142,6 +142,7 @@ struct segdesc { // Address in page table or page directory entry #define PTE_ADDR(pte) ((uint)(pte) & ~0xFFF) +#define PTE_FLAGS(pte) ((uint)(pte) & 0xFFF) #ifndef __ASSEMBLER__ typedef uint pte_t; diff --git a/vm.c b/vm.c index dde56b7..4cffb58 100644 --- a/vm.c +++ b/vm.c @@ -311,7 +311,7 @@ copyuvm(pde_t *pgdir, uint sz) { pde_t *d; pte_t *pte; - uint pa, i; + uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) @@ -322,10 +322,11 @@ copyuvm(pde_t *pgdir, uint sz) if(!(*pte & PTE_P)) panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); + flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)p2v(pa), PGSIZE); - if(mappages(d, (void*)i, PGSIZE, v2p(mem), PTE_W|PTE_U) < 0) + if(mappages(d, (void*)i, PGSIZE, v2p(mem), flags) < 0) goto bad; } return d;