From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EC78C433EF for ; Wed, 23 Feb 2022 18:21:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6846C8D0035; Wed, 23 Feb 2022 13:21:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 634178D0011; Wed, 23 Feb 2022 13:21:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D3D08D0035; Wed, 23 Feb 2022 13:21:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id 245DE8D0011 for ; Wed, 23 Feb 2022 13:21:53 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B4DF322F06 for ; Wed, 23 Feb 2022 18:21:52 +0000 (UTC) X-FDA: 79174863264.10.59B11E9 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id D8C3C18000E for ; Wed, 23 Feb 2022 18:21:51 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 86F2BB820F7; Wed, 23 Feb 2022 18:21:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F25CCC340E7; Wed, 23 Feb 2022 18:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1645640508; bh=3yUKy+iP4Mxqr10PLCbBx6VcfKw+/mhWYC99SkSlObo=; h=Subject:To:Cc:From:Date:In-Reply-To:From; b=gPC/gBR3XzLZOKrieJAhufYvZblORB1p/SGCQwYuxouB6pyUCq/BQgaIwyJ8QjuJk HwLl5YupKWRA836Pf1mTopkM7xVllG8WbN0CPk7sx73sX4NELFEfeR+qtrg/gF6a9A YAAbOhL966yVH6U0IAaE8zYdeWZ2W16CuKzCuO68= Subject: Patch "mm/filemap: Fix handling of THPs in generic_file_buffered_read()" has been added to the 5.16-stable tree To: amajer@suse.com,dmueller@suse.com,gregkh@linuxfoundation.org,kirill.shutemov@linux.intel.com,linux-mm@kvack.org,songliubraving@fb.com,tiwai@suse.de,vbabka@suse.cz,willy@infradead.org Cc: From: Date: Wed, 23 Feb 2022 19:21:29 +0100 In-Reply-To: <20220223155918.927140-1-willy@infradead.org> Message-ID: <164564048917362@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit X-stable: commit X-Patchwork-Hint: ignore X-Rspamd-Queue-Id: D8C3C18000E X-Stat-Signature: 4whr3mawwuw8ncn34w5gynyag3775wou Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=korg header.b="gPC/gBR3"; dmarc=pass (policy=none) header.from=linuxfoundation.org; spf=pass (imf06.hostedemail.com: domain of gregkh@linuxfoundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org X-Rspam-User: X-Rspamd-Server: rspam11 X-HE-Tag: 1645640511-820108 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is a note to let you know that I've just added the patch titled mm/filemap: Fix handling of THPs in generic_file_buffered_read() to the 5.16-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: mm-filemap-fix-handling-of-thps-in-generic_file_buffered_read.patch and it can be found in the queue-5.16 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >From willy@infradead.org Wed Feb 23 18:42:46 2022 From: "Matthew Wilcox (Oracle)" Date: Wed, 23 Feb 2022 15:59:18 +0000 Subject: mm/filemap: Fix handling of THPs in generic_file_buffered_read() To: stable@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com, Song Liu Cc: "Matthew Wilcox (Oracle)" , Adam Majer , Dirk Mueller , Takashi Iwai , Vlastimil Babka Message-ID: <20220223155918.927140-1-willy@infradead.org> From: "Matthew Wilcox (Oracle)" When a THP is present in the page cache, we can return it several times, leading to userspace seeing the same data repeatedly if doing a read() that crosses a 64-page boundary. This is probably not a security issue (since the data all comes from the same file), but it can be interpreted as a transient data corruption issue. Fortunately, it is very rare as it can only occur when CONFIG_READ_ONLY_THP_FOR_FS is enabled, and it can only happen to executables. We don't often call read() on executables. This bug is fixed differently in v5.17 by commit 6b24ca4a1a8d ("mm: Use multi-index entries in the page cache"). That commit is unsuitable for backporting, so fix this in the clearest way. It sacrifices a little performance for clarity, but this should never be a performance path in these kernel versions. Fixes: cbd59c48ae2b ("mm/filemap: use head pages in generic_file_buffered_read") Cc: stable@vger.kernel.org # v5.15, v5.16 Link: https://lore.kernel.org/r/df3b5d1c-a36b-2c73-3e27-99e74983de3a@suse.cz/ Analyzed-by: Adam Majer Analyzed-by: Dirk Mueller Bisected-by: Takashi Iwai Reported-by: Vlastimil Babka Tested-by: Vlastimil Babka Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Greg Kroah-Hartman --- mm/filemap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2365,8 +2365,12 @@ static void filemap_get_read_batch(struc break; if (PageReadahead(head)) break; - xas.xa_index = head->index + thp_nr_pages(head) - 1; - xas.xa_offset = (xas.xa_index >> xas.xa_shift) & XA_CHUNK_MASK; + if (PageHead(head)) { + xas_set(&xas, head->index + thp_nr_pages(head)); + /* Handle wrap correctly */ + if (xas.xa_index - 1 >= max) + break; + } continue; put_page: put_page(head); Patches currently in stable-queue which might be from willy@infradead.org are queue-5.16/mm-filemap-fix-handling-of-thps-in-generic_file_buffered_read.patch