Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1130625rwn; Thu, 15 Sep 2022 10:55:04 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/VamCMSah7BMHNVRlXOVy5SiALZCvyhNYxEQFRgDImlXMbOd1aYW+xYmMBHL19TPHL5SR X-Received: by 2002:a17:906:9c82:b0:6e1:2c94:1616 with SMTP id fj2-20020a1709069c8200b006e12c941616mr793030ejc.64.1663264503953; Thu, 15 Sep 2022 10:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663264503; cv=none; d=google.com; s=arc-20160816; b=ejAA4WjVc7o7Tqc3jAkxQPUGqdyAqNLXXtqsz6FlqXdt/uWtLfi/y/vzvcoYvaBV/M VzBjMCBODhI17IthZ1pqD1krnYL2k9gCS8O2tHR44x80hPQ3z7I8pAoLydA3qRGGt5KH u6fX7w6GLIOqPq0petpH4tz/X7t2UwF/Ijo4IaSofsw5rl5P6Ljotiw90xmhwEdM8A2u BW9KkQyrM3FjvJe69t+c+Bh39UtzrERNYp3nnz0zJNSgYFB+vgfsEBWjz/IXvufXCwBm iaw+h2oAP4PRLnxlyYCMAlURHcufYrZ7SUd4jvSz1t1ymiB16svz2zogAwEdcfo21eVg 0IAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2byv70u9LxFyqg2KEOTjIwO2wrYAaSWdRlHkqPRd+W0=; b=l4p7GtpMwcgY/bUuFzBoxCZOtFJEiO5GR/gBVCDVOt6h2D2JLV3MNbxoXHDnlNP8Tf 08aE7Uxa4zcq25p5pmHjIF5jCn6viY+5fV3JukuyhClsITLN2oWLya0/b909lcAX0Gy9 zxM4f9rZksteHUZwCbq6+p0s026Ns/FCS+bY5esiUWnXsX1721k9Ve7VTiGDasb7mzTy d011g7WMLkCIyFs0uNIbplpXwR3Zqd7I7yddbxKmgkwOKcC6sMHV433C1O734U7vP9TK BnMJIcQXej4X4VeRC9HDx1c7GmvsH2w0woMPLMO8efZqenWh1dct7IOo27lnPbGxPr03 wl3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=L8REomJA; 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 gs32-20020a1709072d2000b00733069541b8si13228772ejc.102.2022.09.15.10.54.37; Thu, 15 Sep 2022 10:55:03 -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=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=L8REomJA; 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 S229658AbiIOR1U (ORCPT + 99 others); Thu, 15 Sep 2022 13:27:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229484AbiIOR1P (ORCPT ); Thu, 15 Sep 2022 13:27:15 -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 2BA5F98D00 for ; Thu, 15 Sep 2022 10:27:13 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id t3so19020542ply.2 for ; Thu, 15 Sep 2022 10:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=2byv70u9LxFyqg2KEOTjIwO2wrYAaSWdRlHkqPRd+W0=; b=L8REomJAnSSsKQQzOccREDQKI9QUe7j4kqYbUwlEK63BVvueOkP7HwF3Tg7LnN/LFo /EJAwjeIXrHCEfKGogFKKN0yGLPkwTBQnm9MmJGlA1fR1a2sOP3pwqi5j7AEZxerVynj n2GoZqNPHjwjRRmK9irk4vWQt+me36EeVoTpY5suYkVKLl8qjhzWR2VmAvcgYG+GHw2V dTgyxZGRdRtKxHDMny3JQhLtWvT/1gfQJzuTQqC6Kmpkwg53qGC5Oa9+HxCA29o9lDIq hJsZbmL5odvBBr+4xDP0KjoZ8KCmRsCUtVhF7lRUBWk1Nq0L0KpnW5dRkVide/uMppBb HYMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=2byv70u9LxFyqg2KEOTjIwO2wrYAaSWdRlHkqPRd+W0=; b=b5j0jclO3VfXA2wNK9kWUKXy0/w9cbU6A2bjY7SifXgJ+2CWtarvh08SMN7hixe18Z Fea0ZUykbUXoMeU9XMYmzDsGgnH7le5ijp9XbyjR/xKZAjzTcSGLGnY38yc+siz+pFKO NBgX9wmmgkrFhQthblZPSunk1CbZoHmcj+mgsswG6WiWW8lBB2zomIdXWjH68y3JXwAs ggBJh1+jOMr99mlH0eS78YYQpPtKVj4vVfFpANzpytrQyZQPiQCNMx688GKS69vTt/2x 5QQVpof4c6LvpnxSQcFDHvKHM3b0IomOiuAog5sYS4H7wr0Nd9T6CYIjTHK1cu5LGJSy 8V4g== X-Gm-Message-State: ACrzQf3cO9cBrP/vT7kJBEKwNKDYm/5VICYHl/lR5tHtNRAXX7T5vO7Q sQrthVrbbtJy/XwSnpd7NUl90QFQriu+aMJw8EAzQw== X-Received: by 2002:a17:902:bb97:b0:175:6721:2c34 with SMTP id m23-20020a170902bb9700b0017567212c34mr621209pls.146.1663262832597; Thu, 15 Sep 2022 10:27:12 -0700 (PDT) MIME-Version: 1.0 References: <20220909212731.1373355-1-abrestic@rivosinc.com> <20220909212731.1373355-2-abrestic@rivosinc.com> In-Reply-To: From: Andrew Bresticker Date: Thu, 15 Sep 2022 13:27:01 -0400 Message-ID: Subject: Re: [PATCH v3 2/2] riscv: Allow PROT_WRITE-only mmap() To: Conor.Dooley@microchip.com Cc: Palmer Dabbelt , Paul Walmsley , Celeste Liu , dram , Ruizhe Pan , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Atish Kumar Patra Content-Type: text/plain; charset="UTF-8" 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, Sep 15, 2022 at 12:56 PM wrote: > > On 09/09/2022 22:27, Andrew Bresticker wrote: > > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > > > Commit 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is > > invalid") made mmap() return EINVAL if PROT_WRITE was set wihtout > > PROT_READ with the justification that a write-only PTE is considered a > > reserved PTE permission bit pattern in the privileged spec. This check > > is unnecessary since we let VM_WRITE imply VM_READ on RISC-V, and it is > > inconsistent with other architectures that don't support write-only PTEs, > > creating a potential software portability issue. Just remove the check > > altogether and let PROT_WRITE imply PROT_READ as is the case on other > > architectures. > > > > Note that this also allows PROT_WRITE|PROT_EXEC mappings which were > > disallowed prior to the aforementioned commit; PROT_READ is implied in > > such mappings as well. > > > > Fixes: 2139619bcad7 ("riscv: mmap with PROT_WRITE but no PROT_READ is invalid") > > For the naive members of the audience such as myself, this patch > came after a non-fixes patch in the series. What is the dependence > of this patch on the other one (if any)? This patch is dependent on the first. Happy to re-spin with a "Fixes" tag on the first patch (or maybe Palmer can add when applying). -Andrew > Thanks, > Conor. > > > Reviewed-by: Atish Patra > > Signed-off-by: Andrew Bresticker > > --- > > v1 -> v2: Update access_error() to account for write-implies-read > > v2 -> v3: Separate into two commits > > --- > > arch/riscv/kernel/sys_riscv.c | 3 --- > > 1 file changed, 3 deletions(-) > > > > diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c > > index 571556bb9261..5d3f2fbeb33c 100644 > > --- a/arch/riscv/kernel/sys_riscv.c > > +++ b/arch/riscv/kernel/sys_riscv.c > > @@ -18,9 +18,6 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len, > > if (unlikely(offset & (~PAGE_MASK >> page_shift_offset))) > > return -EINVAL; > > > > - if (unlikely((prot & PROT_WRITE) && !(prot & PROT_READ))) > > - return -EINVAL; > > - > > return ksys_mmap_pgoff(addr, len, prot, flags, fd, > > offset >> (PAGE_SHIFT - page_shift_offset)); > > } > > -- > > 2.25.1 > > > > > > _______________________________________________ > > linux-riscv mailing list > > linux-riscv@lists.infradead.org > > http://lists.infradead.org/mailman/listinfo/linux-riscv >