Skip to contentSkip to conversation

JFFS2 Fix of panics caused by wrong condition for hole frag creation in write_begin

PATCH In review David Woodhouse 2 participants 2 messages Apr 14, 2008 – May 9, 2008

Subsystems (2)
lore
Share & tools
lore

David Woodhouse

author maintainer
#0 lore raw

PATCH 1/1 JFFS2 Fix of panics caused by wrong condition for hole frag creation in write_begin

From: Alexey Korolev <[email protected]>

This fixes a regression introduced in commit 205c109a7a96d9a3d8ffe64c4068b70811fef5e8 when switching to write_begin/write_end operations in JFFS2. The page offset is miscalculated, leading to corruption of the fragment lists and subsequently to memory corruption and panics.

fs/jffs2/file.c +1 -1
index f9c5dd6..dcc2734 100644
@@ -129,7 +129,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping,
 	struct inode *inode = mapping->host;
 	struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
 	pgoff_t index = pos >> PAGE_CACHE_SHIFT;
-	uint32_t pageofs = pos & (PAGE_CACHE_SIZE - 1);
+	uint32_t pageofs = index << PAGE_CACHE_SHIFT;
 	int ret = 0;
 
 	pg = __grab_cache_page(mapping, index);
Signature · 1 line
dwmw2
#1 lore raw
Quoted 11 lines · David Woodhouse

From: Alexey Korolev <[email protected]>

This fixes a regression introduced in commit 205c109a7a96d9a3d8ffe64c4068b70811fef5e8 when switching to write_begin/write_end operations in JFFS2. The page offset is miscalculated, leading to corruption of the fragment lists and subsequently to memory corruption and panics.

I see this in final 2.6.25 kernel.
Is this worth to go to 2.6.24.y stable too?

---
Atsushi Nemoto