Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibor Pechacek <lpechacek@suse.com>2017-07-12 11:08:57 +0200
committerMiroslav Benes <mbenes@suse.cz>2017-12-08 13:02:48 +0100
commit28a04a2be97498a9c227c83aa37a45306d165424 (patch)
treedb78c53daa3727c1ab71a6c84a4656a52b5984ac
parent5988feb7832d8c820988628ba943044ad389a917 (diff)
kGraft to livepatch migration. Internal rename.
Internal rename in preparation for kGraft -> upstream livepatch migration. External module naming stays the same. API is not touched yet. References: fate#323682 Signed-off-by: Libor Pechacek <lpechacek@suse.com> [ mb: changelog edit ] Signed-off-by: Miroslav Benes <mbenes@suse.cz>
-rw-r--r--livepatch_main.c (renamed from kgr_patch_main.c)33
-rw-r--r--rpm/kgraft-patch.spec12
-rwxr-xr-xscripts/register-patches.sh122
-rwxr-xr-xscripts/tar-up.sh4
-rw-r--r--uname_patch/kgr_patch_uname.h9
-rw-r--r--uname_patch/livepatch_uname.c (renamed from uname_patch/kgr_patch_uname.c)39
-rw-r--r--uname_patch/livepatch_uname.h9
7 files changed, 115 insertions, 113 deletions
diff --git a/kgr_patch_main.c b/livepatch_main.c
index c6aa8e0..d88fc2d 100644
--- a/kgr_patch_main.c
+++ b/livepatch_main.c
@@ -1,5 +1,5 @@
/*
- * kgr_main_patch.c - kGraft patch main infrastructure
+ * livepatch_main.c - kernel live patch main infrastructure
*
* Copyright (c) 2014 SUSE
* Author: Miroslav Benes <mbenes@suse.cz>
@@ -22,50 +22,51 @@
#include <linux/module.h>
#include <linux/types.h>
-#include "uname_patch/kgr_patch_uname.h"
+#include "uname_patch/livepatch_uname.h"
-@@KGR_PATCHES_INCLUDES@@
+@@KLP_PATCHES_INCLUDES@@
static struct kgr_patch patch = {
.name = "kgraft-patch-@@RPMRELEASE@@",
.owner = THIS_MODULE,
.replace_all = true,
.patches = {
- KGR_PATCH(SyS_newuname, kgr_sys_newuname),
- @@KGR_PATCHES_FUNCS@@,
+ KGR_PATCH(SyS_newuname, klp_sys_newuname),
+ @@KLP_PATCHES_FUNCS@@,
KGR_PATCH_END
}
};
-static int __init kgr_patch_init(void)
+static int __init klp_patch_init(void)
{
int retval;
- pr_info("kgraft-patch: initializing\n");
+ pr_info("livepatch: initializing\n");
- retval = kgr_patch_uname_init();
+ retval = klp_patch_uname_init();
if (retval)
return retval;
- @@KGR_PATCHES_INIT_CALLS@@;
+ @@KLP_PATCHES_INIT_CALLS@@;
retval = kgr_patch_kernel(&patch);
if (!retval)
return retval;
- /* jumped to from expanded KGR_PATCHES_INIT_CALLS on failure */
-@@KGR_PATCHES_INIT_ERR_HANDLERS@@:
+ /* jumped to from expanded KLP_PATCHES_INIT_CALLS on failure */
+@@KLP_PATCHES_INIT_ERR_HANDLERS@@:
}
-static void __exit kgr_patch_cleanup(void)
+static void __exit klp_patch_cleanup(void)
{
- pr_info("kgraft-patch: removed\n");
+ pr_info("livepatch: removed\n");
+
+ @@KLP_PATCHES_CLEANUP_CALLS@@;
- @@KGR_PATCHES_CLEANUP_CALLS@@;
kgr_patch_remove(&patch);
}
-module_init(kgr_patch_init);
-module_exit(kgr_patch_cleanup);
+module_init(klp_patch_init);
+module_exit(klp_patch_cleanup);
MODULE_LICENSE("GPL");
diff --git a/rpm/kgraft-patch.spec b/rpm/kgraft-patch.spec
index 868192a..f080e95 100644
--- a/rpm/kgraft-patch.spec
+++ b/rpm/kgraft-patch.spec
@@ -26,12 +26,12 @@ Summary: Kgraft patch module
Group: System/Kernel
Source0: uname_patch.tar.bz2
Source1: Makefile
-Source2: kgr_patch_main.c
+Source2: livepatch_main.c
Source3: config.sh
Source4: source-timestamp
Source5: shadow.c
Source6: shadow.h
-@@KGR_PATCHES_SOURCES@@
+@@KLP_PATCHES_SOURCES@@
BuildRequires: kernel-syms kgraft-devel
ExclusiveArch: @@EXCARCH@@
%kgraft_module_package
@@ -43,20 +43,20 @@ This is a live patch for SUSE Linux Enterprise Server kernel.
%prep
%setup -c
-@@KGR_PATCHES_SETUP_SOURCES@@
-cp %_sourcedir/kgr_patch_main.c .
+@@KLP_PATCHES_SETUP_SOURCES@@
+cp %_sourcedir/livepatch_main.c .
cp %_sourcedir/Makefile .
cp %_sourcedir/shadow.c .
cp %_sourcedir/shadow.h .
%build
sed -i 's/@@RPMRELEASE@@/%module_num/g' Makefile
-sed -i 's/@@RPMRELEASE@@/%module_num/g' kgr_patch_main.c
+sed -i 's/@@RPMRELEASE@@/%module_num/g' livepatch_main.c
echo 'kgraft-patch-%module_num' >Module.supported
set -- *
commit=$(sed -n 's/GIT Revision: //p' %_sourcedir/source-timestamp)
-sed -i "s/@@GITREV@@/${commit:0:7}/g" uname_patch/kgr_patch_uname.c
+sed -i "s/@@GITREV@@/${commit:0:7}/g" uname_patch/livepatch_uname.c
for flavor in %flavors_to_build; do
mkdir -p "obj/$flavor"
diff --git a/scripts/register-patches.sh b/scripts/register-patches.sh
index a3622f8..42fc916 100755
--- a/scripts/register-patches.sh
+++ b/scripts/register-patches.sh
@@ -21,71 +21,71 @@
#
# This script expects a kGraft subpatch to live in a subdirectory
-# SUBPATCH and to provide a SUBPATCH/kgr_patch_SUBPATCH.h
+# SUBPATCH and to provide a SUBPATCH/livepatch_SUBPATCH.h
# header.
#
# This header must provide declarations for
-# - kgr_patch_SUBPATCH_init()
-# - kgr_patch_SUBPATCH_cleanup()
-# and an (all uppercase) KGR_PATCH_SUBPATCH_FUNCS macro.
+# - klp_patch_SUBPATCH_init()
+# - klp_patch_SUBPATCH_cleanup()
+# and an (all uppercase) KLP_PATCH_SUBPATCH_FUNCS macro.
# The latter should be a comma separated list of KGR_PATCH*() entries,
# each corresponding to a function the subpatch wants to replace.
#
# Usage:
-# register-patches.sh kgr_patch_main.c kgraft-patch.spec
+# register-patches.sh livepatch_main.c kgraft-patch.spec
#
# This will properly substitute a number of placeholders in-place.
#
-kgr_patch_main_file="$1"
-kgr_patch_spec_file="$2"
+livepatch_main_file="$1"
+livepatch_spec_file="$2"
# Generate list of patches
-declare -a kgr_patches
+declare -a livepatches
for d in *; do
[ -d "$d" ] || continue
[ x"$d" = xrpm -o x"$d" = xscripts -o x"$d" = xuname_patch ] && continue
- [ -e "$d/kgr_patch_main.c" ] && continue # this is some builddir
+ [ -e "$d/livepatch_main.c" ] && continue # this is some builddir
- if [ ! -f "$d/kgr_patch_${d}.h" ]; then
- echo "error: $d/ doesn't have a $d/kgr_patch_${d}.h" 1>&2
+ if [ ! -f "$d/livepatch_${d}.h" ]; then
+ echo "error: $d/ doesn't have a $d/livepatch_${d}.h" 1>&2
exit 1
fi
- kgr_patches[${#kgr_patches[@]}]=$(basename $d)
+ livepatches[${#livepatches[@]}]=$(basename $d)
done
# Sort it
-kgr_patches=($(
- for p in "${kgr_patches[@]}"; do
+livepatches=($(
+ for p in "${livepatches[@]}"; do
echo $p
done | sort))
-# Finish kgr_patch_main.c:
+# Finish livepatch_main.c:
## Add includes of per-patch headers.
-KGR_PATCHES_INCLUDES=$(
- echo -n "/* Auto expanded KGR_PATCHES_INCLUDES: */\n"
- for p in "${kgr_patches[@]}"; do
- echo -n "#include \"${p}/kgr_patch_${p}.h\"\n"
+KLP_PATCHES_INCLUDES=$(
+ echo -n "/* Auto expanded KLP_PATCHES_INCLUDES: */\n"
+ for p in "${livepatches[@]}"; do
+ echo -n "#include \"${p}/livepatch_${p}.h\"\n"
done)
-## Add the individual patches' replacement entries to struct kgr_patch.
-KGR_PATCHES_FUNCS=$(
- echo -n "\t\t/* Auto expanded KGR_PATCHES_FUNCS: */\n"
- for p in "${kgr_patches[@]}"; do
- p="KGR_PATCH_$(echo $p | tr '[:lower:]' '[:upper:]')_FUNCS"
+## Add the individual patches' replacement entries to struct livepatch.
+KLP_PATCHES_FUNCS=$(
+ echo -n "\t\t/* Auto expanded KLP_PATCHES_FUNCS: */\n"
+ for p in "${livepatches[@]}"; do
+ p="KLP_PATCH_$(echo $p | tr '[:lower:]' '[:upper:]')_FUNCS"
echo -n "\t\t${p}\n"
done | sed 's/\\n$//' # rm trailing extra newlines
)
-## Initialize the individual patches in kgr_patch_init().
-KGR_PATCHES_INIT_CALLS=$(
- echo -n "\t/* Auto expanded KGR_PATCHES_INIT_CALLS: */\n"
- for p in "${kgr_patches[@]}"; do
+## Initialize the individual patches in livepatch_init().
+KLP_PATCHES_INIT_CALLS=$(
+ echo -n "\t/* Auto expanded KLP_PATCHES_INIT_CALLS: */\n"
+ for p in "${livepatches[@]}"; do
cat <<EOF
- retval = kgr_patch_${p}_init();
+ retval = livepatch_${p}_init();
if (retval)
goto err_${p};
@@ -94,32 +94,32 @@ EOF
| sed 's/\(\\n\)\?\\n$//' # rm trailing extra newlines
)
-## Setup the rollback error handlers in kgr_patch_init().
-KGR_PATCHES_INIT_ERR_HANDLERS=$(
- echo -n "\t/* Auto expanded KGR_PATCHES_INIT_ERR_HANDLERS: */\n"
- for i in $(seq $((${#kgr_patches[@]} - 1)) -1 0); do
+## Setup the rollback error handlers in livepatch_init().
+KLP_PATCHES_INIT_ERR_HANDLERS=$(
+ echo -n "\t/* Auto expanded KLP_PATCHES_INIT_ERR_HANDLERS: */\n"
+ for i in $(seq $((${#livepatches[@]} - 1)) -1 0); do
cat <<EOF
- kgr_patch_${kgr_patches[$i]}_cleanup();
-err_${kgr_patches[$i]}:
+ livepatch_${livepatches[$i]}_cleanup();
+err_${livepatches[$i]}:
EOF
done | sed 's%\t%\\t%g' | sed 's%$%\\n%g' | tr -d '\n';
echo "\treturn retval;"
)
-## Cleanup the individual patches in kgr_patch_cleanup().
-KGR_PATCHES_CLEANUP_CALLS=$(
- echo -n "\t/* Auto expanded KGR_PATCHES_CLEANUP_CALLS: */\n"
- for p in "${kgr_patches[@]}"; do
- echo -n "\tkgr_patch_${p}_cleanup();\n"
+## Cleanup the individual patches in livepatch_cleanup().
+KLP_PATCHES_CLEANUP_CALLS=$(
+ echo -n "\t/* Auto expanded KLP_PATCHES_CLEANUP_CALLS: */\n"
+ for p in "${livepatches[@]}"; do
+ echo -n "\tlivepatch_${p}_cleanup();\n"
done)
-sed -i -f - "$kgr_patch_main_file" <<EOF
-s%@@KGR_PATCHES_INCLUDES@@%$KGR_PATCHES_INCLUDES%;
-s%\s*@@KGR_PATCHES_FUNCS@@,\?%$KGR_PATCHES_FUNCS%;
-s%\s*@@KGR_PATCHES_INIT_CALLS@@;\?%$KGR_PATCHES_INIT_CALLS%;
-s%\s*@@KGR_PATCHES_INIT_ERR_HANDLERS@@:\?%$KGR_PATCHES_INIT_ERR_HANDLERS%;
-s%\s*@@KGR_PATCHES_CLEANUP_CALLS@@;\?%$KGR_PATCHES_CLEANUP_CALLS%;
-s%\s*@@KGR_PATCHES_CLEANUP_CALLS@@;\?%$KGR_PATCHES_CLEANUP_CALLS%;
+sed -i -f - "$livepatch_main_file" <<EOF
+s%@@KLP_PATCHES_INCLUDES@@%$KLP_PATCHES_INCLUDES%;
+s%\s*@@KLP_PATCHES_FUNCS@@,\?%$KLP_PATCHES_FUNCS%;
+s%\s*@@KLP_PATCHES_INIT_CALLS@@;\?%$KLP_PATCHES_INIT_CALLS%;
+s%\s*@@KLP_PATCHES_INIT_ERR_HANDLERS@@:\?%$KLP_PATCHES_INIT_ERR_HANDLERS%;
+s%\s*@@KLP_PATCHES_CLEANUP_CALLS@@;\?%$KLP_PATCHES_CLEANUP_CALLS%;
+s%\s*@@KLP_PATCHES_CLEANUP_CALLS@@;\?%$KLP_PATCHES_CLEANUP_CALLS%;
EOF
@@ -129,31 +129,31 @@ EOF
S=7
## First check that none of the to be occupied Source<n> slots has
## been used already.
-for i in "${!kgr_patches[@]}"; do
- if grep -q "^\s*Source$((i+S))\s*:" "$kgr_patch_spec_file"; then
- echo "error: Source$((i+S)) already used in $kgr_patch_spec_file" 1>&2
+for i in "${!livepatches[@]}"; do
+ if grep -q "^\s*Source$((i+S))\s*:" "$livepatch_spec_file"; then
+ echo "error: Source$((i+S)) already used in $livepatch_spec_file" 1>&2
exit 1;
fi
done
-KGR_PATCHES_SOURCES=$(
- echo -n "# Auto expanded KGR_PATCHES_SOURCES:\n"
- for i in "${!kgr_patches[@]}"; do
- echo -n "Source$((i+S)):\t${kgr_patches[i]}.tar.bz2\n"
+KLP_PATCHES_SOURCES=$(
+ echo -n "# Auto expanded KLP_PATCHES_SOURCES:\n"
+ for i in "${!livepatches[@]}"; do
+ echo -n "Source$((i+S)):\t${livepatches[i]}.tar.bz2\n"
done | sed 's/\\n$//' # rm trailing extra newlines
)
## And extract them from %prep
-KGR_PATCHES_SETUP_SOURCES=$(
- echo -n "# Auto expanded KGR_PATCHES_SETUP_SOURCES:\n"
- if [ ${#kgr_patches[@]} -gt 0 ]; then
+KLP_PATCHES_SETUP_SOURCES=$(
+ echo -n "# Auto expanded KLP_PATCHES_SETUP_SOURCES:\n"
+ if [ ${#livepatches[@]} -gt 0 ]; then
echo -n '%setup -T -D'
- for i in "${!kgr_patches[@]}"; do
+ for i in "${!livepatches[@]}"; do
echo -n " -a $((i+S))"
done
fi)
-sed -i -f - "$kgr_patch_spec_file" <<EOF
-s%@@KGR_PATCHES_SOURCES@@%$KGR_PATCHES_SOURCES%;
-s,@@KGR_PATCHES_SETUP_SOURCES@@,$KGR_PATCHES_SETUP_SOURCES,;
+sed -i -f - "$livepatch_spec_file" <<EOF
+s%@@KLP_PATCHES_SOURCES@@%$KLP_PATCHES_SOURCES%;
+s,@@KLP_PATCHES_SETUP_SOURCES@@,$KLP_PATCHES_SETUP_SOURCES,;
EOF
diff --git a/scripts/tar-up.sh b/scripts/tar-up.sh
index cb58c80..9b0ce0e 100755
--- a/scripts/tar-up.sh
+++ b/scripts/tar-up.sh
@@ -72,9 +72,9 @@ done
# install to builddir
source $(dirname $0)/release-version.sh
-install -m 644 kgr_patch_main.c $build_dir
+install -m 644 livepatch_main.c $build_dir
install -m 644 rpm/kgraft-patch.spec $build_dir/kgraft-patch-"$RELEASE".spec
-scripts/register-patches.sh $build_dir/kgr_patch_main.c $build_dir/kgraft-patch-"$RELEASE".spec
+scripts/register-patches.sh $build_dir/livepatch_main.c $build_dir/kgraft-patch-"$RELEASE".spec
install -m 644 rpm/config.sh $build_dir/config.sh
install -m 644 shadow.c $build_dir
install -m 644 shadow.h $build_dir
diff --git a/uname_patch/kgr_patch_uname.h b/uname_patch/kgr_patch_uname.h
deleted file mode 100644
index d6625e3..0000000
--- a/uname_patch/kgr_patch_uname.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _KGR_PATCH_UNAME_H
-#define _KGR_PATCH_UNAME_H
-
-#include <linux/utsname.h>
-
-extern int kgr_patch_uname_init(void);
-extern asmlinkage long kgr_sys_newuname(struct new_utsname __user *name);
-
-#endif
diff --git a/uname_patch/kgr_patch_uname.c b/uname_patch/livepatch_uname.c
index 3a53f83..e3878e1 100644
--- a/uname_patch/kgr_patch_uname.c
+++ b/uname_patch/livepatch_uname.c
@@ -73,69 +73,70 @@ static int override_release(char __user *release, size_t len)
return ret;
}
-char *kgr_tag="/kGraft-@@GITREV@@";
+char *klp_tag="/lp-@@GITREV@@";
-static struct rw_semaphore *kgr_uts_sem;
-static int override_version(char __user *version, size_t len, char *kgr_version)
+static struct rw_semaphore *klp_uts_sem;
+
+static int override_version(char __user *version, size_t len, char *klp_version)
{
int ret = 0;
char *right_brace;
size_t newlen;
- newlen = strlen(kgr_version) + strlen(kgr_tag);
+ newlen = strlen(klp_version) + strlen(klp_tag);
if (newlen >= len) {
- WARN_ONCE(1, "kgraft-patch: not enough space for utsname.version extension");
+ WARN_ONCE(1, "livepatch: not enough space for utsname.version extension");
goto out;
}
- right_brace = strchr(kgr_version, ')');
+ right_brace = strchr(klp_version, ')');
if (!right_brace) {
- WARN_ONCE(1, "kgraft-patch: did not find the commit id");
+ WARN_ONCE(1, "livepatch: did not find the commit id");
goto out;
}
- memmove(right_brace + strlen(kgr_tag), right_brace,
+ memmove(right_brace + strlen(klp_tag), right_brace,
strlen(right_brace) + 1);
- memcpy(right_brace, kgr_tag, strlen(kgr_tag));
+ memcpy(right_brace, klp_tag, strlen(klp_tag));
- ret = copy_to_user(version, kgr_version, newlen + 1);
+ ret = copy_to_user(version, klp_version, newlen + 1);
out:
return ret;
}
-asmlinkage long kgr_sys_newuname(struct new_utsname __user *name)
+asmlinkage long klp_sys_newuname(struct new_utsname __user *name)
{
int errno = 0;
- char kgr_version[65] = { 0 };
+ char klp_version[65] = { 0 };
- down_read(kgr_uts_sem);
+ down_read(klp_uts_sem);
if (copy_to_user(name, utsname(), sizeof *name))
errno = -EFAULT;
- memcpy(kgr_version, utsname()->version, sizeof(utsname()->version));
- up_read(kgr_uts_sem);
+ memcpy(klp_version, utsname()->version, sizeof(utsname()->version));
+ up_read(klp_uts_sem);
if (!errno && override_release(name->release, sizeof(name->release)))
errno = -EFAULT;
if (!errno && override_architecture(name))
errno = -EFAULT;
if (!errno && override_version(name->version, sizeof(name->version),
- kgr_version))
+ klp_version))
errno = -EFAULT;
return errno;
}
-int kgr_patch_uname_init(void)
+int klp_patch_uname_init(void)
{
unsigned long addr;
addr = kallsyms_lookup_name("uts_sem");
if (!addr) {
- pr_err("kgraft-patch: symbol uts_sem not resolved\n");
+ pr_err("livepatch: symbol uts_sem not resolved\n");
return -EFAULT;
}
- kgr_uts_sem = (struct rw_semaphore *) addr;
+ klp_uts_sem = (struct rw_semaphore *) addr;
return 0;
}
diff --git a/uname_patch/livepatch_uname.h b/uname_patch/livepatch_uname.h
new file mode 100644
index 0000000..ccfd6c5
--- /dev/null
+++ b/uname_patch/livepatch_uname.h
@@ -0,0 +1,9 @@
+#ifndef _LIVEPATCH_UNAME_H
+#define _LIVEPATCH_UNAME_H
+
+#include <linux/utsname.h>
+
+extern int klp_patch_uname_init(void);
+extern asmlinkage long klp_sys_newuname(struct new_utsname __user *name);
+
+#endif