From patchwork Fri Apr 8 20:08:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807179 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 317ECC433F5 for ; Fri, 8 Apr 2022 20:08:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7F9D6B0073; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A61836B0074; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 945AE6B0075; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0022.hostedemail.com [216.40.44.22]) by kanga.kvack.org (Postfix) with ESMTP id 822ED6B0073 for ; Fri, 8 Apr 2022 16:08:55 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 3DDE1182895A9 for ; Fri, 8 Apr 2022 20:08:55 +0000 (UTC) X-FDA: 79334800230.26.18ED455 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id C01121C000A for ; Fri, 8 Apr 2022 20:08:54 +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 dfw.source.kernel.org (Postfix) with ESMTPS id DB20961DAE; Fri, 8 Apr 2022 20:08:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40FD9C385A3; Fri, 8 Apr 2022 20:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448533; bh=skQ4+SSthFwNXEUSPxFB30AaiHqqZjOmrlj9xVcgnkk=; h=Date:To:From:In-Reply-To:Subject:From; b=BKrsdFk73utuvqjSyEUscWJAyAaZ5FM/xIs8jmNtD8FsiwQxY6gFzuGZvgsr1DxcC 9D4/wu+TmfmcwBoNk5ARjFrVHJf1DDvNUAIxC7VPpTCwsB4V6SRYqLKxMbGF1cApeG EIZjnkZGrVB3R1n9LRSN6TGJFmfp68aizE+aJEW8= Date: Fri, 08 Apr 2022 13:08:52 -0700 To: willy@infradead.org,naoya.horiguchi@linux.dev,mhocko@kernel.org,ziy@nvidia.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 1/9] mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation. Message-Id: <20220408200853.40FD9C385A3@smtp.kernel.org> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C01121C000A X-Stat-Signature: gtnt1oqmi35j5gxt97auhht4fgq9kh5i X-Rspam-User: Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=BKrsdFk7; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-HE-Tag: 1649448534-353657 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: From: Zi Yan Subject: mm: migrate: use thp_order instead of HPAGE_PMD_ORDER for new page allocation. Fix a VM_BUG_ON_FOLIO(folio_nr_pages(old) != nr_pages) crash. With folios support, it is possible to have other than HPAGE_PMD_ORDER THPs, in the form of folios, in the system. Use thp_order() to correctly determine the source page order during migration. Link: https://lkml.kernel.org/r/20220404165325.1883267-1-zi.yan@sent.com Link: https://lore.kernel.org/linux-mm/20220404132908.GA785673@u2004/ Fixes: d68eccad3706 ("mm/filemap: Allow large folios to be added to the page cache") Reported-by: Naoya Horiguchi Signed-off-by: Zi Yan Cc: Matthew Wilcox Cc: Michal Hocko Signed-off-by: Andrew Morton --- mm/mempolicy.c | 2 +- mm/migrate.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/mm/mempolicy.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +++ a/mm/mempolicy.c @@ -1209,7 +1209,7 @@ static struct page *new_page(struct page struct page *thp; thp = alloc_hugepage_vma(GFP_TRANSHUGE, vma, address, - HPAGE_PMD_ORDER); + thp_order(page)); if (!thp) return NULL; prep_transhuge_page(thp); --- a/mm/migrate.c~mm-migrate-use-thp_order-instead-of-hpage_pmd_order-for-new-page-allocation +++ a/mm/migrate.c @@ -1547,7 +1547,7 @@ struct page *alloc_migration_target(stru */ gfp_mask &= ~__GFP_RECLAIM; gfp_mask |= GFP_TRANSHUGE; - order = HPAGE_PMD_ORDER; + order = thp_order(page); } zidx = zone_idx(page_zone(page)); if (is_highmem_idx(zidx) || zidx == ZONE_MOVABLE) From patchwork Fri Apr 8 20:08:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807180 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 737F9C433FE for ; Fri, 8 Apr 2022 20:08:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B43696B0074; Fri, 8 Apr 2022 16:08:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF31C6B0075; Fri, 8 Apr 2022 16:08:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E0F26B0078; Fri, 8 Apr 2022 16:08:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 923126B0074 for ; Fri, 8 Apr 2022 16:08:58 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 68DCD6150E for ; Fri, 8 Apr 2022 20:08:58 +0000 (UTC) X-FDA: 79334800356.19.BF2BBC7 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf24.hostedemail.com (Postfix) with ESMTP id D6EDE180009 for ; Fri, 8 Apr 2022 20:08:57 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 0A7D561E28; Fri, 8 Apr 2022 20:08:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 602F9C385A6; Fri, 8 Apr 2022 20:08:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448536; bh=5eKCVk5qd0asycbla6RyEsTQRSE7pFO3ajyfmUWIWH4=; h=Date:To:From:In-Reply-To:Subject:From; b=kSQZn0X3m8sgM/Ekjkg8XuUrnISN5jHemzWax+Jd6SmKxcnKy9jjhSO2JDALqZEoR aWrMu9H0S6rjAhEw/d8SQm1uIfHorPI1bafdITzFRp2fBDmi0sf4qGL0dL76bYTl6Y penRUT2eyFfaGTjM1SgjSS5vlztHRFd1AXvdlVuo= Date: Fri, 08 Apr 2022 13:08:55 -0700 To: tglx@linutronix.de,stable@vger.kernel.org,peterz@infradead.org,jcmvbkbc@gmail.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 2/9] highmem: fix checks in __kmap_local_sched_{in,out} Message-Id: <20220408200856.602F9C385A6@smtp.kernel.org> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D6EDE180009 X-Rspam-User: Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=kSQZn0X3; dmarc=none; spf=pass (imf24.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: 13dxswjz97mjawo8ppuqr9j5tq7fyfgd X-HE-Tag: 1649448537-308893 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: From: Max Filippov Subject: highmem: fix checks in __kmap_local_sched_{in,out} When CONFIG_DEBUG_KMAP_LOCAL is enabled __kmap_local_sched_{in,out} check that even slots in the tsk->kmap_ctrl.pteval are unmapped. The slots are initialized with 0 value, but the check is done with pte_none. 0 pte however does not necessarily mean that pte_none will return true. e.g. on xtensa it returns false, resulting in the following runtime warnings: WARNING: CPU: 0 PID: 101 at mm/highmem.c:627 __kmap_local_sched_out+0x51/0x108 CPU: 0 PID: 101 Comm: touch Not tainted 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_out+0x51/0x108 __schedule+0x71a/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f WARNING: CPU: 0 PID: 101 at mm/highmem.c:664 __kmap_local_sched_in+0x50/0xe0 CPU: 0 PID: 101 Comm: touch Tainted: G W 5.17.0-rc7-00010-gd3a1cdde80d2-dirty #13 Call Trace: dump_stack+0xc/0x40 __warn+0x8f/0x174 warn_slowpath_fmt+0x48/0xac __kmap_local_sched_in+0x50/0xe0 finish_task_switch$isra$0+0x1ce/0x2f8 __schedule+0x86e/0x9c4 preempt_schedule_irq+0xa0/0xe0 common_exception_return+0x5c/0x93 do_wp_page+0x30e/0x330 handle_mm_fault+0xa70/0xc3c do_page_fault+0x1d8/0x3c4 common_exception+0x7f/0x7f Fix it by replacing !pte_none(pteval) with pte_val(pteval) != 0. Link: https://lkml.kernel.org/r/20220403235159.3498065-1-jcmvbkbc@gmail.com Fixes: 5fbda3ecd14a ("sched: highmem: Store local kmaps in task struct") Signed-off-by: Max Filippov Reviewed-by: Thomas Gleixner Cc: "Peter Zijlstra (Intel)" Cc: Signed-off-by: Andrew Morton --- mm/highmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/highmem.c~highmem-fix-checks-in-__kmap_local_sched_inout +++ a/mm/highmem.c @@ -624,7 +624,7 @@ void __kmap_local_sched_out(void) /* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL) && !(i & 0x01)) { - WARN_ON_ONCE(!pte_none(pteval)); + WARN_ON_ONCE(pte_val(pteval) != 0); continue; } if (WARN_ON_ONCE(pte_none(pteval))) @@ -661,7 +661,7 @@ void __kmap_local_sched_in(void) /* With debug all even slots are unmapped and act as guard */ if (IS_ENABLED(CONFIG_DEBUG_KMAP_LOCAL) && !(i & 0x01)) { - WARN_ON_ONCE(!pte_none(pteval)); + WARN_ON_ONCE(pte_val(pteval) != 0); continue; } if (WARN_ON_ONCE(pte_none(pteval))) From patchwork Fri Apr 8 20:08:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807181 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 69C59C433F5 for ; Fri, 8 Apr 2022 20:09:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6A416B0075; Fri, 8 Apr 2022 16:09:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B19856B0078; Fri, 8 Apr 2022 16:09:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A092F6B007B; Fri, 8 Apr 2022 16:09:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0251.hostedemail.com [216.40.44.251]) by kanga.kvack.org (Postfix) with ESMTP id 92B276B0075 for ; Fri, 8 Apr 2022 16:09:01 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 493B0183CB077 for ; Fri, 8 Apr 2022 20:09:01 +0000 (UTC) X-FDA: 79334800482.25.EA4B9D2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id CF91440002 for ; Fri, 8 Apr 2022 20:09:00 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 2BFC861E28; Fri, 8 Apr 2022 20:09:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80FFFC385A6; Fri, 8 Apr 2022 20:08:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448539; bh=5no2esH8/58mNWM6tktmP1+A/Rk1YVrxTuyDg3i895M=; h=Date:To:From:In-Reply-To:Subject:From; b=wPFVz06gIltEbF4SwvZPdcxkjMSNpicE1XOusXECnALO1GCNQDvkljk8qVDtDkvO4 sVXkvFb9/G/7BoD23GDUxEz4BW5eqpeuRRXtCqW1n7/7yz3jj/NdLcXR9pdbc1jwh1 Va1HCDbksZFeSRGgr3PriZZWmRDw/mIS6J9Zz6wU= Date: Fri, 08 Apr 2022 13:08:58 -0700 To: terrelln@fb.com,stable@vger.kernel.org,hsiangkao@linux.alibaba.com,cy.fan@huawei.com,cyan@fb.com,guoxuenan@huawei.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 3/9] lz4: fix LZ4_decompress_safe_partial read out of bound Message-Id: <20220408200859.80FFFC385A6@smtp.kernel.org> X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: 8dtqejwwa7fkii3qpzgqazzdburr857q Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=wPFVz06g; dmarc=none; spf=pass (imf11.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Queue-Id: CF91440002 X-HE-Tag: 1649448540-692423 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: From: Guo Xuenan Subject: lz4: fix LZ4_decompress_safe_partial read out of bound When partialDecoding, it is EOF if we've either filled the output buffer or can't proceed with reading an offset for following match. In some extreme corner cases when compressed data is suitably corrupted, UAF will occur. As reported by KASAN [1], LZ4_decompress_safe_partial may lead to read out of bound problem during decoding. lz4 upstream has fixed it [2] and this issue has been disscussed here [3] before. current decompression routine was ported from lz4 v1.8.3, bumping lib/lz4 to v1.9.+ is certainly a huge work to be done later, so, we'd better fix it first. [1] https://lore.kernel.org/all/000000000000830d1205cf7f0477@google.com/ [2] https://github.com/lz4/lz4/commit/c5d6f8a8be3927c0bec91bcc58667a6cfad244ad# [3] https://lore.kernel.org/all/CC666AE8-4CA4-4951-B6FB-A2EFDE3AC03B@fb.com/ Link: https://lkml.kernel.org/r/20211111105048.2006070-1-guoxuenan@huawei.com Reported-by: syzbot+63d688f1d899c588fb71@syzkaller.appspotmail.com Signed-off-by: Guo Xuenan Reviewed-by: Nick Terrell Acked-by: Gao Xiang Cc: Yann Collet Cc: Chengyang Fan Cc: Signed-off-by: Andrew Morton --- lib/lz4/lz4_decompress.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/lib/lz4/lz4_decompress.c~lz4-fix-lz4_decompress_safe_partial-read-out-of-bound +++ a/lib/lz4/lz4_decompress.c @@ -271,8 +271,12 @@ static FORCE_INLINE int LZ4_decompress_g ip += length; op += length; - /* Necessarily EOF, due to parsing restrictions */ - if (!partialDecoding || (cpy == oend)) + /* Necessarily EOF when !partialDecoding. + * When partialDecoding, it is EOF if we've either + * filled the output buffer or + * can't proceed with reading an offset for following match. + */ + if (!partialDecoding || (cpy == oend) || (ip >= (iend - 2))) break; } else { /* may overwrite up to WILDCOPYLENGTH beyond cpy */ From patchwork Fri Apr 8 20:09:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807182 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 D0A5DC433EF for ; Fri, 8 Apr 2022 20:09:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 688526B0078; Fri, 8 Apr 2022 16:09:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6379F6B007B; Fri, 8 Apr 2022 16:09:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 526936B007D; Fri, 8 Apr 2022 16:09:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 456846B0078 for ; Fri, 8 Apr 2022 16:09:04 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 05932AAAEF for ; Fri, 8 Apr 2022 20:09:04 +0000 (UTC) X-FDA: 79334800608.28.D3114C3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 8D876140002 for ; Fri, 8 Apr 2022 20:09:03 +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 dfw.source.kernel.org (Postfix) with ESMTPS id DC6A261E34; Fri, 8 Apr 2022 20:09:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A24A9C385A1; Fri, 8 Apr 2022 20:09:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448542; bh=1D5SNOl6vvFu+GH5I4nM3QG8zMSCIzlqq33jmIn00rY=; h=Date:To:From:In-Reply-To:Subject:From; b=JFIMt77G/CUtogZOfqqpqnjfUyK6QnR9dR7aH1PwzhfDeNOZ8fzsbUHoJEHb9vwKF c56IauoTAlHkHqgzk7Jo0P57+5BNgC0XVweFo5sh02XR/xG940GjZEWRgaB+ap5Jsr yZ9s4zMVQ6lLj26x6XoEVg12KzPUZuM7gUy0D8y0= Date: Fri, 08 Apr 2022 13:09:01 -0700 To: mingo@kernel.org,kirill.shutemov@linux.intel.com,jforbes@redhat.com,aquini@redhat.com,longman@redhat.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 4/9] mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning Message-Id: <20220408200902.A24A9C385A1@smtp.kernel.org> Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=JFIMt77G; spf=pass (imf23.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Stat-Signature: yxsxw6xb6zwxwkj88nbj53r9719aczyh X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8D876140002 X-HE-Tag: 1649448543-521978 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: From: Waiman Long Subject: mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning The gcc 12 compiler reports a "'mem_section' will never be NULL" warning on the following code: static inline struct mem_section *__nr_to_section(unsigned long nr) { #ifdef CONFIG_SPARSEMEM_EXTREME if (!mem_section) return NULL; #endif if (!mem_section[SECTION_NR_TO_ROOT(nr)]) return NULL; : It happens with CONFIG_SPARSEMEM_EXTREME off. The mem_section definition is #ifdef CONFIG_SPARSEMEM_EXTREME extern struct mem_section **mem_section; #else extern struct mem_section mem_section[NR_SECTION_ROOTS][SECTIONS_PER_ROOT]; #endif In the !CONFIG_SPARSEMEM_EXTREME case, mem_section is a static 2-dimensional array and so the check "!mem_section[SECTION_NR_TO_ROOT(nr)]" doesn't make sense. Fix this warning by moving the "!mem_section[SECTION_NR_TO_ROOT(nr)]" check up inside the CONFIG_SPARSEMEM_EXTREME block and adding an explicit NR_SECTION_ROOTS check to make sure that there is no out-of-bound array access. Link: https://lkml.kernel.org/r/20220331180246.2746210-1-longman@redhat.com Fixes: 3e347261a80b ("sparsemem extreme implementation") Signed-off-by: Waiman Long Reported-by: Justin Forbes Cc: "Kirill A . Shutemov" Cc: Ingo Molnar Cc: Rafael Aquini Signed-off-by: Andrew Morton Reviewed-by: Oscar Salvador --- include/linux/mmzone.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/include/linux/mmzone.h~mm-sparsemem-fix-mem_section-will-never-be-null-gcc-12-warning +++ a/include/linux/mmzone.h @@ -1397,13 +1397,16 @@ static inline unsigned long *section_to_ static inline struct mem_section *__nr_to_section(unsigned long nr) { + unsigned long root = SECTION_NR_TO_ROOT(nr); + + if (unlikely(root >= NR_SECTION_ROOTS)) + return NULL; + #ifdef CONFIG_SPARSEMEM_EXTREME - if (!mem_section) + if (!mem_section || !mem_section[root]) return NULL; #endif - if (!mem_section[SECTION_NR_TO_ROOT(nr)]) - return NULL; - return &mem_section[SECTION_NR_TO_ROOT(nr)][nr & SECTION_ROOT_MASK]; + return &mem_section[root][nr & SECTION_ROOT_MASK]; } extern size_t mem_section_usage_size(void); From patchwork Fri Apr 8 20:09:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807183 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 07795C433EF for ; Fri, 8 Apr 2022 20:09:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 947116B007D; Fri, 8 Apr 2022 16:09:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91DFB6B007E; Fri, 8 Apr 2022 16:09:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E6166B0080; Fri, 8 Apr 2022 16:09:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 708D76B007D for ; Fri, 8 Apr 2022 16:09:09 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 461CD22DF4 for ; Fri, 8 Apr 2022 20:09:09 +0000 (UTC) X-FDA: 79334800818.11.E87AB9B Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf04.hostedemail.com (Postfix) with ESMTP id B1AD340003 for ; Fri, 8 Apr 2022 20:09:08 +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 D4EF8B82D64; Fri, 8 Apr 2022 20:09:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 943B7C385A5; Fri, 8 Apr 2022 20:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448545; bh=Uwe61k3TCdIIAb9jWMhOFX99NiRwkoxxsB+Q7xD3Mck=; h=Date:To:From:In-Reply-To:Subject:From; b=vP/PnsHIBa1QkY85u2AzCWADg8BR56BgOHgbNPxvhlodwAHV2uFg+4GZaQnYjzxR7 yTGwqWwXKwNBQeH/KgPabxhmHs3C/yGHkHOxAjQusbesROJyu/SMVuFs3OGvcXXsTI WxKEvc8QjUp4poAk0vPDkxfNm2Euhwq6YXdQ791g= Date: Fri, 08 Apr 2022 13:09:04 -0700 To: stable@vger.kernel.org,seanjc@google.com,pbonzini@redhat.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 5/9] mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) Message-Id: <20220408200905.943B7C385A5@smtp.kernel.org> X-Stat-Signature: xxo8epgcabfiuzs4pciu3oi4k4upypkd Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="vP/PnsHI"; spf=pass (imf04.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: B1AD340003 X-HE-Tag: 1649448548-349809 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000014, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Paolo Bonzini Subject: mmmremap.c: avoid pointless invalidate_range_start/end on mremap(old_size=0) If an mremap() syscall with old_size=0 ends up in move_page_tables(), it will call invalidate_range_start()/invalidate_range_end() unnecessarily, i.e. with an empty range. This causes a WARN in KVM's mmu_notifier. In the past, empty ranges have been diagnosed to be off-by-one bugs, hence the WARNing. Given the low (so far) number of unique reports, the benefits of detecting more buggy callers seem to outweigh the cost of having to fix cases such as this one, where userspace is doing something silly. In this particular case, an early return from move_page_tables() is enough to fix the issue. Link: https://lkml.kernel.org/r/20220329173155.172439-1-pbonzini@redhat.com Reported-by: syzbot+6bde52d89cfdf9f61425@syzkaller.appspotmail.com Signed-off-by: Paolo Bonzini Cc: Sean Christopherson Cc: Signed-off-by: Andrew Morton --- mm/mremap.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/mremap.c~mm-avoid-pointless-invalidate_range_start-end-on-mremapold_size=0 +++ a/mm/mremap.c @@ -486,6 +486,9 @@ unsigned long move_page_tables(struct vm pmd_t *old_pmd, *new_pmd; pud_t *old_pud, *new_pud; + if (!len) + return 0; + old_end = old_addr + len; flush_cache_range(vma, old_addr, old_end); From patchwork Fri Apr 8 20:09:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807184 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 675E3C433EF for ; Fri, 8 Apr 2022 20:09:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0210E6B007E; Fri, 8 Apr 2022 16:09:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE9E76B0080; Fri, 8 Apr 2022 16:09:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD9F46B0081; Fri, 8 Apr 2022 16:09:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id CEAE66B007E for ; Fri, 8 Apr 2022 16:09:11 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AF97126201 for ; Fri, 8 Apr 2022 20:09:11 +0000 (UTC) X-FDA: 79334800902.09.8C92EDA Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf30.hostedemail.com (Postfix) with ESMTP id 249D380006 for ; Fri, 8 Apr 2022 20:09:10 +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 E4E8CB82D20; Fri, 8 Apr 2022 20:09:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C9E9C385A3; Fri, 8 Apr 2022 20:09:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448548; bh=jK5P+S6TBH7YF6w0YeGEccKrveX9Q4CJhIMJxTVHP90=; h=Date:To:From:In-Reply-To:Subject:From; b=D/XdaMbmMx64cu2oQEP24nMEBtaFtmZ3s/GL8tOuuyCDohC13dt16JJDbli9OhYMD wOISBiKU/I7QQsy2/fKUKl8TThyurnLdeRtNjchDLEM6+hdl8lcHT4FWGH7qgzqFhi YJXVgeoYbZChXYf6JXdFtrreg788lYzTk8FsHxno= Date: Fri, 08 Apr 2022 13:09:07 -0700 To: stable@vger.kernel.org,mhocko@suse.com,mgorman@suse.de,kosaki.motohiro@jp.fujitsu.com,linmiaohe@huawei.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 6/9] mm/mempolicy: fix mpol_new leak in shared_policy_replace Message-Id: <20220408200908.9C9E9C385A3@smtp.kernel.org> Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="D/XdaMbm"; spf=pass (imf30.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 249D380006 X-Stat-Signature: ewz7pxx456h8pd6dufduwcuqgkcosi6s X-HE-Tag: 1649448550-170603 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: From: Miaohe Lin Subject: mm/mempolicy: fix mpol_new leak in shared_policy_replace If mpol_new is allocated but not used in restart loop, mpol_new will be freed via mpol_put before returning to the caller. But refcnt is not initialized yet, so mpol_put could not do the right things and might leak the unused mpol_new. This would happen if mempolicy was updated on the shared shmem file while the sp->lock has been dropped during the memory allocation. This issue could be triggered easily with the below code snippet if there are many processes doing the below work at the same time: shmid = shmget((key_t)5566, 1024 * PAGE_SIZE, 0666|IPC_CREAT); shm = shmat(shmid, 0, 0); loop many times { mbind(shm, 1024 * PAGE_SIZE, MPOL_LOCAL, mask, maxnode, 0); mbind(shm + 128 * PAGE_SIZE, 128 * PAGE_SIZE, MPOL_DEFAULT, mask, maxnode, 0); } Link: https://lkml.kernel.org/r/20220329111416.27954-1-linmiaohe@huawei.com Fixes: 42288fe366c4 ("mm: mempolicy: Convert shared_policy mutex to spinlock") Signed-off-by: Miaohe Lin Acked-by: Michal Hocko Cc: KOSAKI Motohiro Cc: Mel Gorman Cc: [3.8] Signed-off-by: Andrew Morton --- mm/mempolicy.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/mempolicy.c~mm-mempolicy-fix-mpol_new-leak-in-shared_policy_replace +++ a/mm/mempolicy.c @@ -2733,6 +2733,7 @@ alloc_new: mpol_new = kmem_cache_alloc(policy_cache, GFP_KERNEL); if (!mpol_new) goto err_out; + atomic_set(&mpol_new->refcnt, 1); goto restart; } From patchwork Fri Apr 8 20:09:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807185 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 31803C4332F for ; Fri, 8 Apr 2022 20:09:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B429B6B0080; Fri, 8 Apr 2022 16:09:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF2E86B0081; Fri, 8 Apr 2022 16:09:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 96C536B0082; Fri, 8 Apr 2022 16:09:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0169.hostedemail.com [216.40.44.169]) by kanga.kvack.org (Postfix) with ESMTP id 897036B0080 for ; Fri, 8 Apr 2022 16:09:13 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D8868249980 for ; Fri, 8 Apr 2022 20:09:13 +0000 (UTC) X-FDA: 79334800986.26.CF5F346 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id C94EA1C0005 for ; Fri, 8 Apr 2022 20:09:12 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 2C38161E3F; Fri, 8 Apr 2022 20:09:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 840A2C385A3; Fri, 8 Apr 2022 20:09:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448551; bh=INxKj1/Eanumd3G10GxRywr5ChlEaetXXPiQm7G9d88=; h=Date:To:From:In-Reply-To:Subject:From; b=z+f5MKcgHh3a6wz7x5/NIrVot0I3Rb+4K//+4efkNJ0PSiTiaTuahUUB4EmM//drT CgboOeLOm2qVgSQD1RQNPjGUJh9iPqs9X5x48klF3SYiXg/wLohu7Pvh1pbPnMDrB/ EpT6v9YMd4MWd+MlMeQGakFbZhVK4jSSM67lMQ+s= Date: Fri, 08 Apr 2022 13:09:10 -0700 To: vasily.averin@linux.dev,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 7/9] mailmap: update Vasily Averin's email address Message-Id: <20220408200911.840A2C385A3@smtp.kernel.org> X-Stat-Signature: 76un33pn8nc45x79887ea8towtbsqiw8 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C94EA1C0005 Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=z+f5MKcg; dmarc=none; spf=pass (imf21.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspam-User: X-HE-Tag: 1649448552-837996 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: From: Vasily Averin Subject: mailmap: update Vasily Averin's email address I'm moving to a @linux.dev account. Map my old addresses. Link: https://lkml.kernel.org/r/737c7c2b-cdab-63ee-be90-cb33316c9657@linux.dev Signed-off-by: Vasily Averin Signed-off-by: Andrew Morton --- .mailmap | 4 ++++ 1 file changed, 4 insertions(+) --- a/.mailmap~mailmap-update-vasily-averins-email-address +++ a/.mailmap @@ -391,6 +391,10 @@ Uwe Kleine-König Uwe Kleine-König Uwe Kleine-König Valdis Kletnieks +Vasily Averin +Vasily Averin +Vasily Averin +Vasily Averin Vinod Koul Vinod Koul Vinod Koul From patchwork Fri Apr 8 20:09:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807186 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 C0A67C4321E for ; Fri, 8 Apr 2022 20:09:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 613626B0072; Fri, 8 Apr 2022 16:09:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C1CF6B0081; Fri, 8 Apr 2022 16:09:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B1416B0082; Fri, 8 Apr 2022 16:09:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 3D5D96B0072 for ; Fri, 8 Apr 2022 16:09:18 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1087220A1A for ; Fri, 8 Apr 2022 20:09:18 +0000 (UTC) X-FDA: 79334801196.07.57ABB1B Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf03.hostedemail.com (Postfix) with ESMTP id 6E36C20005 for ; Fri, 8 Apr 2022 20:09:17 +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 09449B82D69; Fri, 8 Apr 2022 20:09:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7C6C3C385A3; Fri, 8 Apr 2022 20:09:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448554; bh=CqgdUQ8KtmQ/Yioj4EEH5I++u5nh/s1yL09Oz1Ljgus=; h=Date:To:From:In-Reply-To:Subject:From; b=lurkYQeuelUK9MzaQvPWE59Mc2SYGwBMwF5zstmCGj2AAUTY2zxII0D/2B+TR6M+t zGJp1GhQsY6gZYogUUO5cUbUahD0DTXo1pShk8RZSvHH4Wz7RN/Y/QLrLdxRKyBIG8 Cvy8rjaytF8h3A10SHPnJ1U31nUmg3pN3jOf9ZOw= Date: Fri, 08 Apr 2022 13:09:13 -0700 To: songmuchun@bytedance.com,shakeelb@google.com,roman.gushchin@linux.dev,mhocko@suse.com,longman@redhat.com,hannes@cmpxchg.org,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 8/9] mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()" Message-Id: <20220408200914.7C6C3C385A3@smtp.kernel.org> X-Rspam-User: Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=lurkYQeu; spf=pass (imf03.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 6E36C20005 X-Stat-Signature: abq4rhnt1gwo8zzbbjf1j74kps7cffeo X-HE-Tag: 1649448557-209252 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: From: Andrew Morton Subject: mm/list_lru.c: revert "mm/list_lru: optimize memcg_reparent_list_lru_node()" 405cc51fc1049c73 ("mm/list_lru: optimize memcg_reparent_list_lru_node()") has subtle races which are proving ugly to fix. Revert the original optimization. If quantitative testing indicates that we have a significant problem here then other implementations can be looked at. Fixes: 405cc51fc1049c73 ("mm/list_lru: optimize memcg_reparent_list_lru_node()") Acked-by: Shakeel Butt Reviewed-by: Muchun Song Acked-by: Michal Hocko Cc: Waiman Long Cc: Roman Gushchin Cc: Johannes Weiner Signed-off-by: Andrew Morton --- mm/list_lru.c | 6 ------ 1 file changed, 6 deletions(-) --- a/mm/list_lru.c~mm-list_lruc-revert-mm-list_lru-optimize-memcg_reparent_list_lru_node +++ a/mm/list_lru.c @@ -395,12 +395,6 @@ static void memcg_reparent_list_lru_node struct list_lru_one *src, *dst; /* - * If there is no lru entry in this nlru, we can skip it immediately. - */ - if (!READ_ONCE(nlru->nr_items)) - return; - - /* * Since list_lru_{add,del} may be called under an IRQ-safe lock, * we have to use IRQ-safe primitives here to avoid deadlock. */ From patchwork Fri Apr 8 20:09:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12807187 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 3CB3DC433F5 for ; Fri, 8 Apr 2022 20:09:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CF0186B0081; Fri, 8 Apr 2022 16:09:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CA0E26B0082; Fri, 8 Apr 2022 16:09:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8F0D6B0083; Fri, 8 Apr 2022 16:09:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id ABA8D6B0081 for ; Fri, 8 Apr 2022 16:09:20 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5ABEB8249980 for ; Fri, 8 Apr 2022 20:09:20 +0000 (UTC) X-FDA: 79334801280.25.D7C2C6A Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id D676D1A0002 for ; Fri, 8 Apr 2022 20:09:19 +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 BBA95B82B9B; Fri, 8 Apr 2022 20:09:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7876BC385A1; Fri, 8 Apr 2022 20:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1649448557; bh=Xj7cE8c6+xY8r3iB8wRucoyiEjHGn6UoRMQ8ZHjC4qU=; h=Date:To:From:In-Reply-To:Subject:From; b=Xb1qjYWWe2cWTbQOm/+KmsTDPsYPP49AlY6kiJh7y5QdJoAgeYb672TzoEV9SxN1p d9OZxHL6SH6KIXvxAEgTV6ekvTDQnUk+fjwcmEWPc/F2VQwc8Xjjkjjy/SVUFxSq17 2vzGSg1XwxWO9D60yHKARhteXIAkuyssVZ1fy+Z4= Date: Fri, 08 Apr 2022 13:09:16 -0700 To: ndesaulniers@google.com,nathan@kernel.org,trix@redhat.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220408130819.a89195e527ce58dfbe0700b9@linux-foundation.org> Subject: [patch 9/9] MAINTAINERS: add Tom as clang reviewer Message-Id: <20220408200917.7876BC385A1@smtp.kernel.org> X-Rspam-User: X-Stat-Signature: 4g9ca7chx4wz67up48be18updj8xs8zu Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=Xb1qjYWW; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: D676D1A0002 X-HE-Tag: 1649448559-922153 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: From: Tom Rix Subject: MAINTAINERS: add Tom as clang reviewer I have been helping with build breaks and other clang things and would like to help with the reviews. Link: https://lkml.kernel.org/r/20220407175715.3378998-1-trix@redhat.com Signed-off-by: Tom Rix Acked-by: Nathan Chancellor Acked-by: Nick Desaulniers Signed-off-by: Andrew Morton --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) --- a/MAINTAINERS~maintainers-add-self-as-clang-reviewer +++ a/MAINTAINERS @@ -4791,6 +4791,7 @@ F: .clang-format CLANG/LLVM BUILD SUPPORT M: Nathan Chancellor M: Nick Desaulniers +R: Tom Rix L: llvm@lists.linux.dev S: Supported W: https://clangbuiltlinux.github.io/