From nobody Sun Oct 5 16:14:07 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 8556E17BA5; Fri, 1 Aug 2025 11:46:53 +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=1754048818; cv=none; b=BvR0PDZB136a5bZ7fHG2iBz3jLXtorBFul86mmXO9B3ph5HryU4QU3E6XeVeH9umQPkoeTxSmGIDFKrXXCuVjaE5Tn1W/FEwD4dunjuWUarAVPVcGdObB/GIPmYV9mquv9uInZPb1htrKwLTv8d9FX5DIHq/P5rcdsta/w32NN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754048818; c=relaxed/simple; bh=y1ul/ePEL6TuTljSvrve3qgbisA5RKF5kOvE/Fx3ZyQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e3ZgY4bCDbshWb7P18U3uKNwuEgmZQlT+Lt0Wk2XeOFjL5+KRBXeCXc4JtvnafaFpKoIMEHAs26rvap8pyfPvnlgv7ZbvqM/Q8gBYmqYSU7mEtNEKPp2E2G+VDwSqb80/fV7Xfebil6Nq6Mo/4ZYLfg94tK/Oh8c99GCKjJT1II= 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=e6bpmgnv; 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="e6bpmgnv" Received: from [127.0.0.1] (localhost [127.0.0.1]) by mx.nixnet.email (Postfix) with ESMTPSA id 6A9247D326; Fri, 1 Aug 2025 13:46:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pwned.life; s=202002021149; t=1754048805; 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: in-reply-to:in-reply-to:references:references; bh=bYwCqmJrhPqYZqyuDDiVsTLJbguAyJltYFAQRIfPEys=; b=e6bpmgnvIcV7iKSmDn00e5xC5ex4qX8Xt0cQrU0q1+S1TcMU0WIeDgcnSdi1tjkNEXKd8R JJgmrlZmPkGSd/bx6E4y9OiwYEWsZCdbKq1zUgzccjk9hUfW3Qftj+uokXj022JXMJsd3T Uvom74EupBPfJJ8EKMlYGGVxU3EgN2g= From: Achill Gilgenast To: Eduard Zingerman , Yonghong Song , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Viktor Malik , bpf@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Achill Gilgenast , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Subject: [PATCH] libbpf: avoid possible use of uninitialized mod_len Date: Fri, 1 Aug 2025 13:46:06 +0200 Message-ID: <20250801114613.610070-1-fossdd@pwned.life> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: 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; | ^~~~~~~ Signed-off-by: Achill Gilgenast Acked-by: Yonghong Song Acked-by: Eduard Zingerman Link: https://lore.kernel.org/bpf/20250729094611.2065713-1-fossdd@pwned.lif= e/ --- 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