From patchwork Fri Feb 4 17:56:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 540301 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82089C433FE for ; Fri, 4 Feb 2022 17:56:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377190AbiBDR4s (ORCPT ); Fri, 4 Feb 2022 12:56:48 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:37478 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbiBDR4s (ORCPT ); Fri, 4 Feb 2022 12:56:48 -0500 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 41FD5B83874; Fri, 4 Feb 2022 17:56:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DFCCC004E1; Fri, 4 Feb 2022 17:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1643997406; bh=T6HZzuF9kGoCDs+xTHJbPxAXenTBHTFYjDOPtEfogn0=; h=Date:To:From:In-Reply-To:Subject:From; b=YOZHxWRnuWHNoY+2Oxnw8eS3bjz08O872tjgdTpPwZP7XiHdLmebOtC26eSmDq/Zz HQAvdUwEEj+GpJa9YVHZSOew5TJd43RGVBQbODSVXwvpc11cn7QG7DiWVFpgzfggc9 hYamu6/lKKtlOYB8//g4BYjmVhEeRovEUMrNbq6w= Received: by hp1 (sSMTP sendmail emulation); Fri, 04 Feb 2022 09:56:43 -0800 Date: Fri, 04 Feb 2022 09:56:43 -0800 To: ziy@nvidia.com, will@kernel.org, weixugc@google.com, stable@vger.kernel.org, songmuchun@bytedance.com, rppt@kernel.org, rientjes@google.com, pjt@google.com, mingo@redhat.com, jirislaby@kernel.org, hughd@google.com, hpa@zytor.com, gthelen@google.com, dave.hansen@linux.intel.com, anshuman.khandual@arm.com, aneesh.kumar@linux.ibm.com, pasha.tatashin@soleen.com, akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220203204836.88dcebe504f440686cc63a60@linux-foundation.org> Subject: [patch 02/10] mm/debug_vm_pgtable: remove pte entry from the page table Message-Id: <20220204175644.4DFCCC004E1@smtp.kernel.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pasha Tatashin Subject: mm/debug_vm_pgtable: remove pte entry from the page table Patch series "page table check fixes and cleanups", v5. This patch (of 4): The pte entry that is used in pte_advanced_tests() is never removed from the page table at the end of the test. The issue is detected by page_table_check, to repro compile kernel with the following configs: CONFIG_DEBUG_VM_PGTABLE=y CONFIG_PAGE_TABLE_CHECK=y CONFIG_PAGE_TABLE_CHECK_ENFORCED=y During the boot the following BUG is printed: [ 2.262821] debug_vm_pgtable: [debug_vm_pgtable ]: Validating architecture page table helpers [ 2.276826] ------------[ cut here ]------------ [ 2.280426] kernel BUG at mm/page_table_check.c:162! [ 2.284118] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 2.287787] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.16.0-11413-g2c271fe77d52 #3 [ 2.293226] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 ... The entry should be properly removed from the page table before the page is released to the free list. Link: https://lkml.kernel.org/r/20220131203249.2832273-1-pasha.tatashin@soleen.com Link: https://lkml.kernel.org/r/20220131203249.2832273-2-pasha.tatashin@soleen.com Fixes: a5c3b9ffb0f4 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers") Signed-off-by: Pasha Tatashin Reviewed-by: Zi Yan Tested-by: Zi Yan Acked-by: David Rientjes Reviewed-by: Anshuman Khandual Cc: Paul Turner Cc: Wei Xu Cc: Greg Thelen Cc: Ingo Molnar Cc: Will Deacon Cc: Mike Rapoport Cc: Dave Hansen Cc: H. Peter Anvin Cc: Aneesh Kumar K.V Cc: Jiri Slaby Cc: Muchun Song Cc: Hugh Dickins Cc: [5.9+] Signed-off-by: Andrew Morton --- mm/debug_vm_pgtable.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/debug_vm_pgtable.c~mm-debug_vm_pgtable-remove-pte-entry-from-the-page-table +++ a/mm/debug_vm_pgtable.c @@ -171,6 +171,8 @@ static void __init pte_advanced_tests(st ptep_test_and_clear_young(args->vma, args->vaddr, args->ptep); pte = ptep_get(args->ptep); WARN_ON(pte_young(pte)); + + ptep_get_and_clear_full(args->mm, args->vaddr, args->ptep, 1); } static void __init pte_savedwrite_tests(struct pgtable_debug_args *args) From patchwork Fri Feb 4 17:57:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 540300 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4642BC433F5 for ; Fri, 4 Feb 2022 17:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377201AbiBDR5L (ORCPT ); Fri, 4 Feb 2022 12:57:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbiBDR5K (ORCPT ); Fri, 4 Feb 2022 12:57:10 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B339C061714; Fri, 4 Feb 2022 09:57:10 -0800 (PST) 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 5C638B8386E; Fri, 4 Feb 2022 17:57:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA326C340E9; Fri, 4 Feb 2022 17:57:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1643997428; bh=D1pLLIbAAt2KQpwLnzj66vfNlI8SvQaQIa3Kfuug6OQ=; h=Date:To:From:In-Reply-To:Subject:From; b=bbYy4YgyVo9Y8dwGWdyZQuOjT/0svZfvuTTJRLbVT6L72QntPieBiJ6vajDaUFQdE KAOoLZsvsUiytCnmbfEAQpQz04JrEc80MQ1rwAIrj8adK4XSKeCImPi+jV0uC7p7u3 +xi2OecCJ12p9SbjnwQ8bhjYPI8Ag2xwenPjEXKs= Received: by hp1 (sSMTP sendmail emulation); Fri, 04 Feb 2022 09:57:06 -0800 Date: Fri, 04 Feb 2022 09:57:06 -0800 To: zealci@zte.com.cn, vvs@virtuozzo.com, unixbhaskar@gmail.com, stable@vger.kernel.org, shakeelb@google.com, rdunlap@infradead.org, manfred@colorfullife.com, dbueso@suse.de, cgel.zte@gmail.com, arnd@arndb.de, chi.minghao@zte.com.cn, akpm@linux-foundation.org, linux-mm@kvack.org, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220203204836.88dcebe504f440686cc63a60@linux-foundation.org> Subject: [patch 07/10] ipc/sem: do not sleep with a spin lock held Message-Id: <20220204175706.AA326C340E9@smtp.kernel.org> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Minghao Chi Subject: ipc/sem: do not sleep with a spin lock held We can't call kvfree() with a spin lock held, so defer it. Link: https://lkml.kernel.org/r/20211223031207.556189-1-chi.minghao@zte.com.cn Fixes: fc37a3b8b438 ("[PATCH] ipc sem: use kvmalloc for sem_undo allocation") Reported-by: Zeal Robot Signed-off-by: Minghao Chi Reviewed-by: Shakeel Butt Reviewed-by: Manfred Spraul Cc: Arnd Bergmann Cc: Yang Guang Cc: Davidlohr Bueso Cc: Randy Dunlap Cc: Bhaskar Chowdhury Cc: Vasily Averin Cc: Signed-off-by: Andrew Morton --- ipc/sem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/ipc/sem.c~ipc-sem-do-not-sleep-with-a-spin-lock-held +++ a/ipc/sem.c @@ -1964,6 +1964,7 @@ static struct sem_undo *find_alloc_undo( */ un = lookup_undo(ulp, semid); if (un) { + spin_unlock(&ulp->lock); kvfree(new); goto success; } @@ -1976,9 +1977,8 @@ static struct sem_undo *find_alloc_undo( ipc_assert_locked_object(&sma->sem_perm); list_add(&new->list_id, &sma->list_id); un = new; - -success: spin_unlock(&ulp->lock); +success: sem_unlock(sma, -1); out: return un;