[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240516133009.20224-2-lhruska@suse.cz>
Date: Thu, 16 May 2024 15:30:04 +0200
From: Lukas Hruska <lhruska@...e.cz>
To: pmladek@...e.com,
mbenes@...e.cz,
jpoimboe@...nel.org
Cc: joe.lawrence@...hat.com,
live-patching@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-kbuild@...r.kernel.org,
mpdesouza@...e.com,
lhruska@...e.cz,
Josh Poimboeuf <jpoimboe@...hat.com>
Subject: [PATCH v2 1/6] livepatch: Create and include UAPI headers
From: Josh Poimboeuf <jpoimboe@...hat.com>
Define klp prefixes in include/uapi/linux/livepatch.h, and use them for
replacing hard-coded values in kernel/livepatch/core.c.
Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
Signed-off-by: Lukas Hruska <lhruska@...e.cz>
Reviewed-by: Petr Mladek <pmladek@...e.com>
Reviewed-by: Marcos Paulo de Souza <mpdesouza@...e.com>
---
MAINTAINERS | 1 +
include/uapi/linux/livepatch.h | 15 +++++++++++++++
kernel/livepatch/core.c | 5 +++--
3 files changed, 19 insertions(+), 2 deletions(-)
create mode 100644 include/uapi/linux/livepatch.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 28e20975c26f..130b8b0bd4f7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12614,6 +12614,7 @@ F: Documentation/ABI/testing/sysfs-kernel-livepatch
F: Documentation/livepatch/
F: arch/powerpc/include/asm/livepatch.h
F: include/linux/livepatch.h
+F: include/uapi/linux/livepatch.h
F: kernel/livepatch/
F: kernel/module/livepatch.c
F: samples/livepatch/
diff --git a/include/uapi/linux/livepatch.h b/include/uapi/linux/livepatch.h
new file mode 100644
index 000000000000..e19430918a07
--- /dev/null
+++ b/include/uapi/linux/livepatch.h
@@ -0,0 +1,15 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+/*
+ * livepatch.h - Kernel Live Patching Core
+ *
+ * Copyright (C) 2016 Josh Poimboeuf <jpoimboe@...hat.com>
+ */
+
+#ifndef _UAPI_LIVEPATCH_H
+#define _UAPI_LIVEPATCH_H
+
+#define KLP_RELA_PREFIX ".klp.rela."
+#define KLP_SYM_PREFIX ".klp.sym."
+
+#endif /* _UAPI_LIVEPATCH_H */
diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c
index ecbc9b6aba3a..8bde84d85263 100644
--- a/kernel/livepatch/core.c
+++ b/kernel/livepatch/core.c
@@ -20,6 +20,7 @@
#include <linux/completion.h>
#include <linux/memory.h>
#include <linux/rcupdate.h>
+#include <uapi/linux/livepatch.h>
#include <asm/cacheflush.h>
#include "core.h"
#include "patch.h"
@@ -226,7 +227,7 @@ static int klp_resolve_symbols(Elf_Shdr *sechdrs, const char *strtab,
/* Format: .klp.sym.sym_objname.sym_name,sympos */
cnt = sscanf(strtab + sym->st_name,
- ".klp.sym.%55[^.].%511[^,],%lu",
+ KLP_SYM_PREFIX "%55[^.].%511[^,],%lu",
sym_objname, sym_name, &sympos);
if (cnt != 3) {
pr_err("symbol %s has an incorrectly formatted name\n",
@@ -305,7 +306,7 @@ static int klp_write_section_relocs(struct module *pmod, Elf_Shdr *sechdrs,
* See comment in klp_resolve_symbols() for an explanation
* of the selected field width value.
*/
- cnt = sscanf(shstrtab + sec->sh_name, ".klp.rela.%55[^.]",
+ cnt = sscanf(shstrtab + sec->sh_name, KLP_RELA_PREFIX "%55[^.]",
sec_objname);
if (cnt != 1) {
pr_err("section %s has an incorrectly formatted name\n",
--
2.45.0
Powered by blists - more mailing lists