linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <ak@muc.de>
To: akpm@digeo.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Use correct page protection for put_dirty_page
Date: Sun, 11 May 2003 10:08:41 +0200	[thread overview]
Message-ID: <20030511080841.GA31266@averell> (raw)


put_page_dirty must use the page protection of the stack VMA, not hardcoded
PAGE_COPY. They can be different e.g. when the stack is set non executable
via VM_STACK_FLAGS.

I added an fallback path for now because I'm not sure if the stack VMA
is always predowngrowed here, if the printk better it may be also needed
to add an stack extension here.

-Andi

--- linux-2.5.69-amd64/fs/exec.c-o	2003-04-20 21:21:50.000000000 +0200
+++ linux-2.5.69-amd64/fs/exec.c	2003-05-11 08:38:35.000000000 +0200
@@ -292,7 +292,9 @@
 	pgd_t * pgd;
 	pmd_t * pmd;
 	pte_t * pte;
+	pgprot_t prot;
 	struct pte_chain *pte_chain;
+	struct vm_area_struct *vma;
 
 	if (page_count(page) != 1)
 		printk(KERN_ERR "mem_map disagrees with %p at %08lx\n", page, address);
@@ -314,7 +316,13 @@
 	}
 	lru_cache_add_active(page);
 	flush_dcache_page(page);
-	set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(page, PAGE_COPY))));
+	vma = find_vma(tsk->mm, address);
+	if (!vma) { 
+		printk("put_dirty_page: stack vma not extended yet %lx?\n",address); 
+		prot = PAGE_COPY;
+	} else
+		prot = vma->vm_page_prot;
+	set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(page, prot))));
 	pte_chain = page_add_rmap(page, pte, pte_chain);
 	pte_unmap(pte);
 	tsk->mm->rss++;

             reply	other threads:[~2003-05-11  7:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-11  8:08 Andi Kleen [this message]
2003-05-11  8:30 ` [PATCH] Use correct page protection for put_dirty_page William Lee Irwin III
2003-05-11  8:36   ` Andi Kleen
2003-05-11  8:32 ` Andrew Morton
2003-05-11  8:37   ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030511080841.GA31266@averell \
    --to=ak@muc.de \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).