From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796173157; b=OVYqeFV/lMm/SAqjQmuyXY2Prhd9AB+h7hugX4F33FIoUyYPts3X94NNlueZDvUALuN3 zSUUAkImQGkq0jyL2Asc2uR4yykFU8eDs4mZKxBV8et5odDJJAtkYND634IrX3rmuHFBO U9INg7RQpNmQBcL44GFl5wzzF9NyRGv7PHK+JEaPBGYNlqG/xTXqPKmu2+ZXrfQrJFv1B R9pN0gASqnk0357Ab4o4HylKGpec/mQHYnC0KlE5/d8LMPMpGMiKs4TByEbNSLk4XkuRS D7LT/OpHbw9ofRfN6Kt4yY4GGxeIaVHG9NhFa2GUijMwcp7gb/ZSxYJYS3D8g4d/uPQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796173157; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=u6FdmzH4QaZAtZoodFPCGE2q13MF6kmQ9eET0oLW3po=; b=AZm/zmBkpO6g2xvAa5rPaXKZlU3QySHXoWxPAUft3hnmkI/XhvwkOcbXRCIW7bDxrutP 0U3zLfgbwFB/YJc961DL1yi+MSF3o4YOUCLYkGhv/UwqyTG93gGH55hdQdlkbUajoobdo BVMd08viimFQnlnSfZiuo7X0OagG2HxaiEvhc2XzGSeG5bLhJbVH9RfgsgDXj70MbSyCt QwM2NMsD3HO6v+UTSuAqZ/uURDP16vkKXM49O//qHoeFoP/ChrU+T5BrBWBkh15pW3mQL bKBpXFCS4fQdQKLWBYRpRV4dcuYuVAcObwCnZhPgIL4mGa/kxwVahvh+niT54YuzCsA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PPjkBxoR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FC03606A31A; Wed, 2 Dec 2026 00:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=PPjkBxoR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E2641F000C1; Wed, 2 Dec 2026 00:59:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796173157; bh=u6FdmzH4QaZAtZoodFPCGE2q13MF6kmQ9eET0oLW3po=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=PPjkBxoRnqFX3dPoKc0RJ+o7nEXT6rlJ2EfElPG2KlShgq7faa5ZQfE/uxpiuz8KC F5hbcltrj01R2F0I6iYtbHB6yxbQKg+nPR4/DIS3KgobLBQPGzM3EJT5uAyNjh6DLt XP1Q9qhQdWwKYrTYhFqIZN6+uAi9R9f0dERL/0B9M6W4yONPke/J8yFGqjmD4f6VxV cMX2wd19JsmSbBlrORVNC24LH3sFp3kFP2Frjs2zpRtdvak+sCxEnNmHwLSCAnheY/ P0vjN76sMQ6CoMex7uOYHgt90TjGMwj7TjIj3DUk+72p/G5SCvaymYHhmZ2+qBREBu 6J/R6sD4xNubQ== Content-Type: multipart/mixed; boundary="===============2901454638864950353==" X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Message-Id: In-Reply-To: <20261202001344.2721429-21-wusamuel@google.com> References: <20261202001344.2721429-21-wusamuel@google.com> Subject: Re: [PATCH bpf-next v4 09/10] libbpf: Resolve typeless ksyms via KALLSYMS_QUERY_BY_NAME ioctl From: bot+bpf-ci@kernel.org To: wusamuel@google.com,corbet@lwn.net,skhan@linuxfoundation.org,rdunlap@infradead.org,ast@kernel.org,daniel@iogearbox.net,john.fastabend@gmail.com,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,emil@etsalapatis.com,ihor.solodrai@linux.dev,mcgrof@kernel.org,petr.pavlu@suse.com,da.gomez@kernel.org,samitolvanen@google.com,atomlin@atomlin.com,viro@zeniv.linux.org.uk,brauner@kernel.org,jack@suse.cz,nathan@kernel.org,ndesaulniers@google.com,morbo@google.com,justinstitt@google.com Cc: david.laight.linux@gmail.com,akpm@linux-foundation.org,pmladek@suse.com,wusamuel@google.com,kernel-team@android.com,linux-kernel@vger.kernel.org,linux-fsdevel@vger.kernel.org,linux-doc@vger.kernel.org,bpf@vger.kernel.org,linux-modules@vger.kernel.org,linux-kselftest@vger.kernel.org,llvm@lists.linux.dev,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev Date: Wed, 2 Dec 2026 00:59:13 +0000 (UTC) --===============2901454638864950353== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > libbpf: Resolve typeless ksyms via KALLSYMS_QUERY_BY_NAME ioctl TL;DR: Dropping the old 'd'-only restriction on ".llvm." matches may make some typeless ksym externs fail with -ENOTUNIQ or bind new addresses on ThinLTO kernels. Standalone libbpf builds may also lack the linux/fs.h definitions. > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -31,6 +31,7 @@ > #include > #include > #include > +#include > #include This isn't a bug, but libbpf.c now depends on KALLSYMS_QUERY_BY_NAME, KALLSYMS_QUERY_NAME_PREFIX, struct kallsyms_query_by_name and struct kallsyms_query_sym coming from . The in-tree build is fine since tools/include/uapi is used. The stand-alone build from the mirror would pick up the system , and with a header older than this series libbpf.c would fail to compile. libbpf.c usually guards constants from headers it does not carry with fallbacks, for example #ifndef BPF_FS_MAGIC and #ifndef MFD_CLOEXEC. Should local definitions be added here, or should the commit message state that the mirror must start shipping linux/fs.h (and the linux/mount.h and linux/fscrypt.h it includes)? [ ... ] > +static int query_ksym_by_name(int fd, struct extern_desc *ext, bool lto_prefix) > +{ [ ... ] > + if (lto_prefix) { > + n = snprintf(prefix_buf, sizeof(prefix_buf), "%s.llvm.", ext->name); > + if (n < 0 || n >= sizeof(prefix_buf)) > + return 0; > + q.query_name = ptr_to_u64(prefix_buf); > + } > + > + while (!ioctl(fd, KALLSYMS_QUERY_BY_NAME, &q)) { > + if (!ext->is_set) { > + ext->is_set = true; > + ext->ksym.addr = sym.sym_addr; > + pr_debug("extern (ksym) '%s': set to 0x%llx\n", ext->name, ext->ksym.addr); > + } else if (sym.sym_addr != ext->ksym.addr) { > + pr_warn("extern (ksym) '%s': resolution is ambiguous: 0x%llx or 0x%llx\n", > + ext->name, ext->ksym.addr, (unsigned long long)sym.sym_addr); > + return -ENOTUNIQ; > + } > + q.pos++; > + } Was dropping the 'd' restriction on the ".llvm." match intended? The text parser this replaces only did that for 'd' (static data) symbols: res = strstr(sym_name, ".llvm."); if (sym_type == 'd' && res) ext = find_extern_by_name_with_len(obj, sym_name, res - sym_name); else ext = find_extern_by_name(obj, sym_name); That restriction came from c56e59776f46 ("libbpf: Handle .llvm. symbol properly"). KALLSYMS_QUERY_BY_NAME does not filter by type and struct kallsyms_query_sym does not return the type, so the old rule cannot be kept. The commit message ("exact names, plus ".llvm." prefix matches") does not mention this. On Clang ThinLTO kernels, promoted static functions, bss and rodata appear as 't'/'b'/'r' foo.llvm., which gives two visible changes. First, suppose there is an exact global symbol foo (type 'T') and an unrelated static foo.llvm. of type 't', 'b' or 'r' at another address. The old code resolved extern foo uniquely. Now the exact lookup sets ext->ksym.addr, the prefix lookup finds a different address and returns -ENOTUNIQ, and bpf_object__resolve_typeless_ksyms() skips the text fallback for -ENOTUNIQ. Can this make bpf_object__resolve_externs() return -EINVAL for an object that loaded before? Second, a weak typeless extern that used to stay 0, because only a non-'d' foo.llvm. existed, now binds to that symbol's address. Does this change `if (&foo)` style feature checks? Also, the ambiguity message prints ext->name rather than the symbol that matched, so the user sees "'foo': resolution is ambiguous" without knowing which foo.llvm. caused it. The old message printed sym_name. Should the matched name be reported? If the 'd' restriction was dropped intentionally, should the changelog say so and explain why ambiguity against non-data .llvm. symbols should fail the load? --- AI reviewed your patch. Please fix the bug or email reply why it's not a bug. See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46779970959 --===============2901454638864950353==--