From 12fb573fca40c16cc5c393f5e41d5a07554bdcac Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Sat, 19 Jan 2013 13:44:13 -0600 Subject: [PATCH] add address end to fix activeness safety check --- kmod/base.c | 1 + kmod/kpatch.h | 1 + kpatch-create | 8 ++++---- kpatch-diff-gen/kpatch-diff-gen.c | 2 ++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kmod/base.c b/kmod/base.c index 4ba9c2d..f630e88 100644 --- a/kmod/base.c +++ b/kmod/base.c @@ -205,6 +205,7 @@ int kpatch_register(struct module *mod, void *kpatch_relas, for (i = 0; i < num_patches; i++) { funcs[i].old_func_addr = patches[i].orig; + funcs[i].old_func_addr_end = patches[i].orig_end; funcs[i].new_func_addr = patches[i].new; funcs[i].mod = mod; funcs[i].old_func_name = "TODO"; diff --git a/kmod/kpatch.h b/kmod/kpatch.h index 08b89eb..ecef188 100644 --- a/kmod/kpatch.h +++ b/kmod/kpatch.h @@ -19,6 +19,7 @@ struct kpatch_rela { struct kpatch_patch { unsigned long new; unsigned long orig; /* TODO eventually add name of symbol so we can verify it with kallsyms */ + unsigned long orig_end; /* TODO: rename this struct to kpatch_func, embed it within original kpatch_func, and rename original kpatch_func to kpatch_func_reg? */ }; void kpatch_trampoline(unsigned long ip, unsigned long parent_ip, diff --git a/kpatch-create b/kpatch-create index 993fad9..ccc7d85 100755 --- a/kpatch-create +++ b/kpatch-create @@ -111,11 +111,11 @@ scriptecho "diffing binaries" find . -type f -name '*.o.kpatch_orig' | while read file; do origfile="${file#./}" newfile="${origfile%.kpatch_orig}" - [ ! -f "$newfile" ] && die "can't find \"$newfile\"" + [ ! -f "$newfile" ] && die "can't find $newfile" num="`readelf -s \"$file\" |awk '{print $4}' |grep -c FILE`" - [ "$num" = 0 ] && die "unsupported change in (assembly?) file \"$file\"" - [ "$num" -gt 1 ] && die "\"$newfile\" has too many FILE symbols" - scriptecho "object changed: \"$newfile\"" + [ "$num" = 0 ] && die "unsupported change in (assembly?) file $file" + [ "$num" -gt 1 ] && die "$newfile has too many FILE symbols" + scriptecho "object changed: $newfile" "$KPATCH_GEN" "$origfile" "$newfile" -v vmlinux.kpatch_orig -o "$newfile.kpatch_gen" done diff --git a/kpatch-diff-gen/kpatch-diff-gen.c b/kpatch-diff-gen/kpatch-diff-gen.c index 85f7863..0b7edb3 100644 --- a/kpatch-diff-gen/kpatch-diff-gen.c +++ b/kpatch-diff-gen/kpatch-diff-gen.c @@ -53,6 +53,7 @@ struct rela { struct kpatch_patch { unsigned long new; /* TODO don't rely on this being the first */ unsigned long orig; /* TODO eventually add name of symbol so we can verify it with kallsyms */ + unsigned long orig_end; }; @@ -1497,6 +1498,7 @@ int main(int argc, char *argv[]) continue; patch = sec->data->d_buf + (index * sec->sh.sh_entsize); patch->orig = sym->twino->twinv->sym.st_value; + patch->orig_end = patch->orig + sym->sym.st_size; patch->new = 0; index++; }