From patchwork Mon Oct 24 11:27:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8996 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp439967wru; Mon, 24 Oct 2022 06:03:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5N1GuYf7m8YsyD4eQyQrKWXDD7faC+ElbJSg8r7jIbeCz4HkHS+4xxJBfHzAYySgXw7UdE X-Received: by 2002:a17:90a:7787:b0:20d:3093:ae7f with SMTP id v7-20020a17090a778700b0020d3093ae7fmr71156015pjk.226.1666616615006; Mon, 24 Oct 2022 06:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616615; cv=none; d=google.com; s=arc-20160816; b=AeXinX8ARdBxf74KzJmlkqJjPKo6bZ2gdi+HCXmIFiR9ImDOiKP5wJ2UIF/FnuzX9N n3oL0OGQJHNgzc//ORKLVPbi6QwioolX7Zblx2INXqDSKuyHIqyUHJqFNCDx+8h1Jcc2 pvmTWTntjHamMCv3X5XCYgA5pSzJ1IguOIV9XJjJTpEJaXIhU7Fultjc6PLlVFsq8oqv 6FzP9mL2FqQBzSrtQ+OvG8zcugn4toU3l8sdBCUlL6CJNCK9Dsz4P8q22T4jdVz8FK+i AB4KEr/0iUI9EdykXdNUrmhXVbhQgVY+JeLraayHIAXRToWHyN2uLXlDYFLQbqRVT84X C3bg== 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=hgUxNtk3XEIPN9JxG9DlwPWJDzAzbHU2Ehao+CAA300=; b=WZZZBOic9ZLKuYr0i6+pp9JaXdWbshfvs6NWd/1HLywN87Ummbc7i/wY6MAF6Wg5gh nubioBpuBrZTbCeVgbfYih0GrYITR43/VNqfPlblhr/Ejv0QgzyVU7pdqI/AwFtTeMfg +1cwEZ5MKgDkuuljROJmWj+A9c/nJrKYHMnUGhoB7JgXmwPsQEE36QX5mudW2aAmaVrs O0aUt3RMkconqmX2cquvXwXWqKNT8r0nXQWl6qsB1Pzr9U7dTNdFY4pN3DwigOrnj/54 luIRgpG9K40VODb1McJ0f/vPYXy4UAzwvlsVZh54OlUPaRRMKFrfZ/5NFyg3X0+sNG2K wB3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x9MjdjA9; 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 lp12-20020a17090b4a8c00b002130f4827afsi3677280pjb.87.2022.10.24.06.02.50; Mon, 24 Oct 2022 06:03:34 -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=x9MjdjA9; 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 S234764AbiJXNBz (ORCPT + 99 others); Mon, 24 Oct 2022 09:01:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235097AbiJXM7T (ORCPT ); Mon, 24 Oct 2022 08:59:19 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5FB99A2AC; Mon, 24 Oct 2022 05:18:36 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 531E8612DA; Mon, 24 Oct 2022 12:17:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63701C433D7; Mon, 24 Oct 2022 12:17:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613844; bh=RLkjsXNCeD9Aft4ml7uTuapdTsXixKA/dEjOa/v5+hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x9MjdjA9KM/qObeu1WF3d/so3fvtkRATdxHxjy7OnnuUhnmBgDvPMS8nni7mV69Pn /kD1+DxodV849x1fsG88eqJiO6b15Uw68VLpQJVbjha0B9jmh0ipB6pv3XmNl5l3F4 zECNN902EttNzRqCNGfGTDjcPCdjkK6zgM+Ss5Wc= 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.10 035/390] riscv: Make VM_WRITE imply VM_READ Date: Mon, 24 Oct 2022 13:27:12 +0200 Message-Id: <20221024113024.103392568@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747574183716409701?= X-GMAIL-MSGID: =?utf-8?q?1747574183716409701?= 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 @@ -167,7 +167,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;