]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.13-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2014 17:25:05 +0000 (10:25 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 20 Mar 2014 17:25:05 +0000 (10:25 -0700)
added patches:
mm-readahead.c-fix-do_readahead-for-no-readpage-s.patch

queue-3.13/mm-readahead.c-fix-do_readahead-for-no-readpage-s.patch [new file with mode: 0644]
queue-3.13/series

diff --git a/queue-3.13/mm-readahead.c-fix-do_readahead-for-no-readpage-s.patch b/queue-3.13/mm-readahead.c-fix-do_readahead-for-no-readpage-s.patch
new file mode 100644 (file)
index 0000000..6837637
--- /dev/null
@@ -0,0 +1,77 @@
+From 58d5640ebdb273cc817b0d0cda7bcf2efbbc2ff7 Mon Sep 17 00:00:00 2001
+From: Mark Rutland <mark.rutland@arm.com>
+Date: Wed, 29 Jan 2014 14:05:51 -0800
+Subject: mm/readahead.c: fix do_readahead() for no readpage(s)
+
+From: Mark Rutland <mark.rutland@arm.com>
+
+commit 58d5640ebdb273cc817b0d0cda7bcf2efbbc2ff7 upstream.
+
+Commit 63d0f0a3c7e1 ("mm/readahead.c:do_readhead(): don't check for
+->readpage") unintentionally made do_readahead return 0 for all valid
+files regardless of whether readahead was supported, rather than the
+expected -EINVAL.  This gets forwarded on to userspace, and results in
+sys_readahead appearing to succeed in cases that don't make sense (e.g.
+when called on pipes or sockets).  This issue is detected by the LTP
+readahead01 testcase.
+
+As the exact return value of force_page_cache_readahead is currently
+never used, we can simplify it to return only 0 or -EINVAL (when
+readpage or readpages is missing).  With that in place we can simply
+forward on the return value of force_page_cache_readahead in
+do_readahead.
+
+This patch performs said change, restoring the expected semantics.
+
+Signed-off-by: Mark Rutland <mark.rutland@arm.com>
+Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Josh Boyer <jwboyer@fedoraproject.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ mm/readahead.c |   15 +++++----------
+ 1 file changed, 5 insertions(+), 10 deletions(-)
+
+--- a/mm/readahead.c
++++ b/mm/readahead.c
+@@ -211,8 +211,6 @@ out:
+ int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
+               pgoff_t offset, unsigned long nr_to_read)
+ {
+-      int ret = 0;
+-
+       if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages))
+               return -EINVAL;
+@@ -226,15 +224,13 @@ int force_page_cache_readahead(struct ad
+                       this_chunk = nr_to_read;
+               err = __do_page_cache_readahead(mapping, filp,
+                                               offset, this_chunk, 0);
+-              if (err < 0) {
+-                      ret = err;
+-                      break;
+-              }
+-              ret += err;
++              if (err < 0)
++                      return err;
++
+               offset += this_chunk;
+               nr_to_read -= this_chunk;
+       }
+-      return ret;
++      return 0;
+ }
+ /*
+@@ -576,8 +572,7 @@ do_readahead(struct address_space *mappi
+       if (!mapping || !mapping->a_ops)
+               return -EINVAL;
+-      force_page_cache_readahead(mapping, filp, index, nr);
+-      return 0;
++      return force_page_cache_readahead(mapping, filp, index, nr);
+ }
+ SYSCALL_DEFINE3(readahead, int, fd, loff_t, offset, size_t, count)
index 2ff3cf4a3dd43df2cb3926fadad3dea3e527ee66..ff3c15926d07a584b3081fa9b806b75ee254a1d3 100644 (file)
@@ -93,3 +93,4 @@ iscsi-iser-target-fix-isert_conn-state-hung-shutdown-issues.patch
 iser-target-ignore-completions-for-frwrs-in-isert_cq_tx_work.patch
 iser-target-fix-post_send_buf_count-for-rdma-read-write.patch
 iser-target-fix-command-leak-for-tx_desc-comp_llnode_batch.patch
+mm-readahead.c-fix-do_readahead-for-no-readpage-s.patch