Message ID | 20230307140522.2311461-60-ardb@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> 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 00C12C678D5 for <linux-arm-kernel@archiver.kernel.org>; Tue, 7 Mar 2023 14:58:56 +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=GNZea61NYiFsMA4RqIwL+DBP4aFbDAAkUrCxmZwB/GU=; b=D4VTFJXTcINgsC IB7Gw1LsCg1ulYHiZXd6LHc/8aERu8V8C57fL1BU4qbhN91YJpTaIWDccIa9K4E+PB9I/J2wtBZXR 7SW2SeNdrAiSFraMDMIB1f2hcpjngxuKJaIX/bdqdW4UcIGMf52zDmS80KgSXHCnwcOUob4Ho3S6o 9mTtQUSsqnVZkmrICepEvONFLi/qf76zJxPErMy1DvcoLhSqfEwkV5M6MKghiv1e7HTx9UWHLBL+w tJB+nchnTn0GJftvgiiOvj6v6jI3lVGpxh1uMvifdHajPuoTMCzn1jwZz0P9sXW3XQsyQ1feJE4J9 DKw9YW3hQqQjW2bVgdpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZYlA-0010vV-Nk; Tue, 07 Mar 2023 14:57:50 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pZXzx-000f3J-Nd for linux-arm-kernel@lists.infradead.org; Tue, 07 Mar 2023 14:09:03 +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 dfw.source.kernel.org (Postfix) with ESMTPS id E69B561453; Tue, 7 Mar 2023 14:09:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61930C433A7; Tue, 7 Mar 2023 14:08:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678198140; bh=xuULnbPfbdttGoFOmg13d9wHbRDgqXccUG7zc0Xws00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ngCYk9bgPrkWxLrO/DwctYGOfpl/Q05CONePs/WxVd+HIvSDWTC3xFQ8ZcQFBAKT5 12xahHMOJ0OLIEJ8t3h0RxasgdkSgkaURegHIqbtzUAl6dfZ9dQ6qewtnRxvM2mshP oqp3nvPUxlXRcdhABrMVAn9DvTvUyEzpY4VDQytcYkKnKIU1wOMoeRENPGT3vRiuTC m1QkKryos2bl6wPHy0pQlORMSgRLAOJeYHCF9BQhCIFG9o/NW+zAKNJ2/87CqLuDYG WJmOEE1+W0Hh54MaowkecB17GiGnFHzVaFmWXKZCrzZOa9igvtuZYIEg5qW2nb9lxf QlHH6kjJU5OvA== From: Ard Biesheuvel <ardb@kernel.org> To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel <ardb@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Ryan Roberts <ryan.roberts@arm.com>, Anshuman Khandual <anshuman.khandual@arm.com>, Kees Cook <keescook@chromium.org> Subject: [PATCH v3 59/60] mm: add arch hook to validate mmap() prot flags Date: Tue, 7 Mar 2023 15:05:21 +0100 Message-Id: <20230307140522.2311461-60-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307140522.2311461-1-ardb@kernel.org> References: <20230307140522.2311461-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1745; i=ardb@kernel.org; h=from:subject; bh=xuULnbPfbdttGoFOmg13d9wHbRDgqXccUG7zc0Xws00=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIYXdZeGyK2eU0oUmac6b8DmnMD7ezH3OIq2tu4KmLvTJX f1uWr50RykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZgIlyLD/6qfL5S3a57yOmL8 6ewT7hB97bz6Y07vEsNkHuWGzFNhDGL4pydebBxtee/HmRUXhZfp9srMFLqW+lNEvCjoVXJR7J9 ePgA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230307_060901_895160_5506BD51 X-CRM114-Status: GOOD ( 14.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
arm64: Add support for LPA2 at stage1 and WXN
|
expand
|
diff --git a/include/linux/mman.h b/include/linux/mman.h index cee1e4b566d80095..25ffe6948fa21ff8 100644 --- a/include/linux/mman.h +++ b/include/linux/mman.h @@ -120,6 +120,21 @@ static inline bool arch_validate_flags(unsigned long flags) #define arch_validate_flags arch_validate_flags #endif +#ifndef arch_validate_mmap_prot +/* + * This is called from mmap(), which ignores unknown prot bits so the default + * is to accept anything. + * + * Returns true if the prot flags are valid + */ +static inline bool arch_validate_mmap_prot(unsigned long prot, + unsigned long addr) +{ + return true; +} +#define arch_validate_mmap_prot arch_validate_mmap_prot +#endif + /* * Optimisation macro. It is equivalent to: * (x & bit1) ? bit2 : 0 diff --git a/mm/mmap.c b/mm/mmap.c index 740b54be3ed4140f..02ccd45df0194796 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1214,6 +1214,9 @@ unsigned long do_mmap(struct file *file, unsigned long addr, if (!(file && path_noexec(&file->f_path))) prot |= PROT_EXEC; + if (!arch_validate_mmap_prot(prot, addr)) + return -EACCES; + /* force arch specific MAP_FIXED handling in get_unmapped_area */ if (flags & MAP_FIXED_NOREPLACE) flags |= MAP_FIXED;