Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1489010rwi; Thu, 13 Oct 2022 14:37:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6Pe2x5GcoCRdjrqbi+Y32NfWaNMNxFK2qO5zvXspSpd/5cFbZTwhgPHlSRUF3beK7wOXzl X-Received: by 2002:a17:907:1608:b0:78e:1e21:6359 with SMTP id hb8-20020a170907160800b0078e1e216359mr1321950ejc.205.1665697033993; Thu, 13 Oct 2022 14:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665697033; cv=none; d=google.com; s=arc-20160816; b=tDkAnBtsNGkgGeX/V7GuI/Ev2cxrXFJfrLYBZXj9KK3+3LFQ0o5M2ZJCf70e7OQeBx pxAxQR/3tJhvI9lvvs/2eQMiJR0P3tj/ToKCNZw+fmmCZWuCF303n52kqYu7Lnla03pO hf2Uokxo4KqaEiLkbPiK8BybJb+7w4H7o3ABsRP0rHHTQU2My+RYU02ZCWhP4azrt5L3 4I8vf8hXXZ49t1iQK5WfouqEtGD6W3+PTG6rZnOqF9dQRDw4KWUSLbUwOWqtTtl5qRXB cbBrtswSe/n+a9i8I10OrUq/KrOeCMg0S24ozZZvHuAgIM2khnMgFHBlUjCQ+O2AGR0k rTpA== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=Jdu8CDhPFUGuuqJLB1hm8uRgcdUvFaGH3LFEE7wY72E=; b=sFFxTQ3cFoPnmaSGsEPTS3EbQq3CSLK2b/BvVh4xPqCukid9fpzUSx+OOrslPhH8QP dEB1pxhjZ1t1ugtdrM0Y0gLIMJWX4xi7F15yOV13EvzoUVDE4qTgLC/eGpimR1gXfJpH M0I4e5KNXqi4pXjvrZCFZO9pfGy1ey6N89fiBbG/DvB1aFGHpoqYl+USSvwh5JhPWqDW tKOWHR5NlvPU9ioeO3R3FCXAn/KWI7+IxW/y+/o/Z7PLNoGLzE/HjoW+eFWNjKmY5uA1 mYAq3rb4GZXA+SFykc7YKgcT6hfKd5I7eTfm1n5YZodzrK6pVfYyTBaon2+PXy3ob0Dd jQQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=t3NB2tnT; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji6-20020a170907980600b0073d6ad8251asi745088ejc.812.2022.10.13.14.36.02; Thu, 13 Oct 2022 14:37:13 -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=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=t3NB2tnT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229989AbiJMVBa (ORCPT + 99 others); Thu, 13 Oct 2022 17:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229986AbiJMVB0 (ORCPT ); Thu, 13 Oct 2022 17:01:26 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 170C61793A8 for ; Thu, 13 Oct 2022 14:01:25 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id z20so2894315plb.10 for ; Thu, 13 Oct 2022 14:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:from:to:cc:subject:date:message-id :reply-to; bh=Jdu8CDhPFUGuuqJLB1hm8uRgcdUvFaGH3LFEE7wY72E=; b=t3NB2tnT0mOyQNL9SqfMc3Y7GNvuenW4Yj9HqN57Y/yVtpYG8bqNmlprt00zkcnvli Obq7zW1RMHD9vOWjVQ3IKBcRS/3+J2JS40IujCdx+lxEzQrysdaZ+PekVHybVUDZ61rv HaBQNyAMXTPC78lu4kmOOyS5eypmwPQGVzg4djhqYBXV+5JNfXI9wQsQLMS0ywa9zMMx GAqg8GtUZGLgvq5Chtb3MjkGhS2Hxuk6nvFLsFTbq9ZeB8G/5nQa3/q/ogVb5PTHJP+o 585fZTcCdT0YWiI1q5FI2p+cZs7xjz6ZI0ziP/Q7AVKlhYyDTOPvXzrtvCVoCicSxFEc axkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from:cc :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Jdu8CDhPFUGuuqJLB1hm8uRgcdUvFaGH3LFEE7wY72E=; b=jWE4z075/y/tXNCUxmgUYu7vC26Uqyh0Lf0unrphgiLDAx315s3Eb/WQtcd1t8C+WB VHETMYZVplms/DhAXz6KJM82giH5RvQZ9uKtEC72D7q8tJItdXAywLbEnNQlLsmRryEF KS7vi4WNR0T0PBR+n1qrzcDauE3toGKfvPE9UFat7aqG4zMRsTmESnEVBdBa+yfjYD9z YfUGu1suLbvJ3VmfCkrCamRKmH38ec9JhtEo4/gw5JpaNm7IYSXXDyJKHi/7d/cGxO9U rn/FELh88GI9w/34emznR0JGmaVFvc9VR4uaPIMmkZgELDDwwPdIumdgZK43EZ+y2pCS 7gLg== X-Gm-Message-State: ACrzQf3Gn6Bl4K05dS5YXRHG53d8QjDq+py2lngfArZYMi9hPpxPerA+ l/toxIzkcYdB7e+jvqbZRb0hUg== X-Received: by 2002:a17:902:e549:b0:184:5c4a:fad0 with SMTP id n9-20020a170902e54900b001845c4afad0mr1659214plf.6.1665694884466; Thu, 13 Oct 2022 14:01:24 -0700 (PDT) Received: from localhost ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id 12-20020a170902c20c00b001750361f430sm274955pll.155.2022.10.13.14.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 14:01:23 -0700 (PDT) Date: Thu, 13 Oct 2022 14:01:23 -0700 (PDT) X-Google-Original-Date: Thu, 13 Oct 2022 12:51:26 PDT (-0700) Subject: Re: [PATCH v4 0/2] Make mmap() with PROT_WRITE imply PROT_READ In-Reply-To: <20220915193702.2201018-1-abrestic@rivosinc.com> CC: Paul Walmsley , coelacanthus@outlook.com, dramforever@live.com, c141028@gmail.com, Conor Dooley , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, abrestic@rivosinc.com From: Palmer Dabbelt To: abrestic@rivosinc.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 On Thu, 15 Sep 2022 12:37:00 PDT (-0700), abrestic@rivosinc.com wrote: > Commit 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is > invalid") made mmap() reject mappings with only PROT_WRITE set in an > attempt to fix an observed inconsistency in behavior when attempting > to read from a PROT_WRITE-only mapping. The root cause of this behavior > was actually that while RISC-V's protection_map maps VM_WRITE to > readable PTE permissions (since write-only PTEs are considered reserved > by the privileged spec), the page fault handler considered loads from > VM_WRITE-only VMAs illegal accesses. Fix the underlying cause by > handling faults in VM_WRITE-only VMAs (patch 1) and then re-enable > use of mmap(PROT_WRITE) (patch 2), making RISC-V's behavior consistent > with all other architectures that don't support write-only PTEs. > > Both patches are tagged as fixes for the aforementioned commit since that > commit made a userspace visible change that will break any software relying > on mmap(PROT_WRITE). (Also cc: stable since the offending commit was > itself backported to stable). > > v1 -> v2: Allow handling of load faults in VM_WRITE VMAs > v2 -> v3: Split into two pathces > v3 -> v4: Fixes tags (+ this cover letter) > > Andrew Bresticker (2): > riscv: Make VM_WRITE imply VM_READ > riscv: Allow PROT_WRITE-only mmap() > > arch/riscv/kernel/sys_riscv.c | 3 --- > arch/riscv/mm/fault.c | 3 ++- > 2 files changed, 2 insertions(+), 4 deletions(-) Thanks, these are on for-next.