From patchwork Mon Nov 4 17:52:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13861753 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 AFECE1CF96; Mon, 4 Nov 2024 17:53:17 +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=1730742797; cv=none; b=KoTk8IpuJNx1FTnxTv0iGzwixiqd/zQaXEDe149AmrXqPEqYUB04rgfFAf9/midwBuwvuI1MIUA+yXmVl/C1eUK8lkDTuEJ8Q4OS/VuW0G0bisjNhyO01n8TrvxEBhMifEiDfqxStOLS4ffdPq2v4lK4Rqd3AEvPiWcFAlKHAEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730742797; c=relaxed/simple; bh=ZDiG8zX1fgcovcm8UjN+AmQPvesoI2ZbNOk88XOFpJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M9DAZGvwyV16Sqrlp9Lxv06fDti79rHpzRNRn5oOJG9GU868eu2kqJz79itLH3BfyMhLRVB9egq2NhWF8P0fNNvnGQvnuZPte5YC2x9X7xD+IpbcnMW+9J6b/SCRmrk3RjlmQ1kHxfEoTV6SHWf8mPUJFlnU4lTp8iaBr7Vqr90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GCT/aAQQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GCT/aAQQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 422B7C4CECE; Mon, 4 Nov 2024 17:53:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730742797; bh=ZDiG8zX1fgcovcm8UjN+AmQPvesoI2ZbNOk88XOFpJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GCT/aAQQEmOiE2CO2EdcO0mROEbV/PfAf5s5dFqoJrvi8TiRxqzEg5keAyPOWOFk1 Uys/qnVri2Ogrf8M8+SC4ewpKvGR2yUpM/bijT4NVgYRqY5U6iP8y+JoY9zq89DIhJ nQTfVzz/LUQyI+5+BXl0on2TvUx8+cKWMRufZx+WEqPhP8miRBpf16hoHi98eaMRZq fHkKMin7SPACRskgM094/CkCiRzbpEIAZtj39hN0En/kIwGT8dqbT6O4i0pJ1kQP1p 0Z1FS0XLCI7+ahD6hGtDPHvS0sfVvC6JRbMWHZJ7tYisZ57b/QHe3aB+mHmn8h2kRu VUkjaRDhftlMQ== From: Jiri Olsa To: stable@vger.kernel.org Cc: Andrii Nakryiko , bpf@vger.kernel.org, Daniel Borkmann Subject: [PATCH stable 6.1 ] lib/buildid: Fix build ID parsing logic Date: Mon, 4 Nov 2024 18:52:54 +0100 Message-ID: <20241104175256.2327164-3-jolsa@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241104175256.2327164-1-jolsa@kernel.org> References: <20241104175256.2327164-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The parse_build_id_buf does not account Elf32_Nhdr header size when getting the build id data pointer and returns wrong build id data as result. This is problem only for stable trees that merged 84887f4c1c3a fix, the upstream build id code was refactored and returns proper build id. Acked-by: Andrii Nakryiko Fixes: 84887f4c1c3a ("lib/buildid: harden build ID parsing logic") Signed-off-by: Jiri Olsa --- lib/buildid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/buildid.c b/lib/buildid.c index e41fb0ee405f..cc5da016b235 100644 --- a/lib/buildid.c +++ b/lib/buildid.c @@ -40,7 +40,7 @@ static int parse_build_id_buf(unsigned char *build_id, name_sz == note_name_sz && memcmp(nhdr + 1, note_name, note_name_sz) == 0 && desc_sz > 0 && desc_sz <= BUILD_ID_SIZE_MAX) { - data = note_start + note_off + ALIGN(note_name_sz, 4); + data = note_start + note_off + sizeof(Elf32_Nhdr) + ALIGN(note_name_sz, 4); memcpy(build_id, data, desc_sz); memset(build_id + desc_sz, 0, BUILD_ID_SIZE_MAX - desc_sz); if (size)