From abe2f41430770270a1512bf78f489284bfbdbd04 Mon Sep 17 00:00:00 2001 From: Alexey Korolev Date: Mon, 14 Apr 2008 20:45:06 +0100 Subject: JFFS2 Fix of panics caused by wrong condition for hole frag creation in write_begin 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. [ Side note: the bug is a fairly direct result of the naming. Nick was likely misled by the use of "offs", since we tend to use the notion of "offset" not as an absolute position, but as an offset _within_ a page or allocation. Alternatively, a "pgoff_t" is a page index, but not a byte offset - our VM naming can be a bit confusing. So in this case, a VM person would likely have called this a "pos", not an "offs", or perhaps talked about byte offsets rather than page offsets (since it's counted in bytes, not pages). - Linus ] Signed-off-by: Alexey Korolev Signed-off-by: Vasiliy Leonenko Signed-off-by: David Woodhouse Signed-off-by: Linus Torvalds --- fs/jffs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/jffs2') diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index f9c5dd6f4b6..dcc2734e0b5 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -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); -- cgit v1.2.3 From 6188e10d38b8d7244ee7776d5f1f88c837b4b93f Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Fri, 18 Apr 2008 22:21:05 -0400 Subject: Convert asm/semaphore.h users to linux/semaphore.h Signed-off-by: Matthew Wilcox --- fs/jffs2/jffs2_fs_i.h | 2 +- fs/jffs2/jffs2_fs_sb.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/jffs2') diff --git a/fs/jffs2/jffs2_fs_i.h b/fs/jffs2/jffs2_fs_i.h index 0b78fdc9773..a841f4973a7 100644 --- a/fs/jffs2/jffs2_fs_i.h +++ b/fs/jffs2/jffs2_fs_i.h @@ -15,7 +15,7 @@ #include #include #include -#include +#include struct jffs2_inode_info { /* We need an internal mutex similar to inode->i_mutex. diff --git a/fs/jffs2/jffs2_fs_sb.h b/fs/jffs2/jffs2_fs_sb.h index 3a2197f3c81..18fca2b9e53 100644 --- a/fs/jffs2/jffs2_fs_sb.h +++ b/fs/jffs2/jffs2_fs_sb.h @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include -- cgit v1.2.3