Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6636975rdb; Fri, 15 Dec 2023 04:32:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGTW0CM1BTC2t+rhaioBWnztupjG2SjW9VmKE4njv5YJfcAF4ieqqBPo0/MEHIjCIyHygF6 X-Received: by 2002:a05:6a20:8e13:b0:18f:f57a:e761 with SMTP id y19-20020a056a208e1300b0018ff57ae761mr15143109pzj.63.1702643570712; Fri, 15 Dec 2023 04:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702643570; cv=none; d=google.com; s=arc-20160816; b=BY8axTUXBuHs548c8qk9oL3nB9ciPF2tTQ3scuXUU23dTvAeCHWrPzuyP5tFM0PGOh 60CyB8m7E/IjU1z2sGZU8XLUguKcPc1zNIUh6CZGK+iih1v1N1KG1+ZcE6fUvBRT3kAa Ko+m6QTZ7lJVn/aYNvjg+i3PB4F2gQcEugAj40GOMbQ/uXTHTiAwai4Dvsz/NWw7K3u7 0WMPIZsrVSVdXMeiH8PKl0lwTtgy+C2XZDZWkY5MZ2yCXW2sp+5xwxpyGZHynm+zmftY Ls74ao+kTlRJKaFGZQyFkM1RfN02Q3eRVRnLo/F9oJcmL71B/Cn7tyN8EXy8+KGKarmA aiNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=8q4PzrKs2FLRiSdhYmqWyLRGy6LJ8kabPDSBTbTIyoc=; fh=cwFOem/rBL3vlsmW5EZfH4dXj5MUGk0IYxzeUHboVUs=; b=p5rDH0GSnBH9IvYJnkUXF0NVXEH2UnRXonH3NwPcbyFOYYXe0XDu67U0KbaBQEihzY ZQzAiGuq1YMXQD3H4YD+THu0u1674pC7UdUaqD9AmoXOMalq9w/A3d0+w0NL+ME1d+Ri KputNepftKtwU9w+0c/wcrxKpIUAaeVrzXA5AKMY+BsFuoFLutpvAMHmCJuYLdZp34Ut GQS21Y9lOVwH+QR+l7k9XLgT/ox4sMxUjX8bu0TXQvL1O4Ao/m8eKwZkE0CnhwbJGqHu kSGwjnVqyZ3zlK4OrcUgbfzgmSoiCcyWTgiOb8SHd2d5yBDOEU984U+Q8PURLja1TYzI sNvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-924-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 8-20020a631748000000b00565dd108fd4si12614415pgx.115.2023.12.15.04.32.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 04:32:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-924-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-924-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 98ED6B21DA2 for ; Fri, 15 Dec 2023 12:31:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 844482C69E; Fri, 15 Dec 2023 12:31:38 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E62A2C68D for ; Fri, 15 Dec 2023 12:31:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.29]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4Ss7902LBSz9xrsd for ; Fri, 15 Dec 2023 20:01:08 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.27]) by mail.maildlp.com (Postfix) with ESMTP id 4B777140486 for ; Fri, 15 Dec 2023 20:15:03 +0800 (CST) Received: from huaweicloud.com (unknown [10.48.148.243]) by APP2 (Coremail) with SMTP id GxC2BwCnpV86Q3xlRz6QAg--.57272S3; Fri, 15 Dec 2023 13:15:02 +0100 (CET) From: Petr Tesarik To: Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org (open list:USER-MODE LINUX (UML)), linux-kernel@vger.kernel.org (open list) Cc: Roberto Sassu , petr@tesarici.cz, Petr Tesarik Subject: [PATCH 1/2] um: do not panic on kernel mode faults Date: Fri, 15 Dec 2023 13:14:30 +0100 Message-Id: <20231215121431.680-2-petrtesarik@huaweicloud.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231215121431.680-1-petrtesarik@huaweicloud.com> References: <20231215121431.680-1-petrtesarik@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:GxC2BwCnpV86Q3xlRz6QAg--.57272S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw1DWF1ftr1ktw48KFWUCFg_yoW8XF15pF nxAa1agr4Sv3W5Aa9rWr4kZ3y3Ja4qgw12krZ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() on unrecoverable page faults in kernel mode. Although such page faults always indicate a bug in the kernel, other architectures prefer to kill only the current process and continue. The new behavior is useful for testing intentional kernel mode page faults with KUnit. Signed-off-by: Petr Tesarik --- arch/um/kernel/trap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index 6d8ae86ae978..1124a382fd14 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c @@ -17,6 +17,14 @@ #include #include +static void page_fault_oops(struct uml_pt_regs *regs, unsigned long address, + unsigned long ip) +{ + pr_alert("Kernel mode fault at addr 0x%lx, ip 0x%lx\n", address, ip); + show_regs(container_of(regs, struct pt_regs, regs)); + make_task_dead(SIGKILL); +} + /* * Note this is constrained to return 0, -EFAULT, -EACCES, -ENOMEM by * segv(). @@ -249,11 +257,8 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, else if (!is_user && arch_fixup(ip, regs)) goto out; - if (!is_user) { - show_regs(container_of(regs, struct pt_regs, regs)); - panic("Kernel mode fault at addr 0x%lx, ip 0x%lx", - address, ip); - } + if (!is_user) + page_fault_oops(regs, address, ip); show_segv_info(regs); -- 2.34.1