Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2748864lqo; Mon, 20 May 2024 15:56:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEwO+Z+Ze5LccBovBLf6vuR9qChNX9ng0IGayLwTyXhm9hhiyzniuRjiN24SUONSKgPmNlEq+OGPuFHpyFHtGH1lamkKG7zMCACSjp1A== X-Google-Smtp-Source: AGHT+IEhKulvvEJlpv8j4JQIbfskuwAYWx9lCSWsNknLP4THTsD9AiDjfuYUu7GE7ielDK9VlMxk X-Received: by 2002:a0d:e28b:0:b0:618:412a:d12b with SMTP id 00721157ae682-622affa80a5mr291509397b3.15.1716245811988; Mon, 20 May 2024 15:56:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716245811; cv=pass; d=google.com; s=arc-20160816; b=Rh0YCzSD+COxeJl3bd2MPUnmQTjKYJp5Lh+XGf+bYJ3VyAh8IEWcpuZU9hniO84vUS pO77DF6mIwsCrpRcR8KRr6B+VUd4bp4ZGKJ1w90j0JGzrGRq/vbyCMspjRQs6B3C0kQh /0i9ZBwul6ajxYmWmuKpZ7iFz4iqQ0vyRFB1jr8alGOvYHne7JseL0ids5PGoxXNvtkz J7Ib+F5brF8ipmA7+3B7/S0J0a3CkH5Nok9qHYNob+QWR0MlwAVgJzzyJhFpmXv8k2D8 IaE2QX4SkmT5Z4bRvSfbSLuoK4fXOT0YC5KOxrPxJx/94rOiR5j65EQ3X8RThZrfwc6x 7Knw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=IpQC4KCd8hRD1xiB1n+nGcrKBWSRDOzqTKV1oG7H/w0=; fh=QYr0SrnJ71AQxPIBeNgPKAWsG5fIHSsSHCLFq83FhRs=; b=eKlrxZ1mymnGAwmOPEk+2D5pSoDRbIqlUQsXXBhdlXY+r5WNGrM3JsGDbNQ5bqamwd PuB7ou2Tf8LXCSJ+c6+s/o7lAc4F+CRoog4hyQOdxl9TJe3mf/z6xPr+3QaK0geqfK78 ul7AFUSsYW3FsWcJHmyAMZGL45wP7isQXWW05W3Hg7ZT/ezh/rMQ9PzgPGKFMa9Bzyx1 FaiAFkHTCpO56IKGSC3+YmIEkYcR4eV5iKBmj+heIZQDx2ImtswQv9jvYO3sWyPHJrgk rK+PfiXLkq69PBSQWS1ao6B+mUvjctbRUUJZMFHDzAcMhyrMmTf8O1Rf+RjNQvY+rA5Q yvEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=PhteVsDs; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-184279-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df549f4a9si4014471cf.86.2024.05.20.15.56.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 15:56:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184279-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google09082023 header.b=PhteVsDs; arc=pass (i=1 spf=pass spfdomain=cloudflare.com dkim=pass dkdomain=cloudflare.com dmarc=pass fromdomain=cloudflare.com); spf=pass (google.com: domain of linux-kernel+bounces-184279-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184279-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8AA041C216B5 for ; Mon, 20 May 2024 22:56:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C48B8138493; Mon, 20 May 2024 22:52:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b="PhteVsDs" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C834AEF0 for ; Mon, 20 May 2024 22:52:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716245533; cv=none; b=RZxNxjyQgQAd6oUlDL0XrCCY5m6fYeUWJdQFvG3j/eJyMabrlRjS44J11q+N1enMv5TjcjO/06zBEq2rHqg+VqiOqPaRLCLikeJx1qa0Kl4KmGIV5C58oGrnz0RO5sPA0vRPGjhIl/85get6xt63ec9h2ojPdxr4SZgRBRFYCjQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716245533; c=relaxed/simple; bh=LSyLwFwwGKbsWNrZ97yRysd1sjCxGAdHZ+B46seWahg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=nUA+h7qIGkkKCVy5Xari7Fa1/SRDbSKbHB467kYRgyKafnTIaYl7ESaTeuQZePWMuPF4pkTewkNxdXDt4f2xyykJNhYJptfQbw5qjvWfEFhn7EbAPmyrq0/oJ3O3uQIHKzZ3YXJkvE1My/O+8AMjqs+7sRlkeYbsSQ+M8MeUGfc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com; spf=pass smtp.mailfrom=cloudflare.com; dkim=pass (2048-bit key) header.d=cloudflare.com header.i=@cloudflare.com header.b=PhteVsDs; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cloudflare.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloudflare.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1ec4dc64c6cso84898635ad.0 for ; Mon, 20 May 2024 15:52:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google09082023; t=1716245532; x=1716850332; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IpQC4KCd8hRD1xiB1n+nGcrKBWSRDOzqTKV1oG7H/w0=; b=PhteVsDsGPaYJCFHGJkoXgrYY8HfNzgnUwNSF1BLh0wPUKSYuyGlLh4Q8W3dA22/eq MOkPD6xYYl84dSf3XCFB+21eGuu10/6iO6gyQ3qc84HK7OpwSZXzD36BVa4lLndThtNr Bxomr3yeeswl6Drm9CQGOZUXajw8Ve55LAMWI/rhlO+y148+dfPaJwXtNDFIllQK/6yS ZR082VVr8l58gwr8upmOB6nDkp17gezGCF7VfDt/1ubD3dCTFYMbEh2UpMduyr1nnXRX ZVpuc9iueczHigXZb4lviKsIAmbhnDJwFB02oXJB1XX+D09ej4J3WzCteUk1FGMZN+cv p0Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716245532; x=1716850332; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IpQC4KCd8hRD1xiB1n+nGcrKBWSRDOzqTKV1oG7H/w0=; b=q9VswdRgvfkX1blgXVMorXC4fTIlboTVLan/GtlKwDiL5x+CsuxjtdQTt4tE9Gg7ur rEz+Ynej0D7aBCbdjLi4XPaUnS94BB0pdBkKWIh4NRshW/w0I97DhlfTSj0JmtNNlZqo 4/PC6Ma37vXUstX4gwEmqc2Z/iWz/QAFZo5/BY+rXpI4XlPHiMMDODoE9B9nH/M6WDXI c/LCeZu/8wz1sBMQ/TaOapaYMR4sjGm3tSdtsTawxCZ8ZgZEf9zvPgX4H4FGqTwrOWqJ Kccs4FeIdb9VCZexbqSrEqEBDvCZ4gvM935yQnadV2ha50lRcBeRJYrn/x87W93AuZTE /2NA== X-Gm-Message-State: AOJu0YwPpn3atXutG8t4lSikZIq6lHVt+aGNi/Nzvb3FMWZy3uYi0QYw FpPhHkADqHQzOoImYSObd7vjltJZbCYFiflYtQFsVTbG7t4F6sxdxRs9sL7myHE= X-Received: by 2002:a05:6a20:d817:b0:1b0:1025:2f5 with SMTP id adf61e73a8af0-1b010250487mr21580687637.0.1716245531768; Mon, 20 May 2024 15:52:11 -0700 (PDT) Received: from localhost ([2a09:bac5:6548:1232::1d0:55]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-6f4d2af2c41sm20244431b3a.172.2024.05.20.15.52.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 15:52:11 -0700 (PDT) From: Ivan Babrou To: bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@cloudflare.com, Ivan Babrou , Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Nathan Chancellor , Nick Desaulniers , Tom Rix , Raman Shukhau Subject: [PATCH] bpftool: un-const bpf_func_info to fix it for llvm 17 and newer Date: Mon, 20 May 2024 15:51:49 -0700 Message-ID: <20240520225149.5517-1-ivan@cloudflare.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit LLVM 17 started treating const structs as constants: * https://github.com/llvm/llvm-project/commit/0b2d5b967d98 Combined with pointer laundering via ptr_to_u64, which takes a const ptr, but in reality treats the underlying memory as mutable, this makes clang always pass zero to btf__type_by_id, which breaks full name resolution. Disassembly before (LLVM 16) and after (LLVM 17): - 8b 75 cc mov -0x34(%rbp),%esi - e8 47 8d 02 00 call 3f5b0 + 31 f6 xor %esi,%esi + e8 a9 8c 02 00 call 3f510 It's a bigger project to fix this properly (and a question whether LLVM itself should detect this), but for right now let's just fix bpftool. For more information, see this thread in bpf mailing list: * https://lore.kernel.org/bpf/CABWYdi0ymezpYsQsPv7qzpx2fWuTkoD1-wG1eT-9x-TSREFrQg@mail.gmail.com/T/ Fixes: b662000aff84 ("bpftool: Adding support for BTF program names") Signed-off-by: Ivan Babrou --- tools/bpf/bpftool/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index cc6e6aae2447..6d8bbc3ec603 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -338,7 +338,7 @@ void get_prog_full_name(const struct bpf_prog_info *prog_info, int prog_fd, { const char *prog_name = prog_info->name; const struct btf_type *func_type; - const struct bpf_func_info finfo = {}; + struct bpf_func_info finfo = {}; struct bpf_prog_info info = {}; __u32 info_len = sizeof(info); struct btf *prog_btf = NULL; -- 2.44.0