Skip to content

Commit

Permalink
[PATCH] fix for generic_file_write iov problem
Browse files Browse the repository at this point in the history
Here is the fix for the problem described in

	http://bugzilla.kernel.org/show_bug.cgi?id=4721

Basically, problem is generic_file_buffered_write() is accessing beyond end
of the iov[] vector after handling the last vector.  If we happen to cross
page boundary, we get a fault.

I think this simple patch is good enough.  If we really don't want to
depend on the "count", then we need pass nr_segs to
filemap_set_next_iovec() and decrement it and check it.

Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Badari Pulavarty authored and Linus Torvalds committed Jun 25, 2005
1 parent 8ae0b77 commit b0cfbd9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,9 @@ generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
if (unlikely(nr_segs > 1)) {
filemap_set_next_iovec(&cur_iov,
&iov_base, status);
buf = cur_iov->iov_base + iov_base;
if (count)
buf = cur_iov->iov_base +
iov_base;
} else {
iov_base += status;
}
Expand Down

0 comments on commit b0cfbd9

Please sign in to comment.