ia64/linux-2.6.18-xen.hg

changeset 474:6a196954e479

xen: validate type and value of the dtor argument of SetPageForeign()

Linux 2.6.25 changes the protoype of pte_free() etc., resulting in
those functions no longer be suitable as a PageForeign destructor. I
had to find out by way of analysing a crash, but for the future it'd
be much better if the build would already indicate a problem with
this.

At the same time, also check the destructor supplied is not NULL.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 18 11:13:37 2008 +0000 (2008-03-18)
parents 14818545121d
children f122c54b8740
files include/linux/page-flags.h
line diff
     1.1 --- a/include/linux/page-flags.h	Mon Mar 17 11:21:25 2008 +0000
     1.2 +++ b/include/linux/page-flags.h	Tue Mar 18 11:13:37 2008 +0000
     1.3 @@ -250,16 +250,17 @@
     1.4  #define ClearPageUncached(page)	clear_bit(PG_uncached, &(page)->flags)
     1.5  
     1.6  #define PageForeign(page)	test_bit(PG_foreign, &(page)->flags)
     1.7 -#define SetPageForeign(page, dtor) do {		\
     1.8 -	set_bit(PG_foreign, &(page)->flags);	\
     1.9 -	(page)->index = (long)(dtor);		\
    1.10 +#define SetPageForeign(_page, dtor) do {		\
    1.11 +	set_bit(PG_foreign, &(_page)->flags);		\
    1.12 +	BUG_ON((dtor) == (void (*)(struct page *))0);	\
    1.13 +	(_page)->index = (long)(dtor);			\
    1.14  } while (0)
    1.15 -#define ClearPageForeign(page) do {		\
    1.16 -	clear_bit(PG_foreign, &(page)->flags);	\
    1.17 -	(page)->index = 0;			\
    1.18 +#define ClearPageForeign(page) do {			\
    1.19 +	clear_bit(PG_foreign, &(page)->flags);		\
    1.20 +	(page)->index = 0;				\
    1.21  } while (0)
    1.22 -#define PageForeignDestructor(page)		\
    1.23 -	( (void (*) (struct page *)) (page)->index )(page)
    1.24 +#define PageForeignDestructor(_page)			\
    1.25 +	((void (*)(struct page *))(_page)->index)(_page)
    1.26  
    1.27  struct page;	/* forward declaration */
    1.28