Skip to content

Commit

Permalink
JFFS2 Fix of panics caused by wrong condition for hole frag creation …
Browse files Browse the repository at this point in the history
…in write_begin

This fixes a regression introduced in commit
205c109 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 <akorolev@infradead.org>
Signed-off-by: Vasiliy Leonenko <vasiliy.leonenko@mail.ru>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Alexey Korolev authored and Linus Torvalds committed Apr 14, 2008
1 parent 19e729a commit abe2f41
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/jffs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit abe2f41

Please sign in to comment.