Received: by 2002:a05:7208:3188:b0:7e:5202:c8b4 with SMTP id r8csp867602rbd; Fri, 23 Feb 2024 06:09:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXHFIakgTb38Lcs+ThFvQTMzhX/Xeo4nYYmBg3GU5+9xiFSfJ/YinAMvR3SomTrf6CiGhSQiCjXoJJdcp7xOnlkPmqGKWXC71uAYYtoEw== X-Google-Smtp-Source: AGHT+IH3/gu5aQi6OY43nTCddJgEw2CCt1QftMmZ6Ov3Cx6rvCUca8n15gb87tBFg2T2bUQBeJW8 X-Received: by 2002:a05:6a20:889d:b0:1a0:dfc9:378c with SMTP id d29-20020a056a20889d00b001a0dfc9378cmr1506021pzf.44.1708697373314; Fri, 23 Feb 2024 06:09:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708697373; cv=pass; d=google.com; s=arc-20160816; b=cC1twTJ+2v0gibX0gfDs2L32dAvfqMAF+4+mBvVJtWO//UqhDJ8m/6WG6zjEHEnUIh BqLZSnGDFBgvYchyk6li/pZGEV7Y1rnKGB7YKmxgENtcjFjDXrr91X/1Ct7oM1EPJbsJ HmWAqGGvo+xjFP4gw0iLhLYbRBC1do6AbeIG7Ymj70j123PRveXl82lWor8gIK4TFQFd 7o6Dk3cMOmTi2ElxErsHqcMlllX5QsV95wUOUN8xPwGrRzKVUuty3V8TGQQ5uUeHqx0d YbNA/kiWF/CeBVZh14BRl8f7E1rD/wRH0FaF+su2OLJeozSWHgKWmxv+6SlneBwGbgy6 eJTA== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from; bh=Jy1mji0huxlzAVzICNupOAFUqwB/9+kefsnRGGH0duA=; fh=l0xhDQi2YiCJnII4lRJgRHQPEBBPYBbMgTLdbnEOFPs=; b=HJx1PsehoSy2l9BOSypMeFrNTI+PmI5NZurW3nU+AMf4W1wJIlLZeBAErRiOJtJGZR dRv80zhNPnQgxvSDf2XLAC7jpNqwJInnYJ/R5Y0rHiajYWDCQR28g9OKhZJ6lRWQTVUP OV1ycPO4oN4xeq0tWVDjLbSBn8HfPbyZSRiCaM96dXzttHfZNxW6HfG1NMgDaowQat/t Clp3s4ci1SNRyerObnrwIpuiG/As8tJs4l/DSZ6F7pgzPx/ZReRggK/oENxHRi1d71kc L6DzmgCW39/CLiUO5myOyQiWoxULOoCAjb6T4cRrrTwadCr0u7mqhHRUYBapfLuUfAIe g5SA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-78443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78443-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y33-20020a056a001ca100b006e4c0cf47b2si4206801pfw.70.2024.02.23.06.09.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 06:09:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-78443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-78443-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-78443-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 24F38B223FC for ; Fri, 23 Feb 2024 14:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B304F81AD6; Fri, 23 Feb 2024 14:05:09 +0000 (UTC) Received: from frasgout13.his.huawei.com (frasgout13.his.huawei.com [14.137.139.46]) (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 E513B81AB5 for ; Fri, 23 Feb 2024 14:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697109; cv=none; b=UZ3snf3di+BqtdJOyVS+O2vO9tC1uvOs7cqNvWuBrOy3R2+EkRwPMG6bWgkg4mHHs9fLGGzV+OMBcr24VmUO/S918yCYPnbIYdd/S4Q01EtDSlXH/ykBD41GNT5C3UzGOibXbylceeR95sK0Zx2wBjmLtHkzffcY0oaBO0yXaq8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708697109; c=relaxed/simple; bh=3pqc/pxRYqV2lohhwBLkMpVmkZWPaHZgO2ezrk/vsfA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mkM0JSd6XuF4wfLE/uiMYH2BbaIwXSi17TJp+otArZ8sgdhpnnkidot3uxt/CtKhAidFemgRdTPs59eZWEXoQbgNSqGNip8ooDTbF7nWjxGhm+TRDlHUGVLmIUHgs2GkopKUU7tnvPxOQdJ3Oeig1IJWnGzNYVN0RM2F8dOgCN0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout13.his.huawei.com (SkyGuard) with ESMTP id 4ThBFl05nFz9y3Cc for ; Fri, 23 Feb 2024 21:49:31 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.47]) by mail.maildlp.com (Postfix) with ESMTP id E866A14042B for ; Fri, 23 Feb 2024 22:04:55 +0800 (CST) Received: from huaweicloud.com (unknown [10.81.218.207]) by APP1 (Coremail) with SMTP id LxC2BwC3YBkApthlMxERAw--.25951S2; Fri, 23 Feb 2024 15:04:55 +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 Tesarik Subject: [PATCH RESEND 1/1] um: oops on accessing a non-present page in the vmalloc area Date: Fri, 23 Feb 2024 15:04:35 +0100 Message-Id: <20240223140435.1240-1-petrtesarik@huaweicloud.com> X-Mailer: git-send-email 2.34.1 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:LxC2BwC3YBkApthlMxERAw--.25951S2 X-Coremail-Antispam: 1UD129KBjvJXoW7Kw1DWF1rCFykWr15ZrW5KFg_yoW8GFy7pF sxGa1ktr4S9F12ya9rX3s2vr4xKa4kt3W7CrWDAw1Sva1j9F1fZrWakwn8Aw109rWrGayx tFWYyryjyw4DXw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkK14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r1j 6r4UM28EF7xvwVC2z280aVAFwI0_Gr0_Cr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4j6r 4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY1x0264kExVAvwVAq 07x20xyl42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67 AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIY rxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14 v26r1j6r4UMIIF0xvE42xK8VAvwI8IcIk0rVWrZr1j6s0DMIIF0xvEx4A2jsIE14v26r1j 6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7VUj0JPt UUUUU== X-CM-SenderInfo: hshw23xhvd2x3n6k3tpzhluzxrxghudrp/ From: Petr Tesarik If a segmentation fault is caused by accessing an address in the vmalloc area, check that the target page is present. Currently, if the kernel hits a guard page in the vmalloc area, UML blindly assumes that the fault is caused by a stale mapping and will be fixed by flush_tlb_kernel_vm(). Unsurprisingly, if the fault is caused by accessing a guard page, no mapping is created, and when the faulting instruction is restarted, it will cause exactly the same fault again, effectively creating an infinite loop. Signed-off-by: Petr Tesarik --- arch/um/kernel/trap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index 6d8ae86ae978..d5b85f1bfe33 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c @@ -206,11 +206,15 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, int err; int is_write = FAULT_WRITE(fi); unsigned long address = FAULT_ADDRESS(fi); + pte_t *pte; if (!is_user && regs) current->thread.segv_regs = container_of(regs, struct pt_regs, regs); if (!is_user && (address >= start_vm) && (address < end_vm)) { + pte = virt_to_pte(&init_mm, address); + if (!pte_present(*pte)) + page_fault_oops(regs, address, ip); flush_tlb_kernel_vm(); goto out; } -- 2.34.1