[PATCH] Wrong assumption in set_bh_page()

From: Mark Hemment
Date: Sun Aug 17 2003 - 11:45:36 EST


set_bh_page() assumes page_address() will always return NULL for a
highmem page. This assumption is wrong - the highmem page could be
kmap()ped.

Luckily, no code I've looked at assumes that b_data contains a _pure_
offset for a highmem page, but this is a bug waiting to happen.

Patch is against 2.4.21-rc1.

Mark


diff -urN linux-2.4.21-rc1/fs/buffer.c linux-2.4.21-rc1-bh/fs/buffer.c
--- linux-2.4.21-rc1/fs/buffer.c 2003-08-17 15:55:40.000000000 +0100
+++ linux-2.4.21-rc1-bh/fs/buffer.c 2003-08-17 18:15:13.000000000 +0100
@@ -1231,10 +1231,11 @@
if (offset >= PAGE_SIZE)
BUG();

- /*
- * page_address will return NULL anyways for highmem pages
- */
- bh->b_data = page_address(page) + offset;
+ if (PageHighMem(page)) {
+ bh->b_data = (char *)offset;
+ } else {
+ bh->b_data = page_address(page) + offset;
+ }
bh->b_page = page;
}
EXPORT_SYMBOL(set_bh_page);



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/