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 98D25C433F5 for ; Fri, 17 Dec 2021 13:46:52 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3Rv+lahfrz7tIYZhiIL1g5PGouVsiDwV+gj2FOermvw=; b=tZgamL1tDNpRym SierHUdfi0vD6nuZoI4RyWD3D6B2aC7iZ9KHjygnopLGkQf0d+cEwBJ2is71p30of4iK14OyB+Ru/ 06nptUsnC3WNWTDEmNBa26pAPwxGy+ehLrehD4Cb8g0s1q3KR2jo2z3rhU6d7fWJ5tnoAcAs7RAuk GQNaddo+iFXi8CpBERapRbFFJKxQYwj/TwAPDv/1id3c4rjQDGrdCFhzi6FxBKfKWrQSZeVIhvGCU 0iOC92I4Zz0P72x8G8+wtWVlGNiv6/LqPvWscBgFvYh0ZmbDSxMOZ0zZKitfI7Bf1wdMOETNIjdRt kncwbj4M87ixywR5u3nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1myDYG-00AR5i-5M; Fri, 17 Dec 2021 13:45:36 +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 1myDXu-00AQz5-Pc for linux-arm-kernel@lists.infradead.org; Fri, 17 Dec 2021 13:45:16 +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 4E03D62210; Fri, 17 Dec 2021 13:45:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D017FC36AE7; Fri, 17 Dec 2021 13:45:10 +0000 (UTC) Date: Fri, 17 Dec 2021 13:45:07 +0000 From: Catalin Marinas To: andrey.konovalov@linux.dev Cc: Marco Elver , Alexander Potapenko , Andrew Morton , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH mm v3 31/38] kasan, arm64: don't tag executable vmalloc allocations Message-ID: References: <4a5ec956a2666c1f967c9789534a8ac4d4fe26f9.1639432170.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4a5ec956a2666c1f967c9789534a8ac4d4fe26f9.1639432170.git.andreyknvl@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211217_054514_910145_C345BB44 X-CRM114-Status: GOOD ( 13.56 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Dec 13, 2021 at 10:54:27PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > Besides asking vmalloc memory to be executable via the prot argument > of __vmalloc_node_range() (see the previous patch), the kernel can skip > that bit and instead mark memory as executable via set_memory_x(). > > Once tag-based KASAN modes start tagging vmalloc allocations, executing > code from such allocations will lead to the PC register getting a tag, > which is not tolerated by the kernel. > > Generic kernel code typically allocates memory via module_alloc() if > it intends to mark memory as executable. (On arm64 module_alloc() > uses __vmalloc_node_range() without setting the executable bit). > > Thus, reset pointer tags of pointers returned from module_alloc(). > > However, on arm64 there's an exception: the eBPF subsystem. Instead of > using module_alloc(), it uses vmalloc() (via bpf_jit_alloc_exec()) > to allocate its JIT region. > > Thus, reset pointer tags of pointers returned from bpf_jit_alloc_exec(). > > Signed-off-by: Andrey Konovalov Acked-by: Catalin Marinas _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EBD9C433EF for ; Fri, 17 Dec 2021 13:45:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E5CA6B0071; Fri, 17 Dec 2021 08:45:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 795A96B0072; Fri, 17 Dec 2021 08:45:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65D206B0073; Fri, 17 Dec 2021 08:45:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0208.hostedemail.com [216.40.44.208]) by kanga.kvack.org (Postfix) with ESMTP id 53A796B0071 for ; Fri, 17 Dec 2021 08:45:26 -0500 (EST) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 173DD181AC9C6 for ; Fri, 17 Dec 2021 13:45:16 +0000 (UTC) X-FDA: 78927407832.13.35E7C19 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id BFE3E40023 for ; Fri, 17 Dec 2021 13:45:15 +0000 (UTC) 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 4E03D62210; Fri, 17 Dec 2021 13:45:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D017FC36AE7; Fri, 17 Dec 2021 13:45:10 +0000 (UTC) Date: Fri, 17 Dec 2021 13:45:07 +0000 From: Catalin Marinas To: andrey.konovalov@linux.dev Cc: Marco Elver , Alexander Potapenko , Andrew Morton , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: Re: [PATCH mm v3 31/38] kasan, arm64: don't tag executable vmalloc allocations Message-ID: References: <4a5ec956a2666c1f967c9789534a8ac4d4fe26f9.1639432170.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4a5ec956a2666c1f967c9789534a8ac4d4fe26f9.1639432170.git.andreyknvl@google.com> Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf07.hostedemail.com: domain of cmarinas@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: BFE3E40023 X-Stat-Signature: r7msbk85jrzmaoafrjsb36tj95cwu5ke X-HE-Tag: 1639748715-668979 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Dec 13, 2021 at 10:54:27PM +0100, andrey.konovalov@linux.dev wrote: > From: Andrey Konovalov > > Besides asking vmalloc memory to be executable via the prot argument > of __vmalloc_node_range() (see the previous patch), the kernel can skip > that bit and instead mark memory as executable via set_memory_x(). > > Once tag-based KASAN modes start tagging vmalloc allocations, executing > code from such allocations will lead to the PC register getting a tag, > which is not tolerated by the kernel. > > Generic kernel code typically allocates memory via module_alloc() if > it intends to mark memory as executable. (On arm64 module_alloc() > uses __vmalloc_node_range() without setting the executable bit). > > Thus, reset pointer tags of pointers returned from module_alloc(). > > However, on arm64 there's an exception: the eBPF subsystem. Instead of > using module_alloc(), it uses vmalloc() (via bpf_jit_alloc_exec()) > to allocate its JIT region. > > Thus, reset pointer tags of pointers returned from bpf_jit_alloc_exec(). > > Signed-off-by: Andrey Konovalov Acked-by: Catalin Marinas