Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1038766lqo; Fri, 17 May 2024 08:57:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUM9nc9Puw74Z5vH5cXFIK7khzLOzPnbYLAjOQtokoSN80IvpZ68rkNv7yC01mihbStezveWBl08cbXEbtasGv28JkLzg4Ibe5G5hQafA== X-Google-Smtp-Source: AGHT+IGCYzykYV6KF2OFbJ8DruyvCAWqtpa2SMkLgc58FzgIZnz1MO/Hx05NGoQ4La7cHS8+RLQl X-Received: by 2002:a05:6e02:1c23:b0:36a:36d9:36eb with SMTP id e9e14a558f8ab-36cc1501cb1mr245664375ab.27.1715961437208; Fri, 17 May 2024 08:57:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715961437; cv=pass; d=google.com; s=arc-20160816; b=BvXHVj5RawJVGVKEfKc7mu7IL3YqC3LqLadNEY1+yeXCoND/zAICxsKk8inVkPjDtp /KJyyuS0RpXM9y0WaC0WV1gXQvPKkWs+n3fHz5oUpO7vX4374gUSEScnIHMheUcDX8T+ V1sJ2PKhgPqzoZwNqHGWcP7lpnjpeoMZt19e6/EvOU+muPgUM8qK8pWxQ4brIbY8I+qU MCrYflDXWiNUe9ku2TTXi+ZcgHRfOmg0siaDmWItzlnGc+aOVipyRy3u+Y+2YUr6NKnl 5yvVd8eqtl2/1rhLTUZsZTWML9sJojFxe6gtiy/D3I+pOpfGgyPwuqW1/EZ5jV9VLoSK sujQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oTrjQi7xQJ0WGjkZSqMK9KN32AYtmDF0sBNqEPXnHlc=; fh=h6h4QtHCCzrPQxAtoOjSWL2iMYPwNMsDVeWOH9Wix4s=; b=jAGnyrJVXaS158R4bCRlj2tjZak6W/LRpn6UTo7N5JTQCtY1uP3gHH5PGDroDOBcCq ufmVPnq2KYJcOtTri6Ci3QO3+O89E+SIqnsK/gE8HJDG3vY/GdJtydOEZlwJY03nVVek uEMT0YjQBWO1EBrY8q1bZAuXY1IEiT07l0fdoGVZS9b+HxPHBUzWCJEfjBRKsLzzw6uf bBrD2vmEetBOe93qlUrF22033hlwN1GNdxEG6TwcRwlCVhfccZWnqgJdFdiw6CMvPF0C OrDZRmW0vZDKSX/kkWT9Wp/Kk85lmNVWbicJRph+QL6wdipjfXJD0sE58MT5mgzvzmRm 7fsA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qPsMCEt7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-182314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63411719264si18426995a12.492.2024.05.17.08.57.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 08:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qPsMCEt7; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-182314-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182314-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 163AF288EBF for ; Fri, 17 May 2024 15:47:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2F7512FF69; Fri, 17 May 2024 15:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qPsMCEt7" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1FED12F5A3; Fri, 17 May 2024 15:46:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715960805; cv=none; b=gD8HYbVUMThpuyZ8qsBs01Umko4W99irkrqfgoYL5QZ31P+g+zVhyR+0DoDFCF15cmaqKMiv4xZEK2YF51cfOy9PBkzfZ8scdLOMPD6oeFmouXvGb9nr73C2QmWIR8xR/dti6z3AowYxTM9+o2qmF/aI56LCOCtd67Mc8lOVNoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715960805; c=relaxed/simple; bh=EpkhHazhMZ2fwuDobsplhqZvRLo+YDrsHfPiI4NpGv4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tKACy+u1+YztLmWQdjIiCnkGINYxyXb6Ut+09sAoH/qghxGCCU01rG3+LAFET8qc4JwFGgFIxIAxZryqeu80xnpu35x0RC0EodpbWWvApr86E2ooFn8RYqZM6vWE0/WPeIuRQiBUEqaKiBu+vmZWSXuzZ9HDN1J32+/geUD7pw8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qPsMCEt7; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 111FAC4AF67; Fri, 17 May 2024 15:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715960804; bh=EpkhHazhMZ2fwuDobsplhqZvRLo+YDrsHfPiI4NpGv4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qPsMCEt72a5yEc9EgEt6r+yjYEkV9BPAe1xRO8Mnx0FWUaiC9lvILRG04VRJZWw48 6oi3NhTWACIBMVCpaYFZBzGgjvog9Y2TBWGjwbtg4as/XPHXHwLo0KeYmlix1Tn8jJ 4VeuQ6blAMOigvYJG5R5zp9Slb7rxBGhcGmnSRhVLw3HY2TMrkHzFxNCfy5TM2KOl7 3goZJdJ9Tr8Zr9DvcjkvtgL8pUnnLDDUJrwFLygDVMOs6MaI5wNJFVtqt+sDPTLZKE 8D0fBgS7iYh917OFn63YR+c8+L84i4xjQMciA0V/P7pqzz6WoJLNRgmPCqv4y8iZTU E4tvvudi2KGsA== Date: Fri, 17 May 2024 16:46:32 +0100 From: Will Deacon To: Klara Modin Cc: Mike Rapoport , linux-kernel@vger.kernel.org, Alexandre Ghiti , Andrew Morton , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= , Catalin Marinas , Christophe Leroy , "David S. Miller" , Dinh Nguyen , Donald Dutile , Eric Chanudet , Heiko Carstens , Helge Deller , Huacai Chen , Kent Overstreet , Liviu Dudau , Luis Chamberlain , Mark Rutland , Masami Hiramatsu , Michael Ellerman , Nadav Amit , Palmer Dabbelt , Peter Zijlstra , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , Rick Edgecombe , Russell King , Sam Ravnborg , Song Liu , Steven Rostedt , Thomas Bogendoerfer , Thomas Gleixner , bpf@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-modules@vger.kernel.org, linux-parisc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, netdev@vger.kernel.org, sparclinux@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH RESEND v8 16/16] bpf: remove CONFIG_BPF_JIT dependency on CONFIG_MODULES of Message-ID: <20240517154632.GA320@willie-the-truck> References: <20240505160628.2323363-1-rppt@kernel.org> <20240505160628.2323363-17-rppt@kernel.org> <7983fbbf-0127-457c-9394-8d6e4299c685@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7983fbbf-0127-457c-9394-8d6e4299c685@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Hi Klara, On Fri, May 17, 2024 at 01:00:31AM +0200, Klara Modin wrote: > On 2024-05-05 18:06, Mike Rapoport wrote: > > From: "Mike Rapoport (IBM)" > > > > BPF just-in-time compiler depended on CONFIG_MODULES because it used > > module_alloc() to allocate memory for the generated code. > > > > Since code allocations are now implemented with execmem, drop dependency of > > CONFIG_BPF_JIT on CONFIG_MODULES and make it select CONFIG_EXECMEM. > > > > Suggested-by: Bj?rn T?pel > > Signed-off-by: Mike Rapoport (IBM) > > --- > > kernel/bpf/Kconfig | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/kernel/bpf/Kconfig b/kernel/bpf/Kconfig > > index bc25f5098a25..f999e4e0b344 100644 > > --- a/kernel/bpf/Kconfig > > +++ b/kernel/bpf/Kconfig > > @@ -43,7 +43,7 @@ config BPF_JIT > > bool "Enable BPF Just In Time compiler" > > depends on BPF > > depends on HAVE_CBPF_JIT || HAVE_EBPF_JIT > > - depends on MODULES > > + select EXECMEM > > help > > BPF programs are normally handled by a BPF interpreter. This option > > allows the kernel to generate native code when a program is loaded > > This does not seem to work entirely. If build with BPF_JIT without module > support for my Raspberry Pi 3 B I get warnings in my kernel log (easiest way > to trigger it seems to be trying to ssh into it, which fails). Thanks for the report. I was able to reproduce this using QEMU and it looks like the problem is because bpf_arch_text_copy() silently fails to write to the read-only area as a result of patch_map() faulting and the resulting -EFAULT being chucked away. Please can you try the diff below? Will --->8 diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c index 255534930368..94b9fea65aca 100644 --- a/arch/arm64/kernel/patching.c +++ b/arch/arm64/kernel/patching.c @@ -36,7 +36,7 @@ static void __kprobes *patch_map(void *addr, int fixmap) if (image) page = phys_to_page(__pa_symbol(addr)); - else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) + else if (IS_ENABLED(CONFIG_EXECMEM)) page = vmalloc_to_page(addr); else return addr;