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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1828EC28B2B for ; Sun, 14 Aug 2022 16:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ELZTyeq9jny9x6WCitCRxkjJHXOIXQY0t2EEEFL9KIQ=; b=3GHihPXB2mToSX nOSSO9zBGOEh5rFe87eDXWx7UkG5S3VaSzfM4ac6lB5f8YYGi3SpfW6NyQ6hZtROJor8YfzV1bQKh kKNuxHCD5ukPusMarwsOVfH3RR5Wcs4XoNH2hVyt0CVn4wxJLbqh/xydhwtnt+uXRHaSkjhJyAef0 KRuoMUyGlt834yN3S7pBXD+eMcQlYichBLjHUFyqfnmWMEGjJmJSarPRPI9EZIEVcgOlgJ8+zmiX6 6mYVo5TZ4a/4XjyjjGvx3X8mz8FNyTx5cU8aKAKm/ejeR6QimH+tIfoVdcxqwh0M0jf1lESmgWOoy QBlMnH3GHJTzu4CRKWTA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNGMJ-007pro-11; Sun, 14 Aug 2022 16:21:03 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oNGMF-007png-Ej for linux-riscv@lists.infradead.org; Sun, 14 Aug 2022 16:21:01 +0000 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 2885DB80AEE; Sun, 14 Aug 2022 16:20:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6558BC433C1; Sun, 14 Aug 2022 16:20:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660494056; bh=ZvgNG1eC9iccsixk7C5q3yyyNPKNAPFVwtvxIcix/aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ksTillY2i2DDyzU1zbmt6w9PL46A2kQtIxoZN4F1JOlErjLLATaIxcDCkTFyZMZkF ZX+quEkAZSJPKD1iCaN0WSp/oHwxu3dqgosTuqMT0F3Bkv5iga0Oq9BnGEFY3jnoQW pTwTDIYJmWF03soW0ozefZNN1tuTHbyHwtQTrizLDQsgIMrqHPlyCWfiooRivHEDaF kWAOcq8sTe46m2LHsQ44XxL7glAvdgkLLLRYR3uu/n+JGRN1J3SJ7YM3jqiiO12NHN LjmItx2UCEsn4o7bZgREneNK5SjaAmqKg39ykmftBB8uxrwrTofR2st4xavkT1jfFN dWo1Z1NcP0yuw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Celeste Liu , xctan , dram , Ruizhe Pan , Palmer Dabbelt , Sasha Levin , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, guoren@kernel.org, arnd@arndb.de, linux-riscv@lists.infradead.org Subject: [PATCH AUTOSEL 5.19 20/48] riscv: mmap with PROT_WRITE but no PROT_READ is invalid Date: Sun, 14 Aug 2022 12:19:13 -0400 Message-Id: <20220814161943.2394452-20-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814161943.2394452-1-sashal@kernel.org> References: <20220814161943.2394452-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-20220814_092059_791127_30E7EC24 X-CRM114-Status: GOOD ( 11.19 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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: Celeste Liu [ Upstream commit 2139619bcad7ac44cc8f6f749089120594056613 ] As mentioned in Table 4.5 in RISC-V spec Volume 2 Section 4.3, write but not read is "Reserved for future use.". For now, they are not valid. In the current code, -wx is marked as invalid, but -w- is not marked as invalid. This patch refines that judgment. Reported-by: xctan Co-developed-by: dram Signed-off-by: dram Co-developed-by: Ruizhe Pan Signed-off-by: Ruizhe Pan Signed-off-by: Celeste Liu Link: https://lore.kernel.org/r/PH7PR14MB559464DBDD310E755F5B21E8CEDC9@PH7PR14MB5594.namprd14.prod.outlook.com Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- arch/riscv/kernel/sys_riscv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/sys_riscv.c b/arch/riscv/kernel/sys_riscv.c index 9c0194f176fc..571556bb9261 100644 --- a/arch/riscv/kernel/sys_riscv.c +++ b/arch/riscv/kernel/sys_riscv.c @@ -18,9 +18,8 @@ static long riscv_sys_mmap(unsigned long addr, unsigned long len, if (unlikely(offset & (~PAGE_MASK >> page_shift_offset))) return -EINVAL; - if ((prot & PROT_WRITE) && (prot & PROT_EXEC)) - if (unlikely(!(prot & PROT_READ))) - 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.35.1 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv