Browse Source

Merge branch 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull vfs fix from Al Viro:
 "Braino fix for iov_iter_revert() misuse"

* 'work.iov_iter' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  fix braino in generic_file_read_iter()
Linus Torvalds 8 years ago
parent
commit
339fbf6796
2 changed files with 3 additions and 1 deletions
  1. 2 0
      lib/iov_iter.c
  2. 1 1
      mm/filemap.c

+ 2 - 0
lib/iov_iter.c

@@ -790,6 +790,8 @@ void iov_iter_revert(struct iov_iter *i, size_t unroll)
 {
 {
 	if (!unroll)
 	if (!unroll)
 		return;
 		return;
+	if (WARN_ON(unroll > MAX_RW_COUNT))
+		return;
 	i->count += unroll;
 	i->count += unroll;
 	if (unlikely(i->type & ITER_PIPE)) {
 	if (unlikely(i->type & ITER_PIPE)) {
 		struct pipe_inode_info *pipe = i->pipe;
 		struct pipe_inode_info *pipe = i->pipe;

+ 1 - 1
mm/filemap.c

@@ -2050,7 +2050,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
 			iocb->ki_pos += retval;
 			iocb->ki_pos += retval;
 			count -= retval;
 			count -= retval;
 		}
 		}
-		iov_iter_revert(iter, iov_iter_count(iter) - count);
+		iov_iter_revert(iter, count - iov_iter_count(iter));
 
 
 		/*
 		/*
 		 * Btrfs can have a short DIO read if we encounter
 		 * Btrfs can have a short DIO read if we encounter