RE: What is page_alloc.c's bad_page() function?

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

 



Hi,

> 
> static void bad_page(struct page *page)
> {
>         printk(KERN_EMERG "Bad page state in process '%s'\n"
>                 KERN_EMERG "page:%p flags:0x%0*lx mapping:%p
> mapcount:%d count:%d\n"
>                 KERN_EMERG "Trying to fix it up, but a reboot is
>                 needed\n" KERN_EMERG "Backtrace:\n",
>                 current->comm, page, (int)(2*sizeof(unsigned long)),
>                 (unsigned long)page->flags, page->mapping,
>                 page_mapcount(page), page_count(page));
>         dump_stack();
>         page->flags &= ~(1 << PG_lru    |
>                         1 << PG_private |
>                         1 << PG_locked  |
>                         1 << PG_active  |
>                         1 << PG_dirty   |
>                         1 << PG_reclaim |
>                         1 << PG_slab    |
>                         1 << PG_swapcache |
>                         1 << PG_writeback |
>                         1 << PG_buddy );
>         set_page_count(page, 0);
>         reset_page_mapcount(page);
>         page->mapping = NULL;
>         add_taint(TAINT_BAD_PAGE);
> }
> 
> Question:
> 
> a.   what is the purpose of this function - it seems that all the
> caller of this function will continue execution as if nothing has
> happened?   And the next line may process the "page" which this
> funcion has modify?
> b.   what is the purpose of setting to NOT the list of PG_xxxx flags
> shown above?

IMHO, this function is called when some inconsistency is detected regarding the page structure. Since something problematic has occured, the code is just trying to do a graceful recovery by setting default values to certain page attributes. And hence the code continues as it is after calling this function (to make a note that somehing is not right). 

> c.   What is the purpose of the add_taint() function?

As the comment clearly indicates, this function asserts that you can't trust the integrity of the kernel anymore. This may be due to a lot of reasons such as insertion of a tainted module (unlicensed) and in this case, TAINT_BAD_PAGE. Here are the various other reasons:

TAINT_PROPRIETARY_MODULE
TAINT_FORCED_MODULE     
TAINT_UNSAFE_SMP        
TAINT_FORCED_RMMOD      
TAINT_MACHINE_CHECK     
TAINT_BAD_PAGE          
TAINT_USER              
TAINT_DIE               

The kernel informs that it is tainted in case of OOPS / Panic etc. In case of tainted kernel due to proprietary module, kernel developers are likely suggest you to remove the tainted condition first.

Thanks,

Rajat

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux