From patchwork Wed Apr 27 19:41:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12829457 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 2005AC433EF for ; Wed, 27 Apr 2022 19:42:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 570896B0073; Wed, 27 Apr 2022 15:42:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51E386B0074; Wed, 27 Apr 2022 15:42:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40DF46B0075; Wed, 27 Apr 2022 15:42:00 -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 2F8046B0073 for ; Wed, 27 Apr 2022 15:42:00 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 090C428910 for ; Wed, 27 Apr 2022 19:42:00 +0000 (UTC) X-FDA: 79403679600.14.04557BA Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf16.hostedemail.com (Postfix) with ESMTP id D024F18002C for ; Wed, 27 Apr 2022 19:41:55 +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 746F261BED; Wed, 27 Apr 2022 19:41:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F393C385A7; Wed, 27 Apr 2022 19:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651088517; bh=FzMaEt0ORKT14V9HyN2A3rQwOPnyIJUsEAiiAUmn1ow=; h=Date:To:From:In-Reply-To:Subject:From; b=AYxhAu9GR1UaXIaH8b+lS1CD0FklXZaCqihT922cdBzzEhD2SC8sbgUMPRUcBpkdX WP8thrukZpFvzkgiTArjsG4/e7MmLH3w6Fm4e1aZJ1ndY+TeNAGoS3+Lbx9cniZPNW giz/O0dkyoVzouuL+pH6n1Q2Km30wKNKESmTwPr8= Date: Wed, 27 Apr 2022 12:41:56 -0700 To: stable@vger.kernel.org,ryabinin.a.a@gmail.com,glider@google.com,dvyukov@google.com,andreyknvl@gmail.com,qiang1.zhang@intel.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: <20220427124133.cc115bc8acb8de3dda921836@linux-foundation.org> Subject: [patch 1/2] kasan: prevent cpu_quarantine corruption when CPU offline and cache shrink occur at same time Message-Id: <20220427194157.8F393C385A7@smtp.kernel.org> X-Stat-Signature: hne38zwebczj39z3ayt5zshm1w66a7hn X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: D024F18002C Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=AYxhAu9G; spf=pass (imf16.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-Rspam-User: X-HE-Tag: 1651088515-963085 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: Zqiang Subject: kasan: prevent cpu_quarantine corruption when CPU offline and cache shrink occur at same time kasan_quarantine_remove_cache() is called in kmem_cache_shrink()/ destroy(). The kasan_quarantine_remove_cache() call is protected by cpuslock in kmem_cache_destroy() to ensure serialization with kasan_cpu_offline(). However the kasan_quarantine_remove_cache() call is not protected by cpuslock in kmem_cache_shrink(). When a CPU is going offline and cache shrink occurs at same time, the cpu_quarantine may be corrupted by interrupt (per_cpu_remove_cache operation). So add a cpu_quarantine offline flags check in per_cpu_remove_cache(). [akpm@linux-foundation.org: add comment, per Zqiang] Link: https://lkml.kernel.org/r/20220414025925.2423818-1-qiang1.zhang@intel.com Signed-off-by: Zqiang Reviewed-by: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Signed-off-by: Andrew Morton --- mm/kasan/quarantine.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/mm/kasan/quarantine.c~kasan-prevent-cpu_quarantine-corruption-when-cpu-offline-and-cache-shrink-occur-at-same-time +++ a/mm/kasan/quarantine.c @@ -315,6 +315,13 @@ static void per_cpu_remove_cache(void *a struct qlist_head *q; q = this_cpu_ptr(&cpu_quarantine); + /* + * Ensure the ordering between the writing to q->offline and + * per_cpu_remove_cache. Prevent cpu_quarantine from being corrupted + * by interrupt. + */ + if (READ_ONCE(q->offline)) + return; qlist_move_cache(q, &to_free, cache); qlist_free_all(&to_free, cache); } From patchwork Wed Apr 27 19:41:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12829458 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 4F475C433F5 for ; Wed, 27 Apr 2022 19:42:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A52246B0074; Wed, 27 Apr 2022 15:42:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D8F56B0075; Wed, 27 Apr 2022 15:42:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C8426B0078; Wed, 27 Apr 2022 15:42:02 -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 7DC416B0074 for ; Wed, 27 Apr 2022 15:42:02 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 3B14F81698 for ; Wed, 27 Apr 2022 19:42:02 +0000 (UTC) X-FDA: 79403679684.05.AE96E86 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 0CB3140058 for ; Wed, 27 Apr 2022 19:41:58 +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 404A261BEF; Wed, 27 Apr 2022 19:42:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 925CFC385A9; Wed, 27 Apr 2022 19:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1651088520; bh=Z0vz/2W6qPtjAA116S7QHDmsmc8iimqdYnZa8QLU2dc=; h=Date:To:From:In-Reply-To:Subject:From; b=DwdrLUSjCXZyjZVJvdB1mIGdieEPiFgF7uy9DuR8FLL58hiCZf+Lr/MVcCmguTsZH wpgdwjCoQsFHRUeEx4o68sasmGJk9VhHQJ9/wN8m/OZn9xkBinJVbXLjee1SaBniMH G83XrFDn0xBWzj2XNxqkfXNiv4twWfsSJquoQXnw= Date: Wed, 27 Apr 2022 12:41:59 -0700 To: seakeel@gmail.com,hanshenghong2019@email.szu.edu.cn,corbet@lwn.net,baihaowen@meizu.com,akiyks@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: <20220427124133.cc115bc8acb8de3dda921836@linux-foundation.org> Subject: [patch 2/2] docs: vm/page_owner: use literal blocks for param description Message-Id: <20220427194200.925CFC385A9@smtp.kernel.org> X-Stat-Signature: 57iuoqdbgrydxih4dk8chwqewc9kmyi6 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0CB3140058 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=DwdrLUSj; 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-HE-Tag: 1651088518-665266 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: Akira Yokosawa Subject: docs: vm/page_owner: use literal blocks for param description Sphinx generates hard-to-read lists of parameters at the bottom of the page. Fix them by putting literal-block markers of "::" in front of them. Link: https://lkml.kernel.org/r/cfd3bcc0-b51d-0c68-c065-ca1c4c202447@gmail.com Signed-off-by: Akira Yokosawa Fixes: 57f2b54a9379 ("Documentation/vm/page_owner.rst: update the documentation") Cc: Shenghong Han Cc: Haowen Bai Cc: Jonathan Corbet Cc: Alex Shi Signed-off-by: Andrew Morton --- Documentation/vm/page_owner.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/Documentation/vm/page_owner.rst~docs-vm-page_owner-use-literal-blocks-for-param-description +++ a/Documentation/vm/page_owner.rst @@ -110,7 +110,7 @@ Usage If you want to sort by the page nums of buf, use the ``-m`` parameter. The detailed parameters are: - fundamental function: + fundamental function:: Sort: -a Sort by memory allocation time. @@ -122,7 +122,7 @@ Usage -s Sort by stack trace. -t Sort by times (default). - additional function: + additional function:: Cull: --cull @@ -153,6 +153,7 @@ Usage STANDARD FORMAT SPECIFIERS ========================== +:: KEY LONG DESCRIPTION p pid process ID