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 839441078F; Mon, 27 May 2024 19:04:18 +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=1716836658; cv=none; b=fT3uctT/Z0TtH+4jKknBymTmcU5vqDDsZ74rVlBRZVGtJyTaxGDd7S/oVETOSXUmCcjAdk3twnEgIgbKR/8YMf7sZZLAy+IeApvzWDNn9xaAWtzqGbXFVMXz8Fv8SnQ8LEOmrhfccCsWFeSRgjhfQMe22JobHNh1N7azxznvjzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716836658; c=relaxed/simple; bh=k9Qy4prIVsPhxyXMlnuk6KGf9YnLvY3GnH3+41tVQRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cAykh1VZZF+c8GMAiN//nAEVV8S63Wwa4ir+CWHl2zRvrPOHwgeJniWRRYWBlpuf6EAvo2H2ApmBiLL9mKmfZnoyfnrc0btCMCMONBbPUt9HbLVnwiZL5B1c7M8DCdR2lavEbqBVqdtGw112rHR1OfYMbwaNcaC9ZuuQYYX07Zo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zpkzC9fN; 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="zpkzC9fN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 139D4C2BBFC; Mon, 27 May 2024 19:04:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716836658; bh=k9Qy4prIVsPhxyXMlnuk6KGf9YnLvY3GnH3+41tVQRo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zpkzC9fNkibOWyxId2R5kuKaI4maVhwqsZdPpEgRUVBcKHw711viQ74egPW+/qHZd pALVWwDUUayDEzxvQYGFGPHsYWxR/47SWESnZ98W5lEWTH4//xjYDko3eTQPgjEiV2 W+p39oLIDBBue+Dtey2SV6/D930b9aw/kpJbDd98= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guixiong Wei , Ingo Molnar , Kees Cook , Sasha Levin Subject: [PATCH 6.9 097/427] x86/boot: Ignore relocations in .notes sections in walk_relocs() too Date: Mon, 27 May 2024 20:52:24 +0200 Message-ID: <20240527185610.862109820@linuxfoundation.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527185601.713589927@linuxfoundation.org> References: <20240527185601.713589927@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guixiong Wei [ Upstream commit 76e9762d66373354b45c33b60e9a53ef2a3c5ff2 ] Commit: aaa8736370db ("x86, relocs: Ignore relocations in .notes section") ... only started ignoring the .notes sections in print_absolute_relocs(), but the same logic should also by applied in walk_relocs() to avoid such relocations. [ mingo: Fixed various typos in the changelog, removed extra curly braces from the code. ] Fixes: aaa8736370db ("x86, relocs: Ignore relocations in .notes section") Fixes: 5ead97c84fa7 ("xen: Core Xen implementation") Fixes: da1a679cde9b ("Add /sys/kernel/notes") Signed-off-by: Guixiong Wei Signed-off-by: Ingo Molnar Reviewed-by: Kees Cook Link: https://lore.kernel.org/r/20240317150547.24910-1-weiguixiong@bytedance.com Signed-off-by: Sasha Levin --- arch/x86/tools/relocs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c index b029fb81ebeee..e7a44a7f617fb 100644 --- a/arch/x86/tools/relocs.c +++ b/arch/x86/tools/relocs.c @@ -746,6 +746,15 @@ static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel, if (!(sec_applies->shdr.sh_flags & SHF_ALLOC)) { continue; } + + /* + * Do not perform relocations in .notes sections; any + * values there are meant for pre-boot consumption (e.g. + * startup_xen). + */ + if (sec_applies->shdr.sh_type == SHT_NOTE) + continue; + sh_symtab = sec_symtab->symtab; sym_strtab = sec_symtab->link->strtab; for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) { -- 2.43.0