From patchwork Fri Dec 11 21:36:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 94E31C4361B for ; Fri, 11 Dec 2020 21:36:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 15EE7233A2 for ; Fri, 11 Dec 2020 21:36:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15EE7233A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9F0DD6B005D; Fri, 11 Dec 2020 16:36:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9C71A6B0068; Fri, 11 Dec 2020 16:36:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 905756B006C; Fri, 11 Dec 2020 16:36:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id 7AAD46B005D for ; Fri, 11 Dec 2020 16:36:31 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 42E92181AF5E1 for ; Fri, 11 Dec 2020 21:36:31 +0000 (UTC) X-FDA: 77582310582.28.coat73_530863127404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 267866C13 for ; Fri, 11 Dec 2020 21:36:31 +0000 (UTC) X-HE-Tag: coat73_530863127404 X-Filterd-Recvd-Size: 2608 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:30 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722589; bh=dy/vexMOeot19V8Dqiad/cPmps1LRViBmFF4Y0w7Dn0=; h=From:To:Subject:In-Reply-To:From; b=EFf7Kworho4zlMbTXZUcKgbrF84obgXaKxCV3F2mjtjoSgAuJLvt2oA1aZME9ToYv 4lKAxNrP4koGstnsoG8aX6XT80zemvVHA52aKgMPSW8OhTGvITxsmNXQRMs7EkiAm2 qToYSFM1pCIV6EQlrk/TTjLxh/BN7UEoBt3t38uI= From: Andrew Morton To: akpm@linux-foundation.org, alex.shi@linux.alibaba.com, ast@kernel.org, daniel@iogearbox.net, gthelen@google.com, jmforbes@linuxtx.org, josef@toxicpanda.com, jrdr.linux@gmail.com, linux-mm@kvack.org, mkubecek@suse.cz, mm-commits@vger.kernel.org, tony.luck@gmail.com, torvalds@linux-foundation.org Subject: [patch 1/8] revert "mm/filemap: add static for function __add_to_page_cache_locked" Message-ID: <20201211213627.Y0ZoNFaFt%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: revert "mm/filemap: add static for function __add_to_page_cache_locked" Revert 3351b16af494 ("mm/filemap: add static for function __add_to_page_cache_locked") due to incompatibility with ALLOW_ERROR_INJECTION which result in build errors. Link: https://lkml.kernel.org/r/CAADnVQJ6tmzBXvtroBuEH6QA0H+q7yaSKxrVvVxhqr3KBZdEXg@mail.gmail.com Tested-by: Justin Forbes Tested-by: Greg Thelen Acked-by: Alexei Starovoitov Cc: Michal Kubecek Cc: Alex Shi Cc: Souptick Joarder Cc: Daniel Borkmann Cc: Josef Bacik Cc: Tony Luck Signed-off-by: Andrew Morton --- mm/filemap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/filemap.c~revert-mm-filemap-add-static-for-function-__add_to_page_cache_locked +++ a/mm/filemap.c @@ -827,7 +827,7 @@ int replace_page_cache_page(struct page } EXPORT_SYMBOL_GPL(replace_page_cache_page); -static noinline int __add_to_page_cache_locked(struct page *page, +noinline int __add_to_page_cache_locked(struct page *page, struct address_space *mapping, pgoff_t offset, gfp_t gfp, void **shadowp) From patchwork Fri Dec 11 21:36:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAF25C433FE for ; Fri, 11 Dec 2020 21:36:35 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4504A233A2 for ; Fri, 11 Dec 2020 21:36:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4504A233A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CFF926B0068; Fri, 11 Dec 2020 16:36:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C86816B006C; Fri, 11 Dec 2020 16:36:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9D466B006E; Fri, 11 Dec 2020 16:36:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id A33BF6B0068 for ; Fri, 11 Dec 2020 16:36:34 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 73003181AF5E1 for ; Fri, 11 Dec 2020 21:36:34 +0000 (UTC) X-FDA: 77582310708.04.honey97_141355b27404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 534B68019AAA for ; Fri, 11 Dec 2020 21:36:34 +0000 (UTC) X-HE-Tag: honey97_141355b27404 X-Filterd-Recvd-Size: 5431 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:33 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:31 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722592; bh=YTf/PmR8Znq9clmsPA1iOQkRargopVxOv9kb4NwAS7E=; h=From:To:Subject:In-Reply-To:From; b=nd21thy/eg+Xkx5Vn3N7D2EgIqY4NhFvzuQ3PkbdbrgFZxGe7s5lYgmpxk2+YyI2K EvgSHyncESQOORTbI0SPgFTp9VNwa7B3qWiRNTQ9dlEOWf6ehPpUwbMnyOYOA37Ezj 1iCxadW22T9d7hTtBxlkMAsXnrSdpcC00wBcDdkw= From: Andrew Morton To: adobriyan@gmail.com, akpm@linux-foundation.org, andreyknvl@google.com, aryabinin@virtuozzo.com, catalin.marinas@arm.com, dvyukov@google.com, ebiederm@xmission.com, elver@google.com, glider@google.com, linux-mm@kvack.org, miles.chen@mediatek.com, mm-commits@vger.kernel.org, song.bao.hua@hisilicon.com, stable@vger.kernel.org, torvalds@linux-foundation.org, vincenzo.frascino@arm.com, will@kernel.org Subject: [patch 2/8] proc: use untagged_addr() for pagemap_read addresses Message-ID: <20201211213631.mzQwOXkXF%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Miles Chen Subject: proc: use untagged_addr() for pagemap_read addresses When we try to visit the pagemap of a tagged userspace pointer, we find that the start_vaddr is not correct because of the tag. To fix it, we should untag the userspace pointers in pagemap_read(). I tested with 5.10-rc4 and the issue remains. Explanation from Catalin in [1]: :Arguably, that's a user-space bug since tagged file offsets were never :supported. In this case it's not even a tag at bit 56 as per the arm64 :tagged address ABI but rather down to bit 47. You could say that the :problem is caused by the C library (malloc()) or whoever created the :tagged vaddr and passed it to this function. It's not a kernel :regression as we've never supported it. : :Now, pagemap is a special case where the offset is usually not generated :as a classic file offset but rather derived by shifting a user virtual :address. I guess we can make a concession for pagemap (only) and allow :such offset with the tag at bit (56 - PAGE_SHIFT + 3). My test code is based on [2]: A userspace pointer which has been tagged by 0xb4: 0xb400007662f541c8 === userspace program === uint64 OsLayer::VirtualToPhysical(void *vaddr) { uint64 frame, paddr, pfnmask, pagemask; int pagesize = sysconf(_SC_PAGESIZE); off64_t off = ((uintptr_t)vaddr) / pagesize * 8; // off = 0xb400007662f541c8 / pagesize * 8 = 0x5a00003b317aa0 int fd = open(kPagemapPath, O_RDONLY); ... if (lseek64(fd, off, SEEK_SET) != off || read(fd, &frame, 8) != 8) { int err = errno; string errtxt = ErrorString(err); if (fd >= 0) close(fd); return 0; } ... } === kernel fs/proc/task_mmu.c === static ssize_t pagemap_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { ... src = *ppos; svpfn = src / PM_ENTRY_BYTES; // svpfn == 0xb400007662f54 start_vaddr = svpfn << PAGE_SHIFT; // start_vaddr == 0xb400007662f54000 end_vaddr = mm->task_size; /* watch out for wraparound */ // svpfn == 0xb400007662f54 // (mm->task_size >> PAGE) == 0x8000000 if (svpfn > mm->task_size >> PAGE_SHIFT) // the condition is true because of the tag 0xb4 start_vaddr = end_vaddr; ret = 0; while (count && (start_vaddr < end_vaddr)) { // we cannot visit correct entry because start_vaddr is set to end_vaddr int len; unsigned long end; ... } ... } [1] https://lore.kernel.org/patchwork/patch/1343258/ [2] https://github.com/stressapptest/stressapptest/blob/master/src/os.cc#L158 Link: https://lkml.kernel.org/r/20201204024347.8295-1-miles.chen@mediatek.com Signed-off-by: Miles Chen Reviewed-by: Vincenzo Frascino Reviewed-by: Catalin Marinas Cc: Alexey Dobriyan Cc: Andrey Konovalov Cc: Alexander Potapenko Cc: Vincenzo Frascino Cc: Andrey Ryabinin Cc: Catalin Marinas Cc: Dmitry Vyukov Cc: Marco Elver Cc: Will Deacon Cc: Eric W. Biederman Cc: Song Bao Hua (Barry Song) Cc: [5.4-] Signed-off-by: Andrew Morton --- fs/proc/task_mmu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/fs/proc/task_mmu.c~proc-use-untagged_addr-for-pagemap_read-addresses +++ a/fs/proc/task_mmu.c @@ -1599,11 +1599,15 @@ static ssize_t pagemap_read(struct file src = *ppos; svpfn = src / PM_ENTRY_BYTES; - start_vaddr = svpfn << PAGE_SHIFT; end_vaddr = mm->task_size; /* watch out for wraparound */ - if (svpfn > mm->task_size >> PAGE_SHIFT) + start_vaddr = end_vaddr; + if (svpfn <= (ULONG_MAX >> PAGE_SHIFT)) + start_vaddr = untagged_addr(svpfn << PAGE_SHIFT); + + /* Ensure the address is inside the task */ + if (start_vaddr > mm->task_size) start_vaddr = end_vaddr; /* From patchwork Fri Dec 11 21:36:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3945DC4361B for ; Fri, 11 Dec 2020 21:36:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B704223372 for ; Fri, 11 Dec 2020 21:36:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B704223372 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3B0C06B006C; Fri, 11 Dec 2020 16:36:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 386476B006E; Fri, 11 Dec 2020 16:36:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 274B36B0070; Fri, 11 Dec 2020 16:36:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id 109696B006C for ; Fri, 11 Dec 2020 16:36:38 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id D23202496 for ; Fri, 11 Dec 2020 21:36:37 +0000 (UTC) X-FDA: 77582310834.10.party49_3c0468d27404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id AE57516A4AD for ; Fri, 11 Dec 2020 21:36:37 +0000 (UTC) X-HE-Tag: party49_3c0468d27404 X-Filterd-Recvd-Size: 2888 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:37 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722596; bh=6buXg179dc1hdMRmbtFDqCzc/aZHzakFw0JVoG+g1wc=; h=From:To:Subject:In-Reply-To:From; b=nMNCPHgGD92QEjG9LKX3A2M345z9uXEXOEtoy8nUTl4Bypn4GcQRE271LDTi6vnpK 8sq/7XShc9VIJze+kKuIUHEZypy2Ze56yzqSsTaj5pSxMWAkHB8orPZz576oHkSwO1 5G/sHjJ0yQzGDdQ0Xf/dVfWrKmWkSkpG2Vgpt29c= From: Andrew Morton To: akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, arnd@arndb.de, bp@suse.de, jpa@git.mail.kapsi.fi, linux-mm@kvack.org, mm-commits@vger.kernel.org, natechancellor@gmail.com, ndesaulniers@google.com, torvalds@linux-foundation.org Subject: [patch 3/8] selftest/fpu: avoid clang warning Message-ID: <20201211213635.QbYDxhklm%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Arnd Bergmann Subject: selftest/fpu: avoid clang warning With extra warnings enabled, clang complains about the redundant -mhard-float argument: clang: error: argument unused during compilation: '-mhard-float' [-Werror,-Wunused-command-line-argument] Move this into the gcc-only part of the Makefile. Link: https://lkml.kernel.org/r/20201203223652.1320700-1-arnd@kernel.org Fixes: 4185b3b92792 ("selftests/fpu: Add an FPU selftest") Signed-off-by: Arnd Bergmann Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Petteri Aimonen Cc: Borislav Petkov Cc: Arnd Bergmann Cc: Andy Shevchenko Signed-off-by: Andrew Morton --- lib/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/lib/Makefile~selftest-fpu-avoid-clang-warning +++ a/lib/Makefile @@ -107,7 +107,7 @@ obj-$(CONFIG_TEST_FREE_PAGES) += test_fr # off the generation of FPU/SSE* instructions for kernel proper but FPU_FLAGS # get appended last to CFLAGS and thus override those previous compiler options. # -FPU_CFLAGS := -mhard-float -msse -msse2 +FPU_CFLAGS := -msse -msse2 ifdef CONFIG_CC_IS_GCC # Stack alignment mismatch, proceed with caution. # GCC < 7.1 cannot compile code using `double` and -mpreferred-stack-boundary=3 @@ -120,6 +120,7 @@ ifdef CONFIG_CC_IS_GCC # -mpreferred-stack-boundary=3 is not between 4 and 12 # # can be triggered. Otherwise gcc doesn't complain. +FPU_CFLAGS += -mhard-float FPU_CFLAGS += $(call cc-option,-msse -mpreferred-stack-boundary=3,-mpreferred-stack-boundary=4) endif From patchwork Fri Dec 11 21:36:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB9D0C433FE for ; Fri, 11 Dec 2020 21:36:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 51C39233A2 for ; Fri, 11 Dec 2020 21:36:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51C39233A2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DC1B96B006E; Fri, 11 Dec 2020 16:36:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D70BE6B0070; Fri, 11 Dec 2020 16:36:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5F466B0072; Fri, 11 Dec 2020 16:36:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0018.hostedemail.com [216.40.44.18]) by kanga.kvack.org (Postfix) with ESMTP id B11566B006E for ; Fri, 11 Dec 2020 16:36:41 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7894C824999B for ; Fri, 11 Dec 2020 21:36:41 +0000 (UTC) X-FDA: 77582311002.16.girls54_5117eea27404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 5683A100E6903 for ; Fri, 11 Dec 2020 21:36:41 +0000 (UTC) X-HE-Tag: girls54_5117eea27404 X-Filterd-Recvd-Size: 2843 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:40 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:38 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722599; bh=Vql5KOdLOKsBXzP2w5ZiC+qjVWkaxgNf8DRqZZ8o81Q=; h=From:To:Subject:In-Reply-To:From; b=CJ66+UyGOg3XzYy/gi1PKYit4+7U8A9Ty8YTE88QtD19cNGEJQAZ6tBj7lG0yqbKx BO05d7uToJukoTHenflTliJi242O+cNJ6DqdqByntwtUwN6Zy/GyAyG0Mc3gGw4QY5 U2tDS9xpDFc4ec17q8hclOP785sl89Q4cYhWv47s= From: Andrew Morton To: akpm@linux-foundation.org, ardb@kernel.org, arnd@arndb.de, elver@google.com, keescook@chromium.org, linux-mm@kvack.org, masahiroy@kernel.org, michal.lkml@markovi.net, mm-commits@vger.kernel.org, rikard.falkeborn@gmail.com, stable@vger.kernel.org, torvalds@linux-foundation.org Subject: [patch 4/8] kbuild: avoid static_assert for genksyms Message-ID: <20201211213638.89W7IFB2b%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Arnd Bergmann Subject: kbuild: avoid static_assert for genksyms genksyms does not know or care about the _Static_assert() built-in, and sometimes falls back to ignoring the later symbols, which causes undefined behavior such as WARNING: modpost: EXPORT symbol "ethtool_set_ethtool_phy_ops" [vmlinux] version generation failed, symbol will not be versioned. ld: net/ethtool/common.o: relocation R_AARCH64_ABS32 against `__crc_ethtool_set_ethtool_phy_ops' can not be used when making a shared object net/ethtool/common.o:(_ftrace_annotated_branch+0x0): dangerous relocation: unsupported relocation Redefine static_assert for genksyms to avoid that. Link: https://lkml.kernel.org/r/20201203230955.1482058-1-arnd@kernel.org Signed-off-by: Arnd Bergmann Suggested-by: Ard Biesheuvel Cc: Masahiro Yamada Cc: Michal Marek Cc: Kees Cook Cc: Rikard Falkeborn Cc: Marco Elver Cc: Signed-off-by: Andrew Morton --- include/linux/build_bug.h | 5 +++++ 1 file changed, 5 insertions(+) --- a/include/linux/build_bug.h~kbuild-avoid-static_assert-for-genksyms +++ a/include/linux/build_bug.h @@ -77,4 +77,9 @@ #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr) #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) +#ifdef __GENKSYMS__ +/* genksyms gets confused by _Static_assert */ +#define _Static_assert(expr, ...) +#endif + #endif /* _LINUX_BUILD_BUG_H */ From patchwork Fri Dec 11 21:36:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969497 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FB6EC4361B for ; Fri, 11 Dec 2020 21:36:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B820923C32 for ; Fri, 11 Dec 2020 21:36:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B820923C32 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4238C6B0070; Fri, 11 Dec 2020 16:36:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FACE6B0072; Fri, 11 Dec 2020 16:36:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3397E6B0073; Fri, 11 Dec 2020 16:36:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 1E3EC6B0070 for ; Fri, 11 Dec 2020 16:36:45 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CDC41824999B for ; Fri, 11 Dec 2020 21:36:44 +0000 (UTC) X-FDA: 77582311128.22.horn19_25162ed27404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 99F961803893A for ; Fri, 11 Dec 2020 21:36:44 +0000 (UTC) X-HE-Tag: horn19_25162ed27404 X-Filterd-Recvd-Size: 2577 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:44 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722603; bh=WxPFqfjT5vknTH7sFF4MvYKi41O+VPD2FPGbc8Z5FzU=; h=From:To:Subject:In-Reply-To:From; b=AAw5n7FaKKh07dbBFl2FG/FHfghRub+fnBDoC+HlkO9n0SwOo76h7BX5vYoF8U5pJ KEyIo+gzna13huXJgQ83KE06g4jfGyp9dXGpR+tr75FqHWHjCOjoLwKBFaKL7ntWkS 8T6fRZGkx0yVsLjmwVTg9NkQAm0ivuQQWqvIwZds= From: Andrew Morton To: akpm@linux-foundation.org, arnd@arndb.de, brho@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, natechancellor@gmail.com, ndesaulniers@google.com, torvalds@linux-foundation.org Subject: [patch 5/8] initramfs: fix clang build failure Message-ID: <20201211213642.d_d5sDaBb%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Arnd Bergmann Subject: initramfs: fix clang build failure There is only one function in init/initramfs.c that is in the .text section, and it is marked __weak. When building with clang-12 and the integrated assembler, this leads to a bug with recordmcount: ./scripts/recordmcount "init/initramfs.o" Cannot find symbol for section 2: .text. init/initramfs.o: failed I'm not quite sure what exactly goes wrong, but I notice that this function is only ever called from an __init function, and normally inlined. Marking it __init as well is clearly correct and it leads to recordmcount no longer complaining. Link: https://lkml.kernel.org/r/20201204165742.3815221-1-arnd@kernel.org Signed-off-by: Arnd Bergmann Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Barret Rhoden Signed-off-by: Andrew Morton --- init/initramfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/init/initramfs.c~initramfs-fix-clang-build-failure +++ a/init/initramfs.c @@ -535,7 +535,7 @@ extern unsigned long __initramfs_size; #include #include -void __weak free_initrd_mem(unsigned long start, unsigned long end) +void __weak __init free_initrd_mem(unsigned long start, unsigned long end) { #ifdef CONFIG_ARCH_KEEP_MEMBLOCK unsigned long aligned_start = ALIGN_DOWN(start, PAGE_SIZE); From patchwork Fri Dec 11 21:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969499 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4872C433FE for ; Fri, 11 Dec 2020 21:36:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3962A23C32 for ; Fri, 11 Dec 2020 21:36:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3962A23C32 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BC4C46B0072; Fri, 11 Dec 2020 16:36:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B74C76B0073; Fri, 11 Dec 2020 16:36:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A8A3B6B0074; Fri, 11 Dec 2020 16:36:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0182.hostedemail.com [216.40.44.182]) by kanga.kvack.org (Postfix) with ESMTP id 923566B0072 for ; Fri, 11 Dec 2020 16:36:48 -0500 (EST) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5DACE824999B for ; Fri, 11 Dec 2020 21:36:48 +0000 (UTC) X-FDA: 77582311296.02.lamp75_570fe9f27404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 463AF10097AA1 for ; Fri, 11 Dec 2020 21:36:48 +0000 (UTC) X-HE-Tag: lamp75_570fe9f27404 X-Filterd-Recvd-Size: 4023 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:47 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:46 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722607; bh=q8Oikzb51lXNg23rfpod5PCxyUvpIjAexliinSv3Cdo=; h=From:To:Subject:In-Reply-To:From; b=kO7Da+98BZdh8i4Mcw7c/TRZmHXrCbQFCjcQ60JbhDTADEoZRhdGhpHQ8KGHUwm// SoG1SPSTxTUElpNy+X7qHG8Bwgaqz76iTGAutQHBTJnVSS1nMNQMCHVqFalPqj4NM9 q1E+Vb1WOQX0QuXQx1xOn55EtkWQdi5KaldYC8MM= From: Andrew Morton To: akpm@linux-foundation.org, arnd@arndb.de, brho@google.com, linux-mm@kvack.org, mm-commits@vger.kernel.org, natechancellor@gmail.com, ndesaulniers@google.com, torvalds@linux-foundation.org Subject: [patch 6/8] elfcore: fix building with clang Message-ID: <20201211213646.87FH3-_aO%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Arnd Bergmann Subject: elfcore: fix building with clang kernel/elfcore.c only contains weak symbols, which triggers a bug with clang in combination with recordmcount: Cannot find symbol for section 2: .text. kernel/elfcore.o: failed Move the empty stubs into linux/elfcore.h as inline functions. As only two architectures use these, just use the architecture specific Kconfig symbols to key off the declaration. Link: https://lkml.kernel.org/r/20201204165742.3815221-2-arnd@kernel.org Signed-off-by: Arnd Bergmann Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Barret Rhoden Signed-off-by: Andrew Morton --- include/linux/elfcore.h | 22 ++++++++++++++++++++++ kernel/Makefile | 1 - kernel/elfcore.c | 26 -------------------------- 3 files changed, 22 insertions(+), 27 deletions(-) --- a/include/linux/elfcore.h~elfcore-fix-building-with-clang +++ a/include/linux/elfcore.h @@ -104,6 +104,7 @@ static inline int elf_core_copy_task_fpr #endif } +#if defined(CONFIG_UM) || defined(CONFIG_IA64) /* * These functions parameterize elf_core_dump in fs/binfmt_elf.c to write out * extra segments containing the gate DSO contents. Dumping its @@ -118,5 +119,26 @@ elf_core_write_extra_phdrs(struct coredu extern int elf_core_write_extra_data(struct coredump_params *cprm); extern size_t elf_core_extra_data_size(void); +#else +static inline Elf_Half elf_core_extra_phdrs(void) +{ + return 0; +} + +static inline int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) +{ + return 1; +} + +static inline int elf_core_write_extra_data(struct coredump_params *cprm) +{ + return 1; +} + +static inline size_t elf_core_extra_data_size(void) +{ + return 0; +} +#endif #endif /* _LINUX_ELFCORE_H */ --- a/kernel/elfcore.c +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include -#include -#include -#include -#include - -Elf_Half __weak elf_core_extra_phdrs(void) -{ - return 0; -} - -int __weak elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset) -{ - return 1; -} - -int __weak elf_core_write_extra_data(struct coredump_params *cprm) -{ - return 1; -} - -size_t __weak elf_core_extra_data_size(void) -{ - return 0; -} --- a/kernel/Makefile~elfcore-fix-building-with-clang +++ a/kernel/Makefile @@ -97,7 +97,6 @@ obj-$(CONFIG_TASK_DELAY_ACCT) += delayac obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o obj-$(CONFIG_TRACEPOINTS) += tracepoint.o obj-$(CONFIG_LATENCYTOP) += latencytop.o -obj-$(CONFIG_ELFCORE) += elfcore.o obj-$(CONFIG_FUNCTION_TRACER) += trace/ obj-$(CONFIG_TRACING) += trace/ obj-$(CONFIG_TRACE_CLOCK) += trace/ From patchwork Fri Dec 11 21:36:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969501 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA9EEC4361B for ; Fri, 11 Dec 2020 21:36:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5DA9C23C32 for ; Fri, 11 Dec 2020 21:36:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5DA9C23C32 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E354B6B0073; Fri, 11 Dec 2020 16:36:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DEA1B6B0074; Fri, 11 Dec 2020 16:36:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D217D6B0075; Fri, 11 Dec 2020 16:36:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0122.hostedemail.com [216.40.44.122]) by kanga.kvack.org (Postfix) with ESMTP id BC4636B0073 for ; Fri, 11 Dec 2020 16:36:52 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 8A8BF180AD81D for ; Fri, 11 Dec 2020 21:36:52 +0000 (UTC) X-FDA: 77582311464.04.grape45_4411dd427404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin04.hostedemail.com (Postfix) with ESMTP id 6A72C8005041 for ; Fri, 11 Dec 2020 21:36:52 +0000 (UTC) X-HE-Tag: grape45_4411dd427404 X-Filterd-Recvd-Size: 7031 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:51 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722610; bh=Gldvhw+QeSlctzZJBYtXbjK+IWyFYKSbkUdID8aCEOs=; h=From:To:Subject:In-Reply-To:From; b=RCX6fQEEujUpTKBE5GpDM1pGdKE6jD9LgG1dj5DLjz0hilJuJqvPfeDth+C3YGquh 3ejIENZaUcWbdoUEdC9dQOHz0cDDstsFaR+j/SSZsa32fV2isPjP5bN4Ti97i9ZQuZ a0kpK5I4aCH5Tb7JlgvxJ5ic0mhqIYCVZVkvJLyQ= From: Andrew Morton To: akpm@linux-foundation.org, aryabinin@virtuozzo.com, dvyukov@google.com, glider@google.com, guangye.yang@mediatek.com, Kuan-Ying.Lee@mediatek.com, linux-mm@kvack.org, matthias.bgg@gmail.com, miles.chen@mediatek.com, mm-commits@vger.kernel.org, nicholas.tang@mediatek.com, qcai@redhat.com, qiang.zhang@windriver.com, sfr@canb.auug.org.au, torvalds@linux-foundation.org Subject: [patch 7/8] kasan: fix object remaining in offline per-cpu quarantine Message-ID: <20201211213649.uxHv5tD7K%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Kuan-Ying Lee Subject: kasan: fix object remaining in offline per-cpu quarantine We hit this issue in our internal test. When enabling generic kasan, a kfree()'d object is put into per-cpu quarantine first. If the cpu goes offline, object still remains in the per-cpu quarantine. If we call kmem_cache_destroy() now, slub will report "Objects remaining" error. [ 74.982625] ============================================================================= [ 74.983380] BUG test_module_slab (Not tainted): Objects remaining in test_module_slab on __kmem_cache_shutdown() [ 74.984145] ----------------------------------------------------------------------------- [ 74.984145] [ 74.984883] Disabling lock debugging due to kernel taint [ 74.985561] INFO: Slab 0x(____ptrval____) objects=34 used=1 fp=0x(____ptrval____) flags=0x2ffff00000010200 [ 74.986638] CPU: 3 PID: 176 Comm: cat Tainted: G B 5.10.0-rc1-00007-g4525c8781ec0-dirty #10 [ 74.987262] Hardware name: linux,dummy-virt (DT) [ 74.987606] Call trace: [ 74.987924] dump_backtrace+0x0/0x2b0 [ 74.988296] show_stack+0x18/0x68 [ 74.988698] dump_stack+0xfc/0x168 [ 74.989030] slab_err+0xac/0xd4 [ 74.989346] __kmem_cache_shutdown+0x1e4/0x3c8 [ 74.989779] kmem_cache_destroy+0x68/0x130 [ 74.990176] test_version_show+0x84/0xf0 [ 74.990679] module_attr_show+0x40/0x60 [ 74.991218] sysfs_kf_seq_show+0x128/0x1c0 [ 74.991656] kernfs_seq_show+0xa0/0xb8 [ 74.992059] seq_read+0x1f0/0x7e8 [ 74.992415] kernfs_fop_read+0x70/0x338 [ 74.993051] vfs_read+0xe4/0x250 [ 74.993498] ksys_read+0xc8/0x180 [ 74.993825] __arm64_sys_read+0x44/0x58 [ 74.994203] el0_svc_common.constprop.0+0xac/0x228 [ 74.994708] do_el0_svc+0x38/0xa0 [ 74.995088] el0_sync_handler+0x170/0x178 [ 74.995497] el0_sync+0x174/0x180 [ 74.996050] INFO: Object 0x(____ptrval____) @offset=15848 [ 74.996752] INFO: Allocated in test_version_show+0x98/0xf0 age=8188 cpu=6 pid=172 [ 75.000802] stack_trace_save+0x9c/0xd0 [ 75.002420] set_track+0x64/0xf0 [ 75.002770] alloc_debug_processing+0x104/0x1a0 [ 75.003171] ___slab_alloc+0x628/0x648 [ 75.004213] __slab_alloc.isra.0+0x2c/0x58 [ 75.004757] kmem_cache_alloc+0x560/0x588 [ 75.005376] test_version_show+0x98/0xf0 [ 75.005756] module_attr_show+0x40/0x60 [ 75.007035] sysfs_kf_seq_show+0x128/0x1c0 [ 75.007433] kernfs_seq_show+0xa0/0xb8 [ 75.007800] seq_read+0x1f0/0x7e8 [ 75.008128] kernfs_fop_read+0x70/0x338 [ 75.008507] vfs_read+0xe4/0x250 [ 75.008990] ksys_read+0xc8/0x180 [ 75.009462] __arm64_sys_read+0x44/0x58 [ 75.010085] el0_svc_common.constprop.0+0xac/0x228 [ 75.011006] kmem_cache_destroy test_module_slab: Slab cache still has objects Register a cpu hotplug function to remove all objects in the offline per-cpu quarantine when cpu is going offline. Set a per-cpu variable to indicate this cpu is offline. [qiang.zhang@windriver.com: fix slab double free when cpu-hotplug] Link: https://lkml.kernel.org/r/20201204102206.20237-1-qiang.zhang@windriver.com Link: https://lkml.kernel.org/r/1606895585-17382-2-git-send-email-Kuan-Ying.Lee@mediatek.com Signed-off-by: Kuan-Ying Lee Signed-off-by: Zqiang Suggested-by: Dmitry Vyukov Reported-by: Guangye Yang Reviewed-by: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Matthias Brugger Cc: Nicholas Tang Cc: Miles Chen Cc: Qian Cai Cc: Stephen Rothwell Signed-off-by: Andrew Morton --- mm/kasan/quarantine.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) --- a/mm/kasan/quarantine.c~kasan-fix-object-remain-in-offline-per-cpu-quarantine +++ a/mm/kasan/quarantine.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "../slab.h" #include "kasan.h" @@ -43,6 +44,7 @@ struct qlist_head { struct qlist_node *head; struct qlist_node *tail; size_t bytes; + bool offline; }; #define QLIST_INIT { NULL, NULL, 0 } @@ -188,6 +190,10 @@ void quarantine_put(struct kasan_free_me local_irq_save(flags); q = this_cpu_ptr(&cpu_quarantine); + if (q->offline) { + local_irq_restore(flags); + return; + } qlist_put(q, &info->quarantine_link, cache->size); if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) { qlist_move_all(q, &temp); @@ -328,3 +334,36 @@ void quarantine_remove_cache(struct kmem synchronize_srcu(&remove_cache_srcu); } + +static int kasan_cpu_online(unsigned int cpu) +{ + this_cpu_ptr(&cpu_quarantine)->offline = false; + return 0; +} + +static int kasan_cpu_offline(unsigned int cpu) +{ + struct qlist_head *q; + + q = this_cpu_ptr(&cpu_quarantine); + /* Ensure the ordering between the writing to q->offline and + * qlist_free_all. Otherwise, cpu_quarantine may be corrupted + * by interrupt. + */ + WRITE_ONCE(q->offline, true); + barrier(); + qlist_free_all(q, NULL); + return 0; +} + +static int __init kasan_cpu_quarantine_init(void) +{ + int ret = 0; + + ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "mm/kasan:online", + kasan_cpu_online, kasan_cpu_offline); + if (ret < 0) + pr_err("kasan cpu quarantine register failed [%d]\n", ret); + return ret; +} +late_initcall(kasan_cpu_quarantine_init); From patchwork Fri Dec 11 21:36:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11969503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 584DFC4361B for ; Fri, 11 Dec 2020 21:36:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC3D323EF2 for ; Fri, 11 Dec 2020 21:36:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC3D323EF2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4E71F6B0074; Fri, 11 Dec 2020 16:36:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 495AA6B0075; Fri, 11 Dec 2020 16:36:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D4E56B0078; Fri, 11 Dec 2020 16:36:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 276456B0074 for ; Fri, 11 Dec 2020 16:36:56 -0500 (EST) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E4A23363C for ; Fri, 11 Dec 2020 21:36:55 +0000 (UTC) X-FDA: 77582311590.28.rain54_0e1801127404 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id BE1A36C3C for ; Fri, 11 Dec 2020 21:36:55 +0000 (UTC) X-HE-Tag: rain54_0e1801127404 X-Filterd-Recvd-Size: 4390 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Fri, 11 Dec 2020 21:36:55 +0000 (UTC) Date: Fri, 11 Dec 2020 13:36:53 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1607722614; bh=OxdipKPcakqLS2jEp2iuR0I4YoCZzTg0P1U6jh4HFTI=; h=From:To:Subject:In-Reply-To:From; b=aSbcu6pxg0wzXGy/eiBWFCK5x3J4TSkGbtiLXiaKx5QDoj4+k0A2q+PP4vGSByjYv oxp7w5K9QyZBPXNFeqqqGwIIfATiqvJecR4hmdwUZvmRIOWqetFxRwTsVZc7yttcd6 RSMAypTrSRXiO7uCUNXcY9l2r9IlExXvw5DQQ9vw= From: Andrew Morton To: akpm@linux-foundation.org, borntraeger@de.ibm.com, gerald.schaefer@linux.ibm.com, linux-mm@kvack.org, mike.kravetz@oracle.com, mm-commits@vger.kernel.org, stable@vger.kernel.org, torvalds@linux-foundation.org, willy@infradead.org Subject: [patch 8/8] mm/hugetlb: clear compound_nr before freeing gigantic pages Message-ID: <20201211213653.AWzFNUbZK%akpm@linux-foundation.org> In-Reply-To: <20201211133555.88407977f082963499ed343c@linux-foundation.org> User-Agent: s-nail v14.8.16 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: Gerald Schaefer Subject: mm/hugetlb: clear compound_nr before freeing gigantic pages Commit 1378a5ee451a ("mm: store compound_nr as well as compound_order") added compound_nr counter to first tail struct page, overlaying with page->mapping. The overlay itself is fine, but while freeing gigantic hugepages via free_contig_range(), a "bad page" check will trigger for non-NULL page->mapping on the first tail page: [ 276.681603] BUG: Bad page state in process bash pfn:380001 [ 276.681614] page:00000000c35f0856 refcount:0 mapcount:0 mapping:00000000126b68aa index:0x0 pfn:0x380001 [ 276.681620] aops:0x0 [ 276.681622] flags: 0x3ffff00000000000() [ 276.681626] raw: 3ffff00000000000 0000000000000100 0000000000000122 0000000100000000 [ 276.681628] raw: 0000000000000000 0000000000000000 ffffffff00000000 0000000000000000 [ 276.681630] page dumped because: non-NULL mapping [ 276.681632] Modules linked in: [ 276.681637] CPU: 6 PID: 616 Comm: bash Not tainted 5.10.0-rc7-next-20201208 #1 [ 276.681639] Hardware name: IBM 3906 M03 703 (LPAR) [ 276.681641] Call Trace: [ 276.681648] [<0000000458c252b6>] show_stack+0x6e/0xe8 [ 276.681652] [<000000045971cf60>] dump_stack+0x90/0xc8 [ 276.681656] [<0000000458e8b186>] bad_page+0xd6/0x130 [ 276.681658] [<0000000458e8cdea>] free_pcppages_bulk+0x26a/0x800 [ 276.681661] [<0000000458e8e67e>] free_unref_page+0x6e/0x90 [ 276.681663] [<0000000458e8ea6c>] free_contig_range+0x94/0xe8 [ 276.681666] [<0000000458ea5e54>] update_and_free_page+0x1c4/0x2c8 [ 276.681669] [<0000000458ea784e>] free_pool_huge_page+0x11e/0x138 [ 276.681671] [<0000000458ea8530>] set_max_huge_pages+0x228/0x300 [ 276.681673] [<0000000458ea86c0>] nr_hugepages_store_common+0xb8/0x130 [ 276.681678] [<0000000458fd5b6a>] kernfs_fop_write+0xd2/0x218 [ 276.681681] [<0000000458ef9da0>] vfs_write+0xb0/0x2b8 [ 276.681684] [<0000000458efa15c>] ksys_write+0xac/0xe0 [ 276.681687] [<000000045972c5ca>] system_call+0xe6/0x288 [ 276.681730] Disabling lock debugging due to kernel taint This is because only the compound_order is cleared in destroy_compound_gigantic_page(), and compound_nr is set to 1U << order == 1 for order 0 in set_compound_order(page, 0). Fix this by explicitly clearing compound_nr for first tail page after calling set_compound_order(page, 0). Link: https://lkml.kernel.org/r/20201208182813.66391-2-gerald.schaefer@linux.ibm.com Fixes: 1378a5ee451a ("mm: store compound_nr as well as compound_order") Signed-off-by: Gerald Schaefer Reviewed-by: Matthew Wilcox (Oracle) Cc: Mike Kravetz Cc: Christian Borntraeger Cc; Heiko Carstens Cc: [5.9+] Signed-off-by: Andrew Morton --- mm/hugetlb.c | 1 + 1 file changed, 1 insertion(+) --- a/mm/hugetlb.c~mm-hugetlb-clear-compound_nr-before-freeing-gigantic-pages +++ a/mm/hugetlb.c @@ -1216,6 +1216,7 @@ static void destroy_compound_gigantic_pa } set_compound_order(page, 0); + page[1].compound_nr = 0; __ClearPageHead(page); }