From nobody Sun Oct 5 21:57:23 2025 Received: from mx.nixnet.email (mx.nixnet.email [5.161.67.119]) (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 70DFD233721; Tue, 29 Jul 2025 09:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=5.161.67.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753782913; cv=none; b=cL311em7AcB0GRhMulRruuiUao2BLF2qrkRJAtRylmcfiJ3FcalfzaD6lUCMlB2MJnf8omsRnMN7lC0br8sWveQvb8WsuJ0/jM3AIt9fTXfPM3fWmPne88tfHFRiY8JWnrLxYoJxsccozt17Wgsb6op1/biLZ7Brd3rHFEjEGHU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753782913; c=relaxed/simple; bh=ypFGUj5D/RsIpLfcUVF5nL2pTzMlEatJ2G6fAB11pWk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BNmFOQHhVv7ehhSXSAEBUPsHlOU/IeCHWC/PmfVubFTvo3LyfPEgqaDO/wrearRzoMHgKGhGnskdnxV+0JiKxdLQjKQdqdB710mY4edZnoHYYwBlvXgmrTX8Lwn/WJ3Axek6ACxjyAJEt6gk5Bi6lOFJNW+9q9c0KXy0GTqA9rc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pwned.life; spf=pass smtp.mailfrom=pwned.life; dkim=pass (1024-bit key) header.d=pwned.life header.i=@pwned.life header.b=KKllHRoi; arc=none smtp.client-ip=5.161.67.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pwned.life Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pwned.life Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=pwned.life header.i=@pwned.life header.b="KKllHRoi" Received: from [127.0.0.1] (localhost [127.0.0.1]) by mx.nixnet.email (Postfix) with ESMTPSA id AD5F77D32D; Tue, 29 Jul 2025 11:46:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pwned.life; s=202002021149; t=1753782402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=u5aVN9MeNmddLzpEpIfgyH5J5qgbEfCV/49SBvFIR9U=; b=KKllHRoinqo7q60Jzfk9bRa00AFi4vG77BDbJLngZ0QukZpJG/0224fPd35r6UdkFJHD5H DZReOMvxJ6G40t50M1tS5cGH4XDSXATHsZLE1N4Sj7+ERU2q7nfsRACNAQlJ45VwKzstYN nIkdZEgGaehH8D6PnBlE1jSAzzFnYo0= From: Achill Gilgenast To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Viktor Malik , bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Achill Gilgenast , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH] libbpf: avoid possible use of uninitialized mod_len Date: Tue, 29 Jul 2025 11:45:53 +0200 Message-ID: <20250729094611.2065713-1-fossdd@pwned.life> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam: Yes Content-Type: text/plain; charset="utf-8" If not fn_name, mod_len does never get initialized which fails now with gcc15 on Alpine Linux edge: libbpf.c: In function 'find_kernel_btf_id.constprop': libbpf.c:10100:33: error: 'mod_len' may be used uninitialized [-Werror=3Dm= aybe-uninitialized] 10100 | if (mod_name && strncmp(mod->name, mod_name, mod_l= en) !=3D 0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ libbpf.c:10070:21: note: 'mod_len' was declared here 10070 | int ret, i, mod_len; | ^~~~~~~ Fixes: 8f8a024272f3 ("libbpf: support "module: Function" syntax for tracing= programs") Signed-off-by: Achill Gilgenast Acked-by: Eduard Zingerman Acked-by: Yonghong Song --- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e067cb5776bd..fb4d92c5c339 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -10086,27 +10086,27 @@ static int libbpf_find_prog_btf_id(const char *na= me, __u32 attach_prog_fd, int t btf__free(btf); if (err <=3D 0) { pr_warn("%s is not found in prog's BTF\n", name); goto out; } out: return err; } =20 static int find_kernel_btf_id(struct bpf_object *obj, const char *attach_n= ame, enum bpf_attach_type attach_type, int *btf_obj_fd, int *btf_type_id) { - int ret, i, mod_len; + int ret, i, mod_len =3D 0; const char *fn_name, *mod_name =3D NULL; =20 fn_name =3D strchr(attach_name, ':'); if (fn_name) { mod_name =3D attach_name; mod_len =3D fn_name - mod_name; fn_name++; } =20 if (!mod_name || strncmp(mod_name, "vmlinux", mod_len) =3D=3D 0) { ret =3D find_attach_btf_id(obj->btf_vmlinux, mod_name ? fn_name : attach_name, attach_type); --=20 2.50.1