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
305endif305endif
306endif306endif
307 307
308ifdef CONFIG_UNWINDER_ORC
309orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h
310orc_hash_sh := $(srctree)/scripts/orc_hash.sh
311targets += $(orc_hash_h)
312quiet_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)
317archprepare: $(orc_hash_h)
318endif
319
308archclean:320archclean:
309 $(Q)rm -rf $(objtree)/arch/i386321 $(Q)rm -rf $(objtree)/arch/i386
310 $(Q)rm -rf $(objtree)/arch/x86_64322 $(Q)rm -rf $(objtree)/arch/x86_64
arch/x86/include/asm/Kbuild+1−0
@@ -1,6 +1,7 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2 2
3 3
4generated-y += orc_hash.h
4generated-y += syscalls_32.h5generated-y += syscalls_32.h
5generated-y += syscalls_64.h6generated-y += syscalls_64.h
6generated-y += syscalls_x32.h7generated-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
7#include <asm/unwind.h>7#include <asm/unwind.h>
8#include <asm/orc_types.h>8#include <asm/orc_types.h>
9#include <asm/orc_lookup.h>9#include <asm/orc_lookup.h>
10#include <asm/orc_header.h>
11
12ORC_HEADER;
10 13
11#define orc_warn(fmt, ...) \14#define orc_warn(fmt, ...) \
12 printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)15 printk_deferred_once(KERN_WARNING "WARNING: " fmt, ##__VA_ARGS__)
include/asm-generic/vmlinux.lds.h+3−0
@@ -839,6 +839,9 @@ · 838 unmodified lines
839 839
840#ifdef CONFIG_UNWINDER_ORC840#ifdef CONFIG_UNWINDER_ORC
841#define ORC_UNWIND_TABLE \841#define ORC_UNWIND_TABLE \
842 .orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) { \
843 BOUNDED_SECTION_BY(.orc_header, _orc_header) \
844 } \
842 . = ALIGN(4); \845 . = ALIGN(4); \
843 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \846 .orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) { \
844 BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip) \847 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
1979 buf_printf(b, "#include <linux/vermagic.h>\n");1979 buf_printf(b, "#include <linux/vermagic.h>\n");
1980 buf_printf(b, "#include <linux/compiler.h>\n");1980 buf_printf(b, "#include <linux/compiler.h>\n");
1981 buf_printf(b, "\n");1981 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");
1982 buf_printf(b, "BUILD_SALT;\n");1987 buf_printf(b, "BUILD_SALT;\n");
1983 buf_printf(b, "BUILD_LTO_INFO;\n");1988 buf_printf(b, "BUILD_LTO_INFO;\n");
1984 buf_printf(b, "\n");1989 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
5set -e
6
7printf '%s' '#define ORC_HASH '
8
9awk '
10/^#define ORC_(REG|TYPE)_/ { print }
11/^struct orc_entry {$/ { p=1 }
12p { 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