From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 1204926FA7B; Tue, 8 Apr 2025 12:34:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744115662; cv=none; b=V7UYAwZF6bc22cIuDaP8Oq69lghzkpRwqodhI0EuLhQIkaemaXleSU5aSlwDZb3vsjTv2X6L0b8pO62KhJwacYxz8rZLT6KDwqSwseUh6a5XnuZ5WUllFERj5EDlXtVAMBNdFN5IsN4CXoiiRCsCvVOeu0rKQKUdN+4nUAqgWPM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744115662; c=relaxed/simple; bh=fJA1ndHsYKKxBF21ymgURaceU575IcyS73eAkC11x8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U84BDiLgXBK+C8YDeRMpXiPTV+GXhqvMOlfujDFn/Xw2R+zYux02K8Dh0gITu8OyenYTBoK+CoY3lQQ6hcEeIH8di0Ns46x9gzdsqChCmu7WjIHnTC0LjMyAmt6i+09bT0+tmBKl4Y0QYtGakFljK9JL9vjAJENtiSWQEZAOdrw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=czIvA324; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="czIvA324" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DD56C4CEE5; Tue, 8 Apr 2025 12:34:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744115661; bh=fJA1ndHsYKKxBF21ymgURaceU575IcyS73eAkC11x8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=czIvA324bG7fShPdUiGr14uOPBRf+tdjppSQGLbu/Lw6h+HOm0ZmL7pbg3mMAmWg2 mw9tPq6a/oJO8kukq9+J1g/6gWhDBwHK3S+HkVcnQuHzNN2UqMSPc40MEQk8Bn4x2U zFhdVoAqA9kADGS5pCRr/AZ5aZXZnsrq0NjVOYxc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andrii Nakryiko , Alexei Starovoitov , Sasha Levin Subject: [PATCH 6.1 057/204] libbpf: Fix hypothetical STT_SECTION extern NULL deref case Date: Tue, 8 Apr 2025 12:49:47 +0200 Message-ID: <20250408104822.018944603@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104820.266892317@linuxfoundation.org> References: <20250408104820.266892317@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andrii Nakryiko [ Upstream commit e0525cd72b5979d8089fe524a071ea93fd011dc9 ] Fix theoretical NULL dereference in linker when resolving *extern* STT_SECTION symbol against not-yet-existing ELF section. Not sure if it's possible in practice for valid ELF object files (this would require embedded assembly manipulations, at which point BTF will be missing), but fix the s/dst_sym/dst_sec/ typo guarding this condition anyways. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Fixes: a46349227cd8 ("libbpf: Add linker extern resolution support for functions and global variables") Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/r/20250220002821.834400-1-andrii@kernel.org Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- tools/lib/bpf/linker.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 5a99bf6af445b..752ef88c9fd97 100644 --- a/tools/lib/bpf/linker.c +++ b/tools/lib/bpf/linker.c @@ -1962,7 +1962,7 @@ static int linker_append_elf_sym(struct bpf_linker *linker, struct src_obj *obj, obj->sym_map[src_sym_idx] = dst_sym_idx; - if (sym_type == STT_SECTION && dst_sym) { + if (sym_type == STT_SECTION && dst_sec) { dst_sec->sec_sym_idx = dst_sym_idx; dst_sym->st_value = 0; } -- 2.39.5