From: Andrew Morton <akpm@osdl.org>
To: Roland McGrath <roland@redhat.com>
Cc: torvalds@osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] restore protections after forced fault in get_user_pages
Date: Mon, 2 Feb 2004 14:46:42 -0800 [thread overview]
Message-ID: <20040202144642.50ea0468.akpm@osdl.org> (raw)
In-Reply-To: <200402020729.i127TKG8011009@magilla.sf.frob.com>
Roland McGrath <roland@redhat.com> wrote:
>
> get_user_pages can force a fault to succeed despite the vma's protections.
> This is used in access_process_vm, so that ptrace can write an unwritable
> page, or read an unreadable but present page.
That's a bit ugly, isn't it? We don't want to modify the pte permissions
in this case. We just want the page frame. But we do still want to call
handle_mm_fault() if the page isn't there at all, or to COW it.
One way to handle that would be to give the `write' arg to
handle_mm_fault() a third value which means "give us a writeable page, but
don't make the pte writeable". Maybe that isn't warranted for this special
case. But it would be better, really.
> +/*
> + * Reset the page table entry for the given address after faulting in a page.
> + * We restore the protections indicated by its vma.
> + */
> +static void
> +restore_page_prot(struct mm_struct *mm, struct vm_area_struct *vma,
> + unsigned long address)
> +{
> + pgd_t *pgd = pgd_offset(mm, address);
> + pmd_t *pmd = pmd_alloc(mm, pgd, address);
> + pte_t *pte;
> + if (!pmd)
> + return;
> + pte = pte_alloc_map(mm, pmd, address);
> + if (!pte)
> + return;
> + flush_cache_page(vma, address);
> + ptep_establish(vma, address, pte, pte_modify(*pte, vma->vm_page_prot));
> + update_mmu_cache(vma, address, entry);
> + pte_unmap(pte);
> +}
This guy forgot to flush the tlb after modifying the pte permissions, and
symbol `entry' is not defined. We've hit the latter problem multiple
times. It's a good argument for empty inlines rather than empty macros.
diff -puN mm/memory.c~get_user_pages-restore-protections-fix mm/memory.c
--- 25/mm/memory.c~get_user_pages-restore-protections-fix Mon Feb 2 14:34:34 2004
+++ 25-akpm/mm/memory.c Mon Feb 2 14:35:47 2004
@@ -701,6 +701,7 @@ restore_page_prot(struct mm_struct *mm,
pgd_t *pgd = pgd_offset(mm, address);
pmd_t *pmd = pmd_alloc(mm, pgd, address);
pte_t *pte;
+ pte_t entry;
if (!pmd)
return;
@@ -708,7 +709,9 @@ restore_page_prot(struct mm_struct *mm,
if (!pte)
return;
flush_cache_page(vma, address);
- ptep_establish(vma, address, pte, pte_modify(*pte, vma->vm_page_prot));
+ entry = pte_modify(*pte, vma->vm_page_prot);
+ ptep_establish(vma, address, pte, entry);
+ flush_tlb_page(vma, address);
update_mmu_cache(vma, address, entry);
pte_unmap(pte);
}
_
next prev parent reply other threads:[~2004-02-02 22:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-02 7:29 Roland McGrath
2004-02-02 22:46 ` Andrew Morton [this message]
2004-02-02 23:09 ` Linus Torvalds
2004-02-02 23:48 ` Roland McGrath
2004-02-02 23:55 ` Linus Torvalds
2004-02-03 0:03 ` Roland McGrath
2004-02-03 0:09 ` Roland McGrath
2004-02-03 0:30 ` Linus Torvalds
2004-02-03 0:42 ` Andrew Morton
2004-02-03 0:55 ` Roland McGrath
2004-02-03 8:29 ` Ingo Molnar
2004-02-03 10:25 ` Roland McGrath
2004-02-03 17:04 ` Linus Torvalds
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=20040202144642.50ea0468.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=torvalds@osdl.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
all inboxes | Powered by JetHome®