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=1796216428; b=Syf8GlXO0YRO12OF7PXvPL41p3KOTD9B5+kO4G7NbTRKwtygfANSQwwIyiD1z5/homfu Fc0NtnA5W9QZgnz4wwdymf5VVlbIiZ2foAmj+xWQxbdwvJGfkyLcbagD1ILgZV/yA8Vae m+uKZu2CANaDfczRmyOQwQ498Iy9r5i4IxkDkcDFD4K74W/IBXCbsfCv5/C5vOATfJB6a 7uPukvoUhGxbDySbfQ8lt/5hJ87s428/4sthRV++XtNbHpV87rBj88UuCuPicfUdwLf8I qImC8BbPz/fCyYvPYIeJNGnChu8Y2+xuNs2jngIlmwACbybhtIwnahI4GwAiaM3ac/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796216428; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=S0y/sL1cdHfnWLDC72Vfi5hkNdWKhxPLGljb/q/rTnU=; b=dPohTz/KawWCQMenKAmnKQ5QIQJ3R0hpP4GEJwR/ysyM6bPU3WpXFlKpj3h5QJoexGT1 YiM03DHwa4f3cBAkyK4wpjtiwY1NndDk/PwQpbiBjH4O+wU8ClsSNODAA3ZxFWxAuIi3a ddvVG2L+3oollJaGk0vlHo1NOs6ARXyNO1+6NPs/wc3rWqbhaflUv5KIXgRSXv04KTFpc LHeUgkXqzjbEQM8SV3j+Bvb5q3hi850+xmLjfEpSclpzcxraWPbxEE1n9gBJ6ZFvuM+si pDw9+7WgI3tLGgOGNaOEjZJawRL+QUCrjgvER2evG5lWzAWohR0loJ5Z/V2CFp1iv+g== 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=ktjUg0Fp; 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 076E8606A322; Wed, 2 Dec 2026 13:00:27 +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=ktjUg0Fp Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EBB81F000C1; Wed, 2 Dec 2026 13:00:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796216427; bh=S0y/sL1cdHfnWLDC72Vfi5hkNdWKhxPLGljb/q/rTnU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ktjUg0FpfJrRCxQNj7XABvzq7DuZGAtfSQE5uGIVMpADuQgxKp3JAG1yhKP2OBQ/Z 4dXOtq5XzFA8Jn8EblkuEjPW+I/5tnVeQjqMHOvOPx1uHGyd92eT56SlCC9f0Pbizc 7lHHIOj7dUe0TXvCDPCPMVLmwAbFgw+mSCeAFrOLB3radpTOiE+E4H32od858Am8kT nMXGhWj1v+bGZFzRmeAKRIfaeNk6QgvRMFp6W0eXV6NLjkGZj86tJ6COkidU5+OSZJ It+SvdNHNJh/SZXoRjArs0kwnWuyrggvAMd35dKqtQrVeYi4udPa23Y/2rLnNNE5eu c6ATw1ul9wpyA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC bpf-next 21/31] bpftool: Display inlined functions for kprobe multi link Reply-To: sashiko-reviews@lists.linux.dev To: "Jiri Olsa" Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org In-Reply-To: <20261202123035.10335-22-jolsa@kernel.org> References: <20261202123035.10335-1-jolsa@kernel.org> <20261202123035.10335-22-jolsa@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 13:00:27 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] bpftool: broken binary search in find_kernel_sym_by_range() due to 32-bit sort - [Low] bpftool: memory leak in do_show_link() when second link info query fails -- commit 40ced4c64011e2e50d8f3a0de0d6ac7287df545e Author: Jiri Olsa bpftool: Display inlined functions for kprobe multi link This commit updates bpftool to display inline flags and attached inlined function instances for kprobe_multi links in both plain and JSON output. > diff --git a/tools/bpf/bpftool/link.c b/tools/bpf/bpftool/link.c > index 5cffa2d283b47..19daac789a4ca 100644 > --- a/tools/bpf/bpftool/link.c > +++ b/tools/bpf/bpftool/link.c [ ... ] > @@ -322,33 +361,156 @@ symbol_matches_target(__u64 sym_addr, __u64 target= _addr, bool is_ibt_enabled) > return false; > } > =20 > +/* Inlined instances are placed inside functions, find the one covering = @addr. */ > +static struct kernel_sym *find_kernel_sym_by_range(__u64 addr) > +{ > + __u32 lo =3D 0, hi =3D dd.sym_count, mid; > + > + if (!addr) > + return NULL; > + > + while (lo < hi) { > + mid =3D lo + (hi - lo) / 2; > + if (dd.sym_mapping[mid].address <=3D addr) > + lo =3D mid + 1; > + else > + hi =3D mid; > + } > + return lo ? &dd.sym_mapping[lo - 1] : NULL; > +} [Severity: Medium] Can find_kernel_sym_by_range() return a per-cpu symbol instead of the enclosing function because dd.sym_mapping is not sorted in 64-bit unsigned order? kernel_syms_load() sorts dd.sym_mapping with kernel_syms_cmp(), which truncates the 64-bit unsigned long address difference to a 32-bit signed int: tools/bpf/bpftool/xlated_dumper.c:kernel_syms_cmp() { return ((struct kernel_sym *)sym_a)->address - ((struct kernel_sym *)sym_b)->address; } On 64-bit SMP systems such as x86_64, per-cpu symbols in /proc/kallsyms have small positive offsets (e.g. 0x1000), while kernel and module text symbols sit at 0xffffffff80000000 and above, where bit 31 is set. Because truncating (per_cpu_addr - text_addr) to int yields a positive value, qsort() places the per-cpu symbols at the tail of dd.sym_mapping after text symbols. When find_kernel_sym_by_range() binary-searches dd.sym_mapping with 64-bit unsigned comparisons for an inlined address in a module or in the upper half of the table, mid probes into those trailing per-cpu entries, sees dd.sym_mapping[mid].address <=3D addr, and advances lo to the end of the array, reporting a bogus caller, offset, module, and inline BTF lookup. [ ... ] > @@ -1172,24 +1414,36 @@ static int do_show_link(int fd) > goto again; > } > if (info.type =3D=3D BPF_LINK_TYPE_KPROBE_MULTI && > - !info.kprobe_multi.addrs) { > + !info.kprobe_multi.addrs && !info.kprobe_multi.inline_addrs) { > + __u32 inline_count =3D info.kprobe_multi.inline_count; > + > count =3D info.kprobe_multi.count; > if (count) { > addrs =3D calloc(count, sizeof(__u64)); > - if (!addrs) { > - p_err("mem alloc failed"); > - close(fd); > - return -ENOMEM; > - } > - info.kprobe_multi.addrs =3D ptr_to_u64(addrs); > cookies =3D calloc(count, sizeof(__u64)); > - if (!cookies) { > - p_err("mem alloc failed"); > - free(addrs); > - close(fd); > - return -ENOMEM; > - } > + } > + if (inline_count) { > + inline_addrs =3D calloc(inline_count, sizeof(__u64)); > + inline_cookies =3D calloc(inline_count, sizeof(__u64)); > + inline_ids =3D calloc(inline_count, sizeof(__u32)); > + } > + if ((count && (!addrs || !cookies)) || > + (inline_count && (!inline_addrs || !inline_cookies || !inline_ids)= )) { > + p_err("mem alloc failed"); > + free(inline_ids); > + free(inline_cookies); > + free(inline_addrs); > + free(cookies); > + free(addrs); > + close(fd); > + return -ENOMEM; > + } > + if (count || inline_count) { > + info.kprobe_multi.addrs =3D ptr_to_u64(addrs); > info.kprobe_multi.cookies =3D ptr_to_u64(cookies); > + info.kprobe_multi.inline_addrs =3D ptr_to_u64(inline_addrs); > + info.kprobe_multi.inline_cookies =3D ptr_to_u64(inline_cookies); > + info.kprobe_multi.inline_ids =3D ptr_to_u64(inline_ids); > goto again; > } > } [Severity: Low] If the second bpf_link_get_info_by_fd() call after "goto again" fails, does do_show_link() return early without freeing inline_addrs, inline_cookies, inline_ids, addrs, and cookies? --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202123035.1033= 5-1-jolsa@kernel.org?part=3D21