History

Merge tag 'objtool_urgent_for_v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fix from Borislav Petkov: - Add a ORC format hash to vmlinux and modules in order for other tools which use it, to detect changes to it and adapt accordingly * tag 'objtool_urgent_for_v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/unwind/orc: Add ELF section with ORC version identifier

Linus Torvalds committed 3 years ago

Commit 300edd72 parents 661e723 b9f174c7 files · +59 −0Browse files

Unified · Split

7 files
  1. arch/x86/Makefile +12 −0
  2. arch/x86/include/asm/Kbuild +1 −0
  3. arch/x86/include/asm/orc_header.h +19 −0
  4. arch/x86/kernel/unwind_orc.c +3 −0
  5. include/asm-generic/vmlinux.lds.h +3 −0
  6. scripts/mod/modpost.c +5 −0
  7. scripts/orc_hash.sh +16 −0
arch/x86/Makefile+12−0
@@ -305,6 +305,18 @@ ifeq ($(RETPOLINE_CFLAGS),) · 304 unmodified lines
305305 endif
306306 endif
307307
308+ifdef CONFIG_UNWINDER_ORC
309+orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h
310+orc_hash_sh := $(srctree)/scripts/orc_hash.sh
311+targets += $(orc_hash_h)
312+quiet_cmd_orc_hash = GEN $@
313+ cmd_orc_hash = mkdir -p $(dir $@); \
314+ $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@
315+$(orc_hash_h): $(srctree)/arch/x86/include/asm/orc_types.h $(orc_hash_sh) FORCE
316+ $(call if_changed,orc_hash)
317+archprepare: $(orc_hash_h)
318+endif
319+
308320 archclean:
309321 $(Q)rm -rf $(objtree)/arch/i386
310322 $(Q)rm -rf $(objtree)/arch/x86_64
arch/x86/include/asm/Kbuild+1−0
@@ -1,6 +1,7 @@
11 # SPDX-License-Identifier: GPL-2.0
22
33
4+generated-y += orc_hash.h
45 generated-y += syscalls_32.h
56 generated-y += syscalls_64.h
67 generated-y += syscalls_x32.h
arch/x86/include/asm/orc_header.h+19−0
@@ -0,0 +1,19 @@
1+/* SPDX-License-Identifier: GPL-2.0-or-later */
2+/* Copyright (c) Meta Platforms, Inc. and affiliates. */
3+
4+#ifndef _ORC_HEADER_H
5+#define _ORC_HEADER_H
6+
7+#include <linux/types.h>
8+#include <linux/compiler.h>
9+#include <asm/orc_hash.h>
10+
11+/*
12+ * The header is currently a 20-byte hash of the ORC entry definition; see
13+ * scripts/orc_hash.sh.
14+ */
15+#define ORC_HEADER \
16+ __used __section(".orc_header") __aligned(4) \
17+ static const u8 orc_header[] = { ORC_HASH }
18+
19+#endif /* _ORC_HEADER_H */
arch/x86/kernel/unwind_orc.c+3−0
@@ -7,6 +7,9 @@ · 6 unmodified lines
77 #include <asm/unwind.h>
88 #include <asm/orc_types.h>
99 #include <asm/orc_lookup.h>
10+#include <asm/orc_header.h>
11+
12+ORC_HEADER;
1013
1114 #define orc_warn(fmt, ...) \
1215 printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
include/asm-generic/vmlinux.lds.h+3−0
@@ -839,6 +839,9 @@ · 838 unmodified lines
839839
840840 #ifdef CONFIG_UNWINDER_ORC
841841 #define ORC_UNWIND_TABLE \
842+ .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \
843+ BOUNDED_SECTION_BY(.orc_header, _orc_header) \
844+ } \
842845 . = ALIGN(4); \
843846 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \
844847 BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \
scripts/mod/modpost.c+5−0
@@ -1979,6 +1979,11 @@ static void add_header(struct buffer *b, struct module *mod) · 1978 unmodified lines
19791979 buf_printf(b, "#include <linux/vermagic.h>\n");
19801980 buf_printf(b, "#include <linux/compiler.h>\n");
19811981 buf_printf(b, "\n");
1982+ buf_printf(b, "#ifdef CONFIG_UNWINDER_ORC\n");
1983+ buf_printf(b, "#include <asm/orc_header.h>\n");
1984+ buf_printf(b, "ORC_HEADER;\n");
1985+ buf_printf(b, "#endif\n");
1986+ buf_printf(b, "\n");
19821987 buf_printf(b, "BUILD_SALT;\n");
19831988 buf_printf(b, "BUILD_LTO_INFO;\n");
19841989 buf_printf(b, "\n");
scripts/orc_hash.sh+16−0
@@ -0,0 +1,16 @@
1+#!/bin/sh
2+# SPDX-License-Identifier: GPL-2.0-or-later
3+# Copyright (c) Meta Platforms, Inc. and affiliates.
4+
5+set -e
6+
7+printf '%s' '#define ORC_HASH '
8+
9+awk '
10+/^#define ORC_(REG|TYPE)_/ { print }
11+/^struct orc_entry {$/ { p=1 }
12+p { print }
13+/^}/ { p=0 }' |
14+ sha1sum |
15+ cut -d " " -f 1 |
16+ sed 's/\([0-9a-f]\{2\}\)/0x\1,/g'

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t