From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:35550 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759423AbdADKIn (ORCPT ); Wed, 4 Jan 2017 05:08:43 -0500 Subject: Patch "vfs,mm: fix return value of read() at s_maxbytes" has been added to the 4.9-stable tree To: torvalds@linux-foundation.org, akpm@linux-foundation.org, david@fromorbit.com, fangwei1@huawei.com, gregkh@linuxfoundation.org, hch@infradead.org, joseph.salisbury@canonical.com, viro@zeniv.linux.org.uk Cc: , From: Date: Wed, 04 Jan 2017 11:08:18 +0100 Message-ID: <1483524498248238@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled vfs,mm: fix return value of read() at s_maxbytes to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: vfs-mm-fix-return-value-of-read-at-s_maxbytes.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From d05c5f7ba164aed3db02fb188c26d0dd94f5455b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 14 Dec 2016 12:45:25 -0800 Subject: vfs,mm: fix return value of read() at s_maxbytes From: Linus Torvalds commit d05c5f7ba164aed3db02fb188c26d0dd94f5455b upstream. We truncated the possible read iterator to s_maxbytes in commit c2a9737f45e2 ("vfs,mm: fix a dead loop in truncate_inode_pages_range()"), but our end condition handling was wrong: it's not an error to try to read at the end of the file. Reading past the end should return EOF (0), not EINVAL. See for example https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1649342 http://lists.gnu.org/archive/html/bug-coreutils/2016-12/msg00008.html where a md5sum of a maximally sized file fails because the final read is exactly at s_maxbytes. Fixes: c2a9737f45e2 ("vfs,mm: fix a dead loop in truncate_inode_pages_range()") Reported-by: Joseph Salisbury Cc: Wei Fang Cc: Christoph Hellwig Cc: Dave Chinner Cc: Al Viro Cc: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1686,7 +1686,7 @@ static ssize_t do_generic_file_read(stru int error = 0; if (unlikely(*ppos >= inode->i_sb->s_maxbytes)) - return -EINVAL; + return 0; iov_iter_truncate(iter, inode->i_sb->s_maxbytes); index = *ppos >> PAGE_SHIFT; Patches currently in stable-queue which might be from torvalds@linux-foundation.org are queue-4.9/mm-page_alloc-keep-pcp-count-and-list-contents-in-sync-if-struct-page-is-corrupted.patch queue-4.9/splice-reinstate-sigpipe-epipe-handling.patch queue-4.9/mm-vmscan.c-set-correct-defer-count-for-shrinker.patch queue-4.9/vfs-mm-fix-return-value-of-read-at-s_maxbytes.patch