Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2499299rwb; Mon, 3 Oct 2022 01:23:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM59SmqEVylVK1WRIwYBDKAM7gk0k4urduJFyfdkB58zXRyIFq0YDrEoYjUO7++bbF4iGEW0 X-Received: by 2002:a17:90b:388c:b0:20a:9c33:dd2b with SMTP id mu12-20020a17090b388c00b0020a9c33dd2bmr4358854pjb.225.1664785391093; Mon, 03 Oct 2022 01:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664785391; cv=none; d=google.com; s=arc-20160816; b=kHXrUJKS9YWOGfp0g5gHlVJOPjfiJ+1Dg6zXHovVY/46f3XsWGjOOOgeeyEiJb2vH3 CAG8f+T6P1XXUEPe4rjyhsM5tMPZMLeI9TFNuRfxjUQW40jmD0QFhaVGodCYA8yUvnvn o1JYIbaPBCRhkX3cPbkFCn5rBx+gq/KUAj0pqfqYcZMV1Vpogmfp1TPuU2jfSuCOQ68u pXiNSya9RZFfDjt6Yt2hcpUaue2ZzVRfdNxA2UcumE/IdEdW4m0Z3CY7l+Bi1fIihWlV +v7A+luBqhWDNX3Q/ETPrmPYU4MFFUM/JxLO/RYo1E0+dsBnhPjOu6LUg4sunJiAMA9u yi1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QiFnj4ezjEtikXiY9uOD/SNjCYH75A5gQ1pqurnH/bE=; b=L+6ZAWJyOWJG8QvBUy37zAtiWyHF31SCB9/7725spb9PIHm/fgwK1AHl1qW57KfLLA A89HfrfSXI2wzAoZZKtK4DkoTMEaWqDY/j6nXyC6l4i1+pz/WpXc0AHlIPq2tDUu6Bhe vKPwek2AtnZj/QA9R1IK9RegHi1JaONO1Ago6LL/sP08j+HNR8FI1Av5wb4pjcLgQwry sJEEuNLOId89+Ojl4thkRQKxm0KBCF1vZ2bVx3DxQe385XnkNr/J4cdEOQZ9EO5j6tb5 3tjvxUxa4PNFxDe1flSNkPHP8Tdo2VpFW4PdvHIGibdoTBoCF4rB4K/JpJbf0/Mrddil lHyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dcojaH9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y63-20020a638a42000000b0042bd54984e5si9539622pgd.722.2022.10.03.01.22.36; Mon, 03 Oct 2022 01:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dcojaH9T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232203AbiJCHpl (ORCPT + 99 others); Mon, 3 Oct 2022 03:45:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232329AbiJCHoM (ORCPT ); Mon, 3 Oct 2022 03:44:12 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DE1757563; Mon, 3 Oct 2022 00:25:52 -0700 (PDT) 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 CAF4FB80E7F; Mon, 3 Oct 2022 07:19:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3ABD1C433D6; Mon, 3 Oct 2022 07:19:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664781553; bh=HSFhtvXCo+irCMXGqTF2j6qoYuSJB/k0Y30uNtW1jEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dcojaH9TaM9P8ZtldWYB4gQqkA3hnKX6Tme6U4biQI0px7hPASXyOg2OY6B6RG6TJ V3CXU56+wzgOc2WXL6yj/7jYYj9QR+KtEVWVjmWEcm1OiNb8rEOnYxcaKupjP3Em6l YvkIGp+GiGCPCX+56IZKTgGSMKazcaZDXfUNqybQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shuai Xue , Miaohe Lin , Naoya Horiguchi , Huang Ying , Baolin Wang , Bixuan Cui , Andrew Morton Subject: [PATCH 5.15 34/83] mm,hwpoison: check mm when killing accessing process Date: Mon, 3 Oct 2022 09:10:59 +0200 Message-Id: <20221003070722.852051421@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221003070721.971297651@linuxfoundation.org> References: <20221003070721.971297651@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuai Xue commit 77677cdbc2aa4b5d5d839562793d3d126201d18d upstream. The GHES code calls memory_failure_queue() from IRQ context to queue work into workqueue and schedule it on the current CPU. Then the work is processed in memory_failure_work_func() by kworker and calls memory_failure(). When a page is already poisoned, commit a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address") make memory_failure() call kill_accessing_process() that: - holds mmap locking of current->mm - does pagetable walk to find the error virtual address - and sends SIGBUS to the current process with error info. However, the mm of kworker is not valid, resulting in a null-pointer dereference. So check mm when killing the accessing process. [akpm@linux-foundation.org: remove unrelated whitespace alteration] Link: https://lkml.kernel.org/r/20220914064935.7851-1-xueshuai@linux.alibaba.com Fixes: a3f5d80ea401 ("mm,hwpoison: send SIGBUS with error virutal address") Signed-off-by: Shuai Xue Reviewed-by: Miaohe Lin Acked-by: Naoya Horiguchi Cc: Huang Ying Cc: Baolin Wang Cc: Bixuan Cui Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/memory-failure.c | 3 +++ 1 file changed, 3 insertions(+) --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -700,6 +700,9 @@ static int kill_accessing_process(struct }; priv.tk.tsk = p; + if (!p->mm) + return -EFAULT; + mmap_read_lock(p->mm); ret = walk_page_range(p->mm, 0, TASK_SIZE, &hwp_walk_ops, (void *)&priv);