Jan Beulich
2008-Mar-13 16:10 UTC
[Xen-devel] [PATCH] linux: 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 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 <jbeulich@novell.com>
Index: head-2008-03-06/include/linux/page-flags.h
==================================================================---
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.000000000
+0100
@@ -305,16 +305,17 @@ static inline void __ClearPageTail(struc
#define ClearPageUncached(page) clear_bit(PG_uncached, &(page)->flags)
#define PageForeign(page) test_bit(PG_foreign, &(page)->flags)
-#define SetPageForeign(page, dtor) do { \
- set_bit(PG_foreign, &(page)->flags); \
- (page)->index = (long)(dtor); \
+#define SetPageForeign(_page, dtor) do { \
+ set_bit(PG_foreign, &(_page)->flags); \
+ BUG_ON((dtor) == (void (*)(struct page *))0); \
+ (_page)->index = (long)(dtor); \
} while (0)
-#define ClearPageForeign(page) do { \
- clear_bit(PG_foreign, &(page)->flags); \
- (page)->index = 0; \
+#define ClearPageForeign(page) do { \
+ clear_bit(PG_foreign, &(page)->flags); \
+ (page)->index = 0; \
} while (0)
-#define PageForeignDestructor(page) \
- ( (void (*) (struct page *)) (page)->index )(page)
+#define PageForeignDestructor(_page) \
+ ((void (*)(struct page *))(_page)->index)(_page)
struct page; /* forward declaration */
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel