Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2916681rdb; Mon, 4 Dec 2023 10:59:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJYo2v72kbymEcTIEVugV3IM/MCFk7bkopluVhOYqv/JmBYyh9Qx/Ks9qs9ccy0uo2KOYB X-Received: by 2002:a05:6a21:1c8a:b0:18f:9c4:d346 with SMTP id sf10-20020a056a211c8a00b0018f09c4d346mr181218pzb.54.1701716375361; Mon, 04 Dec 2023 10:59:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701716375; cv=none; d=google.com; s=arc-20160816; b=UZVmqr6NEcmF6hIFUXxTv88Lvq8aF4xejnq2XD/ODU6/SNJtezmYjeGjVl92cCAJlJ q3wEbmInBDzx0Fsp60TdJYm781q39ZANseOj/wsuWvwWXkr5FaDE5HgP+brWKwCZJ3nB xs1abfbL72sxw9KOj11AEh79U4sdC31TYyIqC6dqXIlshrubnnJE6sS3SGVmJ+PqWDqQ K3BBGis8S2404U9XsEZC8FYCl5jf568hm7qPqvtYE9ZrSosruEi7fVCgKSeZjEpD3KAU CIqubzerr6Ae8uIBi6YoVilxskEN6mWI0Sl/11VYtJLqR4uEVcX0HfKFAMp8wz2Sg+09 r7Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=OhTNasiWgh+dkfX0Dm+ISFeJznRbPndi9WOsk0B0xUY=; fh=ZftHWBthIMElIiTwvbQ9JaHfluZSx7aom9Qt3YyT5C8=; b=vqLRcBuKeZ/QrNPkmZcpM3os3ul3LjhiyAykBUbSohpDRR28dAwLWWrgvOE3kkEE/T HutHF40YwTF1izlkqtOXBE2//9szYbZChrUhOVMM/Cy6SW2fPhWpeQaIwtVCWbZ9H+Z+ a45xmpUWTEWCWN6Zq4EImKg08ql35AuufhY44YxJMaPRLWxzUBiz6zuYB+TS/KUKEIKL TCuNDwbOJY8P6DMZ+bn6kI/rhQF3K8xx7pEykg6NFDH1eadKTVrD5RzCylK/Vgr3mJih gfZVvuFgaHJubIQrFyJ7jsQV1LMYCzcG9qHVBWyw37C/hMpkZM4FbdYjs2DZmI9h2Qor +Xzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gVppsoUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l6-20020a63ba46000000b005c67bf3805fsi3118991pgu.309.2023.12.04.10.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:59:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=gVppsoUu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5FADC80ACB51; Mon, 4 Dec 2023 10:59:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbjLDS7Y (ORCPT + 99 others); Mon, 4 Dec 2023 13:59:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjLDS7W (ORCPT ); Mon, 4 Dec 2023 13:59:22 -0500 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44888F0 for ; Mon, 4 Dec 2023 10:59:28 -0800 (PST) Received: by mail-vs1-xe30.google.com with SMTP id ada2fe7eead31-464811e5b3cso1296172137.1 for ; Mon, 04 Dec 2023 10:59:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701716367; x=1702321167; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=OhTNasiWgh+dkfX0Dm+ISFeJznRbPndi9WOsk0B0xUY=; b=gVppsoUuN4dqz8Syy1kQUrjoI9C/nqzgvQfx9nxccS1+RNS89BFXrTngJIOrk1P6If VplsZJ65o6IHbLWieGBql0IaVkQDWogVu+eI8is0EtgTP0CONumAwdj4iJfQys0/4eMk Iryix0SeSnwxRXh2vSivhXqpgzPjawruaCoQ5ylbQvbXZ9QuXZa0BfcgdycQDQSAHn61 a4nSahHkBplyN0wqnAtQotFnTvEPpC6jXp5q+DbUtCi9EowADUZmq8jeuIr89+F+UB6n xbQCIRISWxN9a3sFhAUCq3AEFFWk6PnBYeV0Hv2gnLd7K9HhxKM6WjOEUdOz9tG8WSi5 LU/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701716367; x=1702321167; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OhTNasiWgh+dkfX0Dm+ISFeJznRbPndi9WOsk0B0xUY=; b=pGFGDWbl1J2BYTAg735EwX3YB99f2wJ+vC0ZrCqNwKKPCcEFSOJzpGpexSJfiknSoz iKSbMvEnCiElN9p4Re6KWb1CNr5z6vXST/SRVBkVGn2E0al7S203XIpsVmGtjmCXJTh9 gvUqQdKTTK3f3Os7vClnR4MK4vkYWcTuDGki9XT82D0iUUhaDojlvyTnmvsW1bsyeYJf Hg5bmD5RJe6gPeFNyYRAco8dGip73hUZuothygncPdRwh3iQHqcw1wfK4S9acN9j714l suJmz0Ll1XUSyaJmrYjtOrOiAFuyn4k7XGt4Mq3w5PTMwmvtajNrOUG0QkKshftt4rAH tuWA== X-Gm-Message-State: AOJu0Yy5d2sIHuPUa1l3R1tIfXx0knbpQDzjCo9lQ7yUtUZHaWjoexmZ xyuwy9LFrSGQp6YWFdU7yEkbxzDLKbtouHt8Ls/QIQ== X-Received: by 2002:a05:6102:a53:b0:452:6d82:56e3 with SMTP id i19-20020a0561020a5300b004526d8256e3mr383189vss.6.1701716367163; Mon, 04 Dec 2023 10:59:27 -0800 (PST) MIME-Version: 1.0 References: <20231130133630.192490507@infradead.org> <20231130134204.136058029@infradead.org> <20231204091334.GM3818@noisy.programming.kicks-ass.net> <20231204111128.GV8262@noisy.programming.kicks-ass.net> <20231204125239.GA1319@noisy.programming.kicks-ass.net> <20231204181614.GA7299@noisy.programming.kicks-ass.net> <20231204183354.GC7299@noisy.programming.kicks-ass.net> In-Reply-To: <20231204183354.GC7299@noisy.programming.kicks-ass.net> From: Sami Tolvanen Date: Mon, 4 Dec 2023 10:58:48 -0800 Message-ID: Subject: Re: [PATCH v2 2/2] x86/cfi,bpf: Fix BPF JIT call To: Peter Zijlstra Cc: Jiri Olsa , Alexei Starovoitov , Song Liu , Song Liu , Paul Walmsley , Palmer Dabbelt , Albert Ou , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , X86 ML , "H. Peter Anvin" , "David S. Miller" , David Ahern , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Arnd Bergmann , Kees Cook , Nathan Chancellor , Nick Desaulniers , linux-riscv , LKML , Network Development , bpf , linux-arch , clang-built-linux , Josh Poimboeuf , Joao Moreira , Mark Rutland Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 10:59:34 -0800 (PST) On Mon, Dec 4, 2023 at 10:34=E2=80=AFAM Peter Zijlstra wrote: > > So afaict this is used through bpf_for_each_map_elem(), where the > argument still is properly callback_fn. However, in the desriptor > bpf_for_each_map_elem_proto the argument gets described as: > ARG_PTR_TO_FUNC, which in turn has a comment like: > > ARG_PTR_TO_FUNC, /* pointer to a bpf program function */ > > Which to me sounds like there is definite type punning involved. The > call in bpf_for_each_array_elem() is a regular C indirect call, which > gets adorned with the kCFI magic. > > But I doubt the BPF function that gets used gets the correct matching > bits on. > > TL;DR, I think this is a pre-existing problem with kCFI + eBPF and not > caused by my patches. It is a pre-existing problem, I ran into the same failures when I looked into this briefly last year: https://github.com/ClangBuiltLinux/linux/issues/1727 In addition to bpf_for_each_array_elem, a few other callers also use the same function pointer type that doesn't match cfi_bpf_hash. Sami