Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiroslav Benes <mbenes@suse.cz>2018-11-02 17:23:48 +0100
committerMiroslav Benes <mbenes@suse.cz>2018-11-02 17:26:46 +0100
commita00eabe24f861f9ad2f6d7223dc1f3ef3f58ac58 (patch)
treee4878cdd140f62f52d539c96d93b9f1f92120acd
parentac36eb6dfa850ef2a98d42d4b6295abb5c1e0b3b (diff)
livepatch: create and include UAPI headers (fate#326849).
-rw-r--r--patches.suse/livepatch-create-and-include-UAPI-headers.patch116
-rw-r--r--series.conf1
2 files changed, 117 insertions, 0 deletions
diff --git a/patches.suse/livepatch-create-and-include-UAPI-headers.patch b/patches.suse/livepatch-create-and-include-UAPI-headers.patch
new file mode 100644
index 0000000000..d3ca1a7203
--- /dev/null
+++ b/patches.suse/livepatch-create-and-include-UAPI-headers.patch
@@ -0,0 +1,116 @@
+From: Josh Poimboeuf <jpoimboe@redhat.com>
+Subject: livepatch: create and include UAPI headers
+Patch-mainline: Submitted, https://lore.kernel.org/lkml/20170829190140.401-1-jmoreira@suse.de/
+References: fate#326849
+
+Replace hard-coded values in kernel/livepatch/core.c with defines and put
+them into a new UAPI file so they can also be used by klp-convert, an elf
+processing tool for formatting live patching relocations properly.
+
+Define macros KLP_MODULE_RELOC and KLP_SYMPOS in
+include/linux/livepatch.h to improve user-friendliness of the
+livepatch annotation process.
+
+Update MAINTAINERS.
+
+Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
+Reviewed-by: Petr Mladek <pmladek@suse.com>
+Signed-off-by: Joao Moreira <jmoreira@suse.de>
+Signed-off-by: Miroslav Benes <mbenes@suse.cz>
+
+---
+ MAINTAINERS | 1 +
+ include/linux/livepatch.h | 12 ++++++++++++
+ include/uapi/linux/livepatch.h | 28 ++++++++++++++++++++++++++++
+ kernel/livepatch/core.c | 4 ++--
+ 4 files changed, 43 insertions(+), 2 deletions(-)
+
+--- a/MAINTAINERS
++++ b/MAINTAINERS
+@@ -7728,6 +7728,7 @@ R: Petr Mladek <pmladek@suse.com>
+ S: Maintained
+ F: kernel/livepatch/
+ F: include/linux/livepatch.h
++F: include/uapi/linux/livepatch.h
+ F: arch/x86/include/asm/livepatch.h
+ F: arch/x86/kernel/livepatch.c
+ F: Documentation/livepatch/
+--- a/include/linux/livepatch.h
++++ b/include/linux/livepatch.h
+@@ -25,6 +25,7 @@
+ #include <linux/ftrace.h>
+ #include <linux/completion.h>
+ #include <linux/list.h>
++#include <uapi/linux/livepatch.h>
+
+ #if IS_ENABLED(CONFIG_LIVEPATCH)
+
+@@ -230,6 +231,17 @@ void *klp_shadow_get_or_alloc(void *obj,
+ void klp_shadow_free(void *obj, unsigned long id, klp_shadow_dtor_t dtor);
+ void klp_shadow_free_all(unsigned long id, klp_shadow_dtor_t dtor);
+
++/* Used to annotate symbol relocations in live patches */
++#define KLP_MODULE_RELOC(obj) \
++ struct klp_module_reloc \
++ __attribute__((__section__(".klp.module_relocs." #obj)))
++
++#define KLP_SYMPOS(symbol, pos) \
++ { \
++ .sym = &symbol, \
++ .sympos = pos, \
++ },
++
+ #else /* !CONFIG_LIVEPATCH */
+
+ static inline int klp_module_coming(struct module *mod) { return 0; }
+--- /dev/null
++++ b/include/uapi/linux/livepatch.h
+@@ -0,0 +1,28 @@
++/*
++ * livepatch.h - Kernel Live Patching Core
++ *
++ * Copyright (C) 2016 Josh Poimboeuf <jpoimboe@redhat.com>
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License
++ * as published by the Free Software Foundation; either version 2
++ * of the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, see <http://www.gnu.org/licenses/>.
++ */
++
++#ifndef _UAPI_LIVEPATCH_H
++#define _UAPI_LIVEPATCH_H
++
++#include <linux/types.h>
++
++#define KLP_RELA_PREFIX ".klp.rela."
++#define KLP_SYM_PREFIX ".klp.sym."
++
++#endif /* _UAPI_LIVEPATCH_H */
+--- a/kernel/livepatch/core.c
++++ b/kernel/livepatch/core.c
+@@ -261,7 +261,7 @@ static int klp_resolve_symbols(Elf_Shdr
+
+ /* Format: .klp.sym.objname.symname,sympos */
+ cnt = sscanf(strtab + sym->st_name,
+- ".klp.sym.%55[^.].%127[^,],%lu",
++ KLP_SYM_PREFIX "%55[^.].%127[^,],%lu",
+ objname, symname, &sympos);
+ if (cnt != 3) {
+ pr_err("symbol %s has an incorrectly formatted name\n",
+@@ -307,7 +307,7 @@ static int klp_write_object_relocations(
+ * See comment in klp_resolve_symbols() for an explanation
+ * of the selected field width value.
+ */
+- cnt = sscanf(secname, ".klp.rela.%55[^.]", sec_objname);
++ cnt = sscanf(secname, KLP_RELA_PREFIX "%55[^.]", sec_objname);
+ if (cnt != 1) {
+ pr_err("section %s has an incorrectly formatted name\n",
+ secname);
diff --git a/series.conf b/series.conf
index 0362bfbc06..94915e95c7 100644
--- a/series.conf
+++ b/series.conf
@@ -19120,6 +19120,7 @@
# klp-convert
patches.suse/livepatch-modpost-ignore-unresolved-symbols.patch
+ patches.suse/livepatch-create-and-include-UAPI-headers.patch
########################################################
# XEN patches