From patchwork Thu Jun 2 20:40:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 9151181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9773C60751 for ; Thu, 2 Jun 2016 20:43:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 874CF26490 for ; Thu, 2 Jun 2016 20:43:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BFDF28326; Thu, 2 Jun 2016 20:43:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 815AA26490 for ; Thu, 2 Jun 2016 20:43:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8ZQ2-00009t-EU; Thu, 02 Jun 2016 20:40:42 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b8ZQ1-00009l-Eh for xen-devel@lists.xenproject.org; Thu, 02 Jun 2016 20:40:41 +0000 Received: from [193.109.254.147] by server-10.bemta-14.messagelabs.com id A3/C0-31433-8C990575; Thu, 02 Jun 2016 20:40:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXSO6nOVff4zIB wg5Y7Vhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0b3BNaC7cUVB64tYWxg/B/XxcjBISTQyiRx MKSLkQvI/MwoMeXHQXYIZwOjxI9zC1khnG5Gia8zr7B0MXICOUUSV3ZNYALpZhMwkXizyhEkL CJgK9G+aAUriM0sYCQxufEdWLmwgIPE+RWbwOIsAqoSK5d0sYHYvAJuEgf6vjGC2BICchLbtu yBsg0lTj/cxjiBkXcBI8MqRvXi1KKy1CJdQ72kosz0jJLcxMwcXUNDE73c1OLixPTUnMSkYr3 k/NxNjMBQYACCHYxHO50PMUpyMCmJ8jLGBoQL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuCtmwGU EyxKTU+tSMvMAQYlTFqCg0dJhHcFSJq3uCAxtzgzHSJ1ilGX49jcG2uZhFjy8vNSpcR5rUCKB ECKMkrz4EbAIuQSo6yUMC8j0FFCPAWpRbmZJajyrxjFORiVhHmjQabwZOaVwG16BXQEE9ARBY /8QY4oSURISTUwzlTo153+ra9egO25UtsfXdHDM1i2SBhnN8kd8KnbuUmr2UZ3l37BolrVg1v 6JB49v3FcwWvjXKcr0RVvY2ptmZTaWZYed+s9dZCJyWfapsM88dN/lHbuf6S1ftLbXDmGyp9n 3sxbZxTq/03i3YL9p6yPlG03n+s6o7/roAn/xXzlaWc27220VGIpzkg01GIuKk4EAJnzDsCLA gAA X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1464900038!45455716!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2279 invoked from network); 2 Jun 2016 20:40:39 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-9.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 2 Jun 2016 20:40:39 -0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u52KeaOP005691 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Jun 2016 20:40:37 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id u52KeatY017378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 2 Jun 2016 20:40:36 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id u52KeZig016708; Thu, 2 Jun 2016 20:40:36 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 02 Jun 2016 13:40:35 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id D7FA46A00FA; Thu, 2 Jun 2016 16:40:34 -0400 (EDT) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com Date: Thu, 2 Jun 2016 16:40:30 -0400 Message-Id: <1464900030-26305-1-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.5.5 X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH livepatch-tools] Rename of xSplice to LivePatch. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP s/xsplice/livepatch/ s/XSPLICE/LIVEPATCH/ s/xSplice/LivePatch/ Signed-off-by: Konrad Rzeszutek Wilk --- README.md | 26 ++++++++++++------------- common.h | 2 +- create-diff-object.c | 42 ++++++++++++++++++++-------------------- xsplice-build => livepatch-build | 32 +++++++++++++++--------------- xsplice-gcc => livepatch-gcc | 12 ++++++------ prelink.c | 4 ++-- 6 files changed, 59 insertions(+), 59 deletions(-) rename xsplice-build => livepatch-build (90%) rename xsplice-gcc => livepatch-gcc (80%) diff --git a/README.md b/README.md index c39b376..9fb709f 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -xsplice-build +livepatch-build ============= -xsplice-build is a tool for building xSplice patches from source code +livepatch-build is a tool for building LivePatch patches from source code patches. It takes as input, a Xen tree and a patch and outputs an -`.xsplice` module containing containing the live patch. +`.livepatch` module containing containing the live patch. Quick start ----------- @@ -15,14 +15,14 @@ $ cd ~/src/xen $ git reset --hard $ git clean -x -f -d $ git checkout 346d4545569928b652c40c7815c1732676f8587c^ -$ cd ~/src/xsplice-build +$ cd ~/src/livepatch-build $ wget -q 'http://xenbits.xen.org/xsa/xsa106.patch' -$ ./xsplice-build --xen-debug -s ~/src/xen -p xsa106.patch -o out -Building xSplice patch: xsa106 +$ ./livepatch-build --xen-debug -s ~/src/xen -p xsa106.patch -o out +Building LivePatch patch: xsa106 Xen directory: /home/ross/src/xen -Patch file: /home/ross/src/xsplice-build/xsa106.patch -Output directory: /home/ross/src/xsplice-build/out +Patch file: /home/ross/src/livepatch-build/xsa106.patch +Output directory: /home/ross/src/livepatch-build/out ================================================ Testing patch file... @@ -32,10 +32,10 @@ Unapply patch and build with 4 CPU(s)... Extracting new and modified ELF sections... Processing xen/arch/x86/x86_emulate.o Creating patch module... -xsa106.xsplice created successfully +xsa106.livepatch created successfully -$ ls -lh out/xsa106.xsplice --rw-rw-r--. 1 ross ross 418K Oct 12 12:02 out/xsa106.xsplice +$ ls -lh out/xsa106.livepatch +-rw-rw-r--. 1 ross ross 418K Oct 12 12:02 out/xsa106.livepatch ``` Project Status @@ -43,7 +43,7 @@ Project Status This is prototype code: * There's no way to apply built patches * Patches cannot be built for some source patches - * The output format does not correspond to the latest xSplice design + * The output format does not correspond to the latest LivePatch design With no source patch modifications, live patches can be built for every XSA that applies to x86 back to XSA-90 except for XSA-97, XSA-111, @@ -51,7 +51,7 @@ XSA-112, and XSA-114 (83% success rate). License ------- -xSplice is under the GPLv2 license. +LivePatch is under the GPLv2 license. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/common.h b/common.h index d76881c..7599fe7 100644 --- a/common.h +++ b/common.h @@ -116,7 +116,7 @@ struct kpatch_elf { #define PATCH_INSN_SIZE 5 -struct xsplice_patch_func { +struct livepatch_patch_func { char *name; unsigned long new_addr; unsigned long old_addr; diff --git a/create-diff-object.c b/create-diff-object.c index 0488556..69bcd88 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -860,7 +860,7 @@ static void kpatch_mark_ignored_functions_same(struct kpatch_elf *kelf) struct section *sec; struct rela *rela; - sec = find_section_by_name(&kelf->sections, ".xsplice.ignore.functions"); + sec = find_section_by_name(&kelf->sections, ".livepatch.ignore.functions"); if (!sec) return; @@ -887,7 +887,7 @@ static void kpatch_mark_ignored_sections(struct kpatch_elf *kelf) struct rela *rela; char *name; - sec = find_section_by_name(&kelf->sections, ".xsplice.ignore.sections"); + sec = find_section_by_name(&kelf->sections, ".livepatch.ignore.sections"); if (!sec) return; @@ -1297,10 +1297,10 @@ static void kpatch_include_hook_elements(struct kpatch_elf *kelf) /* include load/unload sections */ list_for_each_entry(sec, &kelf->sections, list) { - if (!strcmp(sec->name, ".xsplice.hooks.load") || - !strcmp(sec->name, ".xsplice.hooks.unload") || - !strcmp(sec->name, ".rela.xsplice.hooks.load") || - !strcmp(sec->name, ".rela.xsplice.hooks.unload")) { + if (!strcmp(sec->name, ".livepatch.hooks.load") || + !strcmp(sec->name, ".livepatch.hooks.unload") || + !strcmp(sec->name, ".rela.livepatch.hooks.load") || + !strcmp(sec->name, ".rela.livepatch.hooks.unload")) { sec->include = 1; if (is_rela_section(sec)) { /* include hook dependencies */ @@ -1325,8 +1325,8 @@ static void kpatch_include_hook_elements(struct kpatch_elf *kelf) * used by the kpatch_[load|unload]() macros. */ list_for_each_entry(sym, &kelf->symbols, list) - if (!strcmp(sym->name, "xsplice_load_data") || - !strcmp(sym->name, "xsplice_unload_data")) + if (!strcmp(sym->name, "livepatch_load_data") || + !strcmp(sym->name, "livepatch_unload_data")) sym->include = 0; } @@ -1469,7 +1469,7 @@ static void kpatch_create_strings_elements(struct kpatch_elf *kelf) /* allocate section resources */ ALLOC_LINK(sec, &kelf->sections); - sec->name = ".xsplice.strings"; + sec->name = ".livepatch.strings"; /* set data */ sec->data = malloc(sizeof(*sec->data)); @@ -1490,7 +1490,7 @@ static void kpatch_create_strings_elements(struct kpatch_elf *kelf) sym->sym.st_info = GELF_ST_INFO(STB_LOCAL, STT_SECTION); sym->type = STT_SECTION; sym->bind = STB_LOCAL; - sym->name = ".xsplice.strings"; + sym->name = ".livepatch.strings"; } static void kpatch_build_strings_section_data(struct kpatch_elf *kelf) @@ -1500,7 +1500,7 @@ static void kpatch_build_strings_section_data(struct kpatch_elf *kelf) int size; char *strtab; - sec = find_section_by_name(&kelf->sections, ".xsplice.strings"); + sec = find_section_by_name(&kelf->sections, ".livepatch.strings"); if (!sec) ERROR("can't find .kpatch.strings"); @@ -1560,7 +1560,7 @@ static char *mangle_local_symbol(char *filename, char *symname) * Rename local symbols to the filename#symbol format used by Xen's "special" * symbol table. */ -static void xsplice_rename_local_symbols(struct kpatch_elf *kelf, char *hint) +static void livepatch_rename_local_symbols(struct kpatch_elf *kelf, char *hint) { struct symbol *sym; @@ -1638,7 +1638,7 @@ static struct section *create_section_pair(struct kpatch_elf *kelf, return sec; } -static void xsplice_create_patches_sections(struct kpatch_elf *kelf, +static void livepatch_create_patches_sections(struct kpatch_elf *kelf, struct lookup_table *table, char *hint, int resolve) { @@ -1647,7 +1647,7 @@ static void xsplice_create_patches_sections(struct kpatch_elf *kelf, struct symbol *sym, *strsym; struct rela *rela; struct lookup_result result; - struct xsplice_patch_func *funcs; + struct livepatch_patch_func *funcs; char *funcname; /* count patched functions */ @@ -1657,14 +1657,14 @@ static void xsplice_create_patches_sections(struct kpatch_elf *kelf, nr++; /* create text/rela section pair */ - sec = create_section_pair(kelf, ".xsplice.funcs", sizeof(*funcs), nr); + sec = create_section_pair(kelf, ".livepatch.funcs", sizeof(*funcs), nr); relasec = sec->rela; funcs = sec->data->d_buf; /* lookup strings symbol */ - strsym = find_symbol_by_name(&kelf->symbols, ".xsplice.strings"); + strsym = find_symbol_by_name(&kelf->symbols, ".livepatch.strings"); if (!strsym) - ERROR("can't find .xsplice.strings symbol"); + ERROR("can't find .livepatch.strings symbol"); /* populate sections */ index = 0; @@ -1713,7 +1713,7 @@ static void xsplice_create_patches_sections(struct kpatch_elf *kelf, rela->addend = 0; rela->offset = index * sizeof(*funcs); rela->offset = index * sizeof(*funcs) + - offsetof(struct xsplice_patch_func, new_addr); + offsetof(struct livepatch_patch_func, new_addr); /* * Add a relocation that will populate @@ -1724,7 +1724,7 @@ static void xsplice_create_patches_sections(struct kpatch_elf *kelf, rela->type = R_X86_64_64; rela->addend = offset_of_string(&kelf->strings, funcname); rela->offset = index * sizeof(*funcs) + - offsetof(struct xsplice_patch_func, name); + offsetof(struct livepatch_patch_func, name); index++; } @@ -1965,12 +1965,12 @@ int main(int argc, char *argv[]) log_debug("Create strings elements\n"); kpatch_create_strings_elements(kelf_out); log_debug("Create patches sections\n"); - xsplice_create_patches_sections(kelf_out, lookup, hint, + livepatch_create_patches_sections(kelf_out, lookup, hint, arguments.resolve); kpatch_build_strings_section_data(kelf_out); log_debug("Rename local symbols\n"); - xsplice_rename_local_symbols(kelf_out, hint); + livepatch_rename_local_symbols(kelf_out, hint); /* * At this point, the set of output sections and symbols is diff --git a/xsplice-build b/livepatch-build similarity index 90% rename from xsplice-build rename to livepatch-build index 5852186..a49e0d4 100755 --- a/xsplice-build +++ b/livepatch-build @@ -1,6 +1,6 @@ #!/bin/bash # -# xsplice build script +# livepatch build script # # Copyright (C) 2014 Seth Jennings # Copyright (C) 2013,2014 Josh Poimboeuf @@ -19,7 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# This script takes a Xen tree, and a patch and outputs an xsplice +# This script takes a Xen tree, and a patch and outputs an livepatch # module intended to patch Xen at runtime. # Large amounts of this script are taken from kpatch's kpatch-build # script. @@ -39,7 +39,7 @@ warn() { die() { if [[ -z $1 ]]; then - msg="xSplice build failed" + msg="LivePatch build failed" else msg="$1" fi @@ -78,10 +78,10 @@ function build_special() cd "${SRCDIR}" || die # Capture .o files from the patched build - export CROSS_COMPILE="${SCRIPTDIR}/xsplice-gcc " - export XSPLICE_BUILD_DIR="$(pwd)/" - export XSPLICE_CAPTURE_DIR="$OUTPUT/${name}" - mkdir -p "$XSPLICE_CAPTURE_DIR" + export CROSS_COMPILE="${SCRIPTDIR}/livepatch-gcc " + export LIVEPATCH_BUILD_DIR="$(pwd)/" + export LIVEPATCH_CAPTURE_DIR="$OUTPUT/${name}" + mkdir -p "$LIVEPATCH_CAPTURE_DIR" # Build with special GCC flags cd "${SRCDIR}/xen" || die @@ -89,8 +89,8 @@ function build_special() make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk - unset XSPLICE_BUILD_DIR - unset XSPLICE_CAPTURE_DIR + unset LIVEPATCH_BUILD_DIR + unset LIVEPATCH_CAPTURE_DIR } function create_patch() @@ -142,15 +142,15 @@ function create_patch() echo "Creating patch module..." if [ -z "$PRELINK" ]; then - ld -r -o "${PATCHNAME}.xsplice" --build-id=sha1 $(find output -type f -name "*.o") || die - chmod +x "${PATCHNAME}.xsplice" + ld -r -o "${PATCHNAME}.livepatch" --build-id=sha1 $(find output -type f -name "*.o") || die + chmod +x "${PATCHNAME}.livepatch" else ld -r -o output.o --build-id=sha1 $(find output -type f -name "*.o") || die - "${SCRIPTDIR}"/prelink $debugopt output.o "${PATCHNAME}.xsplice" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die + "${SCRIPTDIR}"/prelink $debugopt output.o "${PATCHNAME}.livepatch" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die fi - objcopy --add-section .xsplice.depends=depends.bin "${PATCHNAME}.xsplice" - objcopy --set-section-flags .xsplice.depends=alloc,readonly "${PATCHNAME}.xsplice" + objcopy --add-section .livepatch.depends=depends.bin "${PATCHNAME}.livepatch" + objcopy --set-section-flags .livepatch.depends=alloc,readonly "${PATCHNAME}.livepatch" } usage() { @@ -247,7 +247,7 @@ OUTPUT="$(readlink -m -- "$outputarg")" PATCHNAME=$(make_patch_name "${PATCHFILE}") -echo "Building xSplice patch: ${PATCHNAME}" +echo "Building LivePatch patch: ${PATCHNAME}" echo echo "Xen directory: ${SRCDIR}" echo "Patch file: ${PATCHFILE}" @@ -282,5 +282,5 @@ if [ "${SKIP}" != "diff" ]; then cd "${OUTPUT}" || die create_patch - echo "${PATCHNAME}.xsplice created successfully" + echo "${PATCHNAME}.livepatch created successfully" fi diff --git a/xsplice-gcc b/livepatch-gcc similarity index 80% rename from xsplice-gcc rename to livepatch-gcc index 8b63e50..634157a 100755 --- a/xsplice-gcc +++ b/livepatch-gcc @@ -1,6 +1,6 @@ #!/bin/bash # -# xsplice build script +# livepatch build script # # Copyright (C) 2015 Ross Lagerwall # @@ -39,9 +39,9 @@ if [[ "$TOOLCHAINCMD" = "gcc" ]] ; then ;; *.o) path="$(pwd)/$(dirname $obj)" - dir="${path#$XSPLICE_BUILD_DIR}" - if [ -n "$XSPLICE_CAPTURE_DIR" -a -d "$XSPLICE_CAPTURE_DIR" ]; then - echo "$dir/$obj" >> "${XSPLICE_CAPTURE_DIR}/changed_objs" + dir="${path#$LIVEPATCH_BUILD_DIR}" + if [ -n "$LIVEPATCH_CAPTURE_DIR" -a -d "$LIVEPATCH_CAPTURE_DIR" ]; then + echo "$dir/$obj" >> "${LIVEPATCH_CAPTURE_DIR}/changed_objs" keep=yes fi break @@ -59,8 +59,8 @@ fi ret="$?" if [[ "$keep" = "yes" ]] ; then - mkdir -p "$(dirname $XSPLICE_CAPTURE_DIR/$dir/$obj)" - cp "$obj" "$XSPLICE_CAPTURE_DIR/$dir/$obj" + mkdir -p "$(dirname $LIVEPATCH_CAPTURE_DIR/$dir/$obj)" + cp "$obj" "$LIVEPATCH_CAPTURE_DIR/$dir/$obj" fi exit "$ret" diff --git a/prelink.c b/prelink.c index 6b929c3..2039e5b 100644 --- a/prelink.c +++ b/prelink.c @@ -40,7 +40,7 @@ char *childobj; enum loglevel loglevel = NORMAL; /* Resolve symbols using xen-syms */ -void xsplice_resolve_symbols(struct kpatch_elf *kelf, +void livepatch_resolve_symbols(struct kpatch_elf *kelf, struct lookup_table *table) { struct symbol *sym; @@ -157,7 +157,7 @@ int main(int argc, char *argv[]) lookup = lookup_open(arguments.args[2]); log_debug("Resolve symbols\n"); - xsplice_resolve_symbols(kelf, lookup); + livepatch_resolve_symbols(kelf, lookup); /* * Update rela section headers and rebuild the rela section data