From nobody Sat Feb 7 12:05:56 2026 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 049F426E173 for ; Sun, 1 Feb 2026 21:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769982812; cv=none; b=Czqb6Rg1+W2+YsiUzYT1ySCcQCIr7g759KKRf3dlviwfj8FzTSVVlcwQ7fKB6FUUH9bVHzZ3nmI9c7DgCloMWZLwW4b0h3FpmNvQ/1Ukat7HCbV6NOwI6akFQROmZttZIc5/nwqs6L03+ZJsRcwk9H1fW5JBpkozZMyecJzg33c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769982812; c=relaxed/simple; bh=tW+ompafPZXV49JuSnFEfBy/BkZIMjs1dqECeICfgDo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=o9CrNbasVC7xICZuCsUv63fLPgLZRRv9WSUXOZrxlsDXPYidlTjZC11DX0RHZVcol9t8DBiWBnptlQnth0hFZsIXlBe8AS5b3mSbge6O4r4EPI1L2aS5zhDu4z3pBImMhFfAt2TonzBNtJucptvKiU+HeKupunILoQxswvWkUSA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VDIKzZ0V; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VDIKzZ0V" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1769982799; 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=7mGV3Nuub+VvmJ8cY/wNMOcNA2p422Z13U0w6JvGN+Q=; b=VDIKzZ0VlcGtXTcVZHqs4gbzzKZTHGyapB/DLw9SXhiUWjlJtOp+yX2lDSSJmCU8dF47Se mYV9+0elF4NgyluGm+Lmc8QxQ93njcbIypEpy3e0xYZJO5FkBu142aNsD9k9o2rMRnTqyF L4sUXqsCB92R/qAgKDPPK2qAmHAFJpY= From: Thorsten Blum To: Martin KaFai Lau , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa Cc: Thorsten Blum , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH bpf-next v2] bpf: Replace snprintf("%s", ...) with strscpy in parse_{base,module} Date: Sun, 1 Feb 2026 22:52:48 +0100 Message-ID: <20260201215247.677121-2-thorsten.blum@linux.dev> 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-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Replace snprintf("%s", ...) with the faster and more direct strscpy(). Signed-off-by: Thorsten Blum --- Changes in v2: - Keep snprintf("%s", ...) in btf_show_name() as suggested by Alexei - Update patch title - Link to v1: https://lore.kernel.org/lkml/20260201180445.664056-2-thorsten= .blum@linux.dev/ --- kernel/bpf/btf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 8959f3bc1e92..7708958e3fb8 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include =20 @@ -6324,7 +6325,7 @@ static struct btf *btf_parse_base(struct btf_verifier= _env *env, const char *name btf->data_size =3D data_size; btf->kernel_btf =3D true; btf->named_start_id =3D 0; - snprintf(btf->name, sizeof(btf->name), "%s", name); + strscpy(btf->name, name); =20 err =3D btf_parse_hdr(env); if (err) @@ -6443,7 +6444,7 @@ static struct btf *btf_parse_module(const char *modul= e_name, const void *data, btf->start_str_off =3D base_btf->hdr.str_len; btf->kernel_btf =3D true; btf->named_start_id =3D 0; - snprintf(btf->name, sizeof(btf->name), "%s", module_name); + strscpy(btf->name, module_name); =20 btf->data =3D kvmemdup(data, data_size, GFP_KERNEL | __GFP_NOWARN); if (!btf->data) { --=20 Thorsten Blum GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4