linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* bug in order>0 page allocations with !CONFIG_MMU
@ 2004-11-04 14:28 David Howells
  2004-11-05  5:15 ` [uClinux-dev] " Greg Ungerer
  0 siblings, 1 reply; 3+ messages in thread
From: David Howells @ 2004-11-04 14:28 UTC (permalink / raw)
  To: uClinux development list; +Cc: linux-kernel


Hi,

I've found that this:

	[mm/page_alloc.c]
	static inline void set_page_refs(struct page *page, int order)
	{
	#ifdef CONFIG_MMU
		set_page_count(page, 1);
	#else
		int i;

		/*
		 * We need to reference all the pages for this order, otherwise if
		 * anyone accesses one of the pages with (get/put) it will be freed.
		 */
		for (i = 0; i < (1 << order); i++)
			set_page_count(page+i, 1);
	#endif /* CONFIG_MMU */
	}

Causes problems if !CONFIG_MMU because __free_pages_ok()/free_pages_check()
reports a bad page on the second page when it comes time to free it:

	Bad page state at __free_pages_ok (in process 'events/0', page c08132e0)
	flags:0x20000000 mapping:00000000 mapcount:0 count:1

Why is doing this necessary at all? No one should be touching the individual
pages of a block allocation. The kernel should defend itself against
userspace trying to munmap part of a multipage mmap.

I think this should be:

	static inline void set_page_refs(struct page *page, int order)
	{
		set_page_count(page, 1);
	}

It seems to work for me. If no one disagrees, I'll give akpm a patch for this.

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uClinux-dev] bug in order>0 page allocations with !CONFIG_MMU
  2004-11-04 14:28 bug in order>0 page allocations with !CONFIG_MMU David Howells
@ 2004-11-05  5:15 ` Greg Ungerer
  2004-11-05 12:11   ` David Howells
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Ungerer @ 2004-11-05  5:15 UTC (permalink / raw)
  To: uClinux development list; +Cc: linux-kernel

Hi David,

David Howells wrote:
> I've found that this:
> 
> 	[mm/page_alloc.c]
> 	static inline void set_page_refs(struct page *page, int order)
> 	{
> 	#ifdef CONFIG_MMU
> 		set_page_count(page, 1);
> 	#else
> 		int i;
> 
> 		/*
> 		 * We need to reference all the pages for this order, otherwise if
> 		 * anyone accesses one of the pages with (get/put) it will be freed.
> 		 */
> 		for (i = 0; i < (1 << order); i++)
> 			set_page_count(page+i, 1);
> 	#endif /* CONFIG_MMU */
> 	}
> 
> Causes problems if !CONFIG_MMU because __free_pages_ok()/free_pages_check()
> reports a bad page on the second page when it comes time to free it:
> 
> 	Bad page state at __free_pages_ok (in process 'events/0', page c08132e0)
> 	flags:0x20000000 mapping:00000000 mapcount:0 count:1

That itself can be fixed by not checking the page_counts in
__free_pages_ok():

@@ -219,7 +219,9 @@
  {
         if (    page_mapped(page) ||
                 page->mapping != NULL ||
+#ifdef CONFIG_MMU
                 page_count(page) != 0 ||
+#endif
                 (page->flags & (
                         1 << PG_lru     |
                         1 << PG_private |



> Why is doing this necessary at all? No one should be touching the individual
> pages of a block allocation. The kernel should defend itself against
> userspace trying to munmap part of a multipage mmap.

I don't recall right now why we had to do this originally.
It was absolutely neccessary once, but I don't think we need
this anymore. At least it runs fine on m68knommu targets now
without this.

Regards
Greg



------------------------------------------------------------------------
Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg@snapgear.com
SnapGear -- a CyberGuard Company            PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [uClinux-dev] bug in order>0 page allocations with !CONFIG_MMU
  2004-11-05  5:15 ` [uClinux-dev] " Greg Ungerer
@ 2004-11-05 12:11   ` David Howells
  0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2004-11-05 12:11 UTC (permalink / raw)
  To: uClinux development list; +Cc: linux-kernel


> > Why is doing this necessary at all? No one should be touching the
> > individual pages of a block allocation. The kernel should defend itself
> > against userspace trying to munmap part of a multipage mmap.
> 
> I don't recall right now why we had to do this originally.
> It was absolutely neccessary once, but I don't think we need
> this anymore. At least it runs fine on m68knommu targets now
> without this.

I've just found out what it's necessary for. access_process_vm() as called
from, say, /proc/cmdline.

David

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-05 12:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-04 14:28 bug in order>0 page allocations with !CONFIG_MMU David Howells
2004-11-05  5:15 ` [uClinux-dev] " Greg Ungerer
2004-11-05 12:11   ` David Howells

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).