From patchwork Mon Oct 24 11:26:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp481393wru; Mon, 24 Oct 2022 07:23:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Ec/spatWxR0M5aZUMb3aaPT1um4RhIwPqfNCqLuUBsHIm5+bXXqeH8wJq8uO/vLg6s1II X-Received: by 2002:a17:907:3f26:b0:78d:9c30:4529 with SMTP id hq38-20020a1709073f2600b0078d9c304529mr27672424ejc.195.1666621382417; Mon, 24 Oct 2022 07:23:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621382; cv=none; d=google.com; s=arc-20160816; b=FvWzUZztuthSw95GlPXgLdHM5+DvsMFTvgsytNJvfvrEoEdIKzqMQAwuNvi7xT/ER9 k2Jqm4YFGwg5RqO9Fwca2OMNQYJRgFgteSmd2n7wyJDqMfFCm69F2adLs6R+tyd5naRo H1Hyj9+ZkfYhp88OvwyrkYAfJrWre7d5EIbwLpWK75yZMZjnfNlPm4Q7si4rEmhc7ZiN jdC4D8X6CSAbS9GiGyELb4hJJYp9RYoVx8HhIzL75bYg+/3RKNOpD2txTdrBuS2U/WEY UIjiOV+TZez7E7JGnA/rO/J+z+BA1msxclSFGZeFR5pQz2GFZlz1k1mIJ+r4umZCl1NH okVw== 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=Lp8Vn0X7eCXWpccKoFbe44HNtsKHOFR79VkoBD6zQIQ=; b=zrL4MD2ugRGewtQC7CfiP34XHpaQ47U6H+7VE/eYGOTMdoKIvsVRz053pq1jCSSPTY Zq9/e+/48ETHe5RfbUx+YK53TraBXsbsXzYLMhq1eB3mOHNogQyX3DP5Jp4qXbm6jj/l ZWRx26ZrjMDXKczDpL8ShRrg6CrqNkpBteXc4RyOkqM9lArtSXRFm8bET+qF4WxsVd+t WFsdhLpAeo+7GDWPBA41HSdlaisC3/6DRPszpoxjiyBGsQWz269s2ptXQuaox+dnN9h8 Th/CJpdkV/zXtB1a5KGtNLl7ifNyATWgPU0Zb01pz6e3hiBGZvyIC+c3P+BkDezNNAoL 8vcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=l5xwtdMs; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z2-20020a056402274200b0045cf3f51a34si32884371edd.24.2022.10.24.07.22.36; Mon, 24 Oct 2022 07:23:02 -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=l5xwtdMs; 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 S233897AbiJXOSQ (ORCPT + 99 others); Mon, 24 Oct 2022 10:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234946AbiJXOOR (ORCPT ); Mon, 24 Oct 2022 10:14:17 -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 E9F7492CE5; Mon, 24 Oct 2022 05:54:07 -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 5CC83B8172B; Mon, 24 Oct 2022 12:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B2FA2C433D6; Mon, 24 Oct 2022 12:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614891; bh=Q3bJL7AcK+e7dG8IoaG3j0chEM628/hmPM5Z4F2I6jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l5xwtdMs7HsqJ46cikjYwovTludYtg2Ntl6obqeCnx6hiUBqC1D0dFHpumjW2Ykaz xWrLfd+NgogI3FTOl/0m9zxyX+FexKAbDaD6lgcyxXBOZXDW/WRTa5JtZfhrajPAVp sFMcRypQbZugQsfS0ZXnENtZvv/jlzSOnLu0NH9o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Atish Patra , Andrew Bresticker , Palmer Dabbelt Subject: [PATCH 5.15 043/530] riscv: Make VM_WRITE imply VM_READ Date: Mon, 24 Oct 2022 13:26:27 +0200 Message-Id: <20221024113046.972620791@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579182819106748?= X-GMAIL-MSGID: =?utf-8?q?1747579182819106748?= From: Andrew Bresticker commit 7ab72c597356be1e7f0f3d856e54ce78527f43c8 upstream. RISC-V does not presently have write-only mappings as that PTE bit pattern is considered reserved in the privileged spec, so allow handling of read faults in VMAs that have VM_WRITE without VM_READ in order to be consistent with other architectures that have similar limitations. Fixes: 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid") Reviewed-by: Atish Patra Signed-off-by: Andrew Bresticker Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20220915193702.2201018-2-abrestic@rivosinc.com/ Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/mm/fault.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/arch/riscv/mm/fault.c +++ b/arch/riscv/mm/fault.c @@ -188,7 +188,8 @@ static inline bool access_error(unsigned } break; case EXC_LOAD_PAGE_FAULT: - if (!(vma->vm_flags & VM_READ)) { + /* Write implies read */ + if (!(vma->vm_flags & (VM_READ | VM_WRITE))) { return true; } break;