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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D93BC433EF for ; Fri, 17 Dec 2021 13:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236779AbhLQNpP (ORCPT ); Fri, 17 Dec 2021 08:45:15 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:45870 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236694AbhLQNpO (ORCPT ); Fri, 17 Dec 2021 08:45:14 -0500 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 4B4A36220F for ; 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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