linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guixiong Wei <weiguixiong@bytedance.com>
To: keescook@chromium.org, tglx@linutronix.de
Cc: jgross@suse.com, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	peterz@infradead.org, gregkh@linuxfoundation.org,
	tony.luck@intel.com, adobriyan@gmail.com,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	weiguixiong@bytedance.com
Subject: [PATCH] x86, relocs: Ignore relocations in .notes section on walk_relocs
Date: Sun, 17 Mar 2024 23:05:47 +0800	[thread overview]
Message-ID: <20240317150547.24910-1-weiguixiong@bytedance.com> (raw)

The commit aaa8736370db ("x86, relocs: Ignore relocations in
.notes section") only ignore .note section on print_absolute_relocs,
but it also need to add on walk_relocs to avoid relocations in .note
section.

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 <weiguixiong@bytedance.com>
---
 arch/x86/tools/relocs.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index b029fb81ebee..33844b33b8b9 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -746,6 +746,16 @@ 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 section; 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.24.3 (Apple Git-128)


             reply	other threads:[~2024-03-17 15:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-17 15:05 Guixiong Wei [this message]
2024-03-18 21:40 ` [PATCH] x86, relocs: Ignore relocations in .notes section on walk_relocs Kees Cook
2024-03-18 21:56   ` Borislav Petkov
2024-03-18 23:45     ` Kees Cook
2024-03-19  8:16       ` Borislav Petkov
2024-03-19 16:56         ` Kees Cook
2024-03-22 19:46           ` Borislav Petkov
2024-03-22 23:40             ` Kees Cook
2024-03-23 10:38               ` Borislav Petkov
2024-03-25 20:23                 ` Kees Cook
2024-03-22  8:45   ` Ingo Molnar
2024-03-22 23:41     ` Kees Cook
2024-03-24  3:57       ` [PATCH] x86/build: Clean up arch/x86/tools/relocs.c a bit Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240317150547.24910-1-weiguixiong@bytedance.com \
    --to=weiguixiong@bytedance.com \
    --cc=adobriyan@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).