From mboxrd@z Thu Jan 1 00:00:00 1970 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=-17.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 5B1E3C433E0 for ; Mon, 8 Feb 2021 18:01:45 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF62764E85 for ; Mon, 8 Feb 2021 18:01:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF62764E85 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rxGzvrAs1wv/Xu/66CKLo9LI7lHvjJ/6H2dIO2PsRgY=; b=we03paFvF9p5hpDdwPpm9OdeR Jbnw8N+JHtil4oa9wtkahnaIXRGjTov0OMLoQCQfPMYk4HLTyLFNsLxbKmMocUnhTW+yDUqNl4CfO XE1BqVTCN1dT/3JNYxPST+MvRJF3a1p/rB6k4m2Xf9StJn6v6exaU3Qd437VCKfQkZJgnueNY+wCH eg80MWIEqrgODI/R+4oCfrFRI6MFQKCUQkKT78YLEhuqdD6OE3ZiDjjCsJCSkPU8HwlPj6C2SsXEr FUUx6e94TteHp2L8OaqClOcOJvTBUVuBsgHWn5ZsFRSd9Lqq4Fbd+kXYUzKxFcCs6KRpzxs7Zg5jy T0vMNBK4g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9Aqk-0008N6-OT; Mon, 08 Feb 2021 18:01:26 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l9Ap2-0007Km-E9 for linux-riscv@lists.infradead.org; Mon, 08 Feb 2021 17:59:42 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3D2B64ED9; Mon, 8 Feb 2021 17:59:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612807178; bh=pocyn+9VVPB9fe6QZ4lhsKCTCFw29kNYVSRIRcFeyvE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1oioWzPrLKd/YH2+a0Pb/YhKP/KBzZvyCg6Xfe2CvKbWN0v4C8j4AswnLQbkoDst A1JXgegPeD0aMwEOlUDXwNkXpWcsCnXc5sUhO7GRin1I7plGBR7ieoo1cxgAmZ7Wvd hkpuSBSFTQBo3zN1IJnrEoZ7aC7oWs+GZSZUTewBVa7fCEtvFYMRXP9KtIs1RaBZ+O +To+dDjnhH6DpVMERopJxApI0c1qJjVA4GvqrEp93NPfHPMxDQEwvVA2TFh1vNYyfS FcVGO8FbKfN7b0S5eY6Yh/MocmiJqcOew8apsAHLys8zp7hPxehFl1Gi1KH7vpFdK8 jFk87eSfUhyVg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 09/14] riscv: virt_addr_valid must check the address belongs to linear mapping Date: Mon, 8 Feb 2021 12:59:21 -0500 Message-Id: <20210208175926.2092211-9-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210208175926.2092211-1-sashal@kernel.org> References: <20210208175926.2092211-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210208_125940_814738_D4093298 X-CRM114-Status: UNSURE ( 9.77 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Atish Patra , linux-riscv@lists.infradead.org, Palmer Dabbelt , Alexandre Ghiti Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Alexandre Ghiti [ Upstream commit 2ab543823322b564f205cb15d0f0302803c87d11 ] virt_addr_valid macro checks that a virtual address is valid, ie that the address belongs to the linear mapping and that the corresponding physical page exists. Add the missing check that ensures the virtual address belongs to the linear mapping, otherwise __virt_to_phys, when compiled with CONFIG_DEBUG_VIRTUAL enabled, raises a WARN that is interpreted as a kernel bug by syzbot. Signed-off-by: Alexandre Ghiti Reviewed-by: Atish Patra Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/include/asm/page.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h index 06cfbb3aacbb0..abc147aeff8b0 100644 --- a/arch/riscv/include/asm/page.h +++ b/arch/riscv/include/asm/page.h @@ -115,7 +115,10 @@ extern unsigned long min_low_pfn; #endif /* __ASSEMBLY__ */ -#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr))) +#define virt_addr_valid(vaddr) ({ \ + unsigned long _addr = (unsigned long)vaddr; \ + (unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \ +}) #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -- 2.27.0 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv