Re: [PATCH -v3] x86: Make sure free_init_pages() free pages in boundary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 27, 2010 at 05:50:06PM -0700, Yinghai Lu wrote:
> > diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
> > index e71c5cb..018e793 100644
> > --- a/arch/x86/mm/init.c
> > +++ b/arch/x86/mm/init.c
> > @@ -336,6 +336,11 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
> >  	if (addr >= end)
> >  		return;
> >  
> > +	if (WARN_ON(addr & ~PAGE_MASK || end & ~PAGE_MASK)) {
> > +		addr = PAGE_ALIGN(addr);
> > +		end &= PAGE_MASK;
> > +	}
> > +
> >  	/*
> >  	 * If debugging page accesses then do not free this memory but
> >  	 * mark them not present - any buggy init-section access will
> > @@ -355,11 +360,10 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
> >  
> >  	printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
> >  
> > -	for (; addr < end; addr += PAGE_SIZE) {
> > +	for (; addr != end; addr += PAGE_SIZE) {
> >  		ClearPageReserved(virt_to_page(addr));
> >  		init_page_count(virt_to_page(addr));
> > -		memset((void *)(addr & ~(PAGE_SIZE-1)),
> > -			POISON_FREE_INITMEM, PAGE_SIZE);
> > +		memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
> >  		free_page(addr);
> >  		totalram_pages++;
> >  	}
> something wrong here, if someone pass (0x10, 0x20), the will be aligned to [0x1000, 0]
> you will get dead loop

You are right!  It should be enough to move the alignment fixup above the addr >= end
check and in that case?  So we would get the warning and then simply return.

> will update that.

Thanks!

> YH

	Hannes
--
To unsubscribe from this list: send the line "unsubscribe linux-arch" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel]     [Kernel Newbies]     [x86 Platform Driver]     [Netdev]     [Linux Wireless]     [Netfilter]     [Bugtraq]     [Linux Filesystems]     [Yosemite Discussion]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]

  Powered by Linux