* [PATCH] Wrong assumption in set_bh_page()
@ 2003-08-17 16:40 Mark Hemment
0 siblings, 0 replies; only message in thread
From: Mark Hemment @ 2003-08-17 16:40 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: linux-kernel
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-08-17 16:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-17 16:40 [PATCH] Wrong assumption in set_bh_page() Mark Hemment
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).