]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mm/readahead.c: fix do_readahead() for no readpage(s)
authorMark Rutland <mark.rutland@arm.com>
Wed, 29 Jan 2014 22:05:51 +0000 (14:05 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Mar 2014 04:44:13 +0000 (21:44 -0700)
commit9b7946975ae8ba68367eb6a13e98dbd19f82ebe5
tree492dc82e3a326f017c16bb70f4f276af5ae6e79e
parent85869425bf6923e428eae62777e153c4e8196d79
mm/readahead.c: fix do_readahead() for no readpage(s)

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