From: "Jan Beulich" Subject: [PATCH] linux: validate type and value of the dtor argument of SetPageForeign() Date: Thu, 13 Mar 2008 16:10:10 +0000 Message-ID: <47D95FF2.76E4.0078.0@novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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 once, also check the destructor supplied is not NULL. As usual, written and tested on 2.6.25-rc5 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich Index: head-2008-03-06/include/linux/page-flags.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- head-2008-03-06.orig/include/linux/page-flags.h 2008-03-07 = 10:08:24.000000000 +0100 +++ head-2008-03-06/include/linux/page-flags.h 2008-03-07 10:12:47.0000000= 00 +0100 @@ -305,16 +305,17 @@ static inline void __ClearPageTail(struc #define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->fla= gs) =20 #define PageForeign(page) test_bit(PG_foreign, &(page)->flags) -#define SetPageForeign(page, dtor) do { \ - set_bit(PG_foreign, &(page)->flags); \ - (page)->index =3D (long)(dtor); \ +#define SetPageForeign(_page, dtor) do { \ + set_bit(PG_foreign, &(_page)->flags); \ + BUG_ON((dtor) =3D=3D (void (*)(struct page *))0); \ + (_page)->index =3D (long)(dtor); \ } while (0) -#define ClearPageForeign(page) do { \ - clear_bit(PG_foreign, &(page)->flags); \ - (page)->index =3D 0; \ +#define ClearPageForeign(page) do { \ + clear_bit(PG_foreign, &(page)->flags); \ + (page)->index =3D 0; \ } while (0) -#define PageForeignDestructor(page) \ - ( (void (*) (struct page *)) (page)->index )(page) +#define PageForeignDestructor(_page) \ + ((void (*)(struct page *))(_page)->index)(_page) =20 struct page; /* forward declaration */ =20