kmod/core: remove unused old_func_name field

Not needed, we can always add it again later if needed (for sanity
checks, maybe)
This commit is contained in:
Josh Poimboeuf 2014-03-13 15:08:08 -05:00
parent 15e1b83cfe
commit e7dde72ed9
2 changed files with 16 additions and 19 deletions

View File

@ -54,7 +54,7 @@ static int kpatch_num_funcs(struct kpatch_func *f)
{ {
int i; int i;
for (i = 0; f[i].old_func_name; i++) for (i = 0; f[i].old_func_addr; i++)
; ;
return i; return i;
@ -74,7 +74,7 @@ void kpatch_backtrace_address_verify(void *data, unsigned long address,
if (args->ret) if (args->ret)
return; return;
for (f = args->funcs; f->old_func_name; f++) for (f = args->funcs; f->old_func_addr; f++)
if (address >= f->old_func_addr && if (address >= f->old_func_addr &&
address < f->old_func_addr_end) address < f->old_func_addr_end)
goto unsafe; goto unsafe;
@ -82,8 +82,8 @@ void kpatch_backtrace_address_verify(void *data, unsigned long address,
return; return;
unsafe: unsafe:
printk("kpatch: activeness safety check failed for '%s()'\n", printk("kpatch: activeness safety check failed for function at address "
f->old_func_name); "'%lx()'\n", f->old_func_addr);
args->ret = -EBUSY; args->ret = -EBUSY;
} }
@ -200,7 +200,7 @@ int kpatch_register(struct module *mod, void *kpatch_patches,
struct kpatch_patch *patches; struct kpatch_patch *patches;
struct kpatch_func *funcs, *f; struct kpatch_func *funcs, *f;
pr_err("loading patch module \"%s\"", mod->name); pr_err("loading patch module \"%s\"\n", mod->name);
num_patches = (kpatch_patches_end - kpatch_patches) / sizeof(*patches); num_patches = (kpatch_patches_end - kpatch_patches) / sizeof(*patches);
patches = kpatch_patches; patches = kpatch_patches;
@ -217,10 +217,9 @@ int kpatch_register(struct module *mod, void *kpatch_patches,
funcs[i].old_func_addr_end = patches[i].orig_end; funcs[i].old_func_addr_end = patches[i].orig_end;
funcs[i].new_func_addr = patches[i].new; funcs[i].new_func_addr = patches[i].new;
funcs[i].mod = mod; funcs[i].mod = mod;
funcs[i].old_func_name = "TODO";
/* Do any needed incremental patching. */ /* Do any needed incremental patching. */
for (f = kpatch_funcs; f->old_func_name; f++) { for (f = kpatch_funcs; f->old_func_addr; f++) {
if (funcs[i].old_func_addr == f->old_func_addr) { if (funcs[i].old_func_addr == f->old_func_addr) {
funcs[i].old_func_addr = f->new_func_addr; funcs[i].old_func_addr = f->new_func_addr;
ref_module(funcs[i].mod, f->mod); ref_module(funcs[i].mod, f->mod);
@ -230,10 +229,9 @@ int kpatch_register(struct module *mod, void *kpatch_patches,
ret = ftrace_set_filter_ip(&kpatch_ftrace_ops, patches[i].orig, ret = ftrace_set_filter_ip(&kpatch_ftrace_ops, patches[i].orig,
0, 0); 0, 0);
if (ret) { if (ret) {
printk("kpatch: can't set ftrace filter at " printk("kpatch: can't set ftrace filter at address "
"%lx '%s' (%d)\n", "0x%lx (%d)\n",
funcs[i].old_func_addr, funcs[i].old_func_name, funcs[i].old_func_addr, ret);
ret);
goto out; goto out;
} }
} }
@ -295,7 +293,7 @@ static int kpatch_remove_patch(void *data)
memset(&kpatch_funcs[i], 0, memset(&kpatch_funcs[i], 0,
num_remove_funcs * sizeof(struct kpatch_func)); num_remove_funcs * sizeof(struct kpatch_func));
for ( ;kpatch_funcs[i + num_remove_funcs].old_func_name; i++) for ( ;kpatch_funcs[i + num_remove_funcs].old_func_addr; i++)
memcpy(&kpatch_funcs[i], &kpatch_funcs[i + num_remove_funcs], memcpy(&kpatch_funcs[i], &kpatch_funcs[i + num_remove_funcs],
sizeof(struct kpatch_func)); sizeof(struct kpatch_func));
@ -317,7 +315,7 @@ int kpatch_unregister(struct module *mod)
goto out; goto out;
} }
for (f = kpatch_funcs, i = 0; f->old_func_name; f++) for (f = kpatch_funcs, i = 0; f->old_func_addr; f++)
if (f->mod == mod) if (f->mod == mod)
memcpy(&funcs[i++], f, sizeof(*funcs)); memcpy(&funcs[i++], f, sizeof(*funcs));
memset(&funcs[i], 0, sizeof(*funcs)); memset(&funcs[i], 0, sizeof(*funcs));
@ -334,13 +332,13 @@ int kpatch_unregister(struct module *mod)
} }
} }
for (f = funcs; f->old_func_name; f++) { for (f = funcs; f->old_func_addr; f++) {
ret = ftrace_set_filter_ip(&kpatch_ftrace_ops, f->old_func_addr, ret = ftrace_set_filter_ip(&kpatch_ftrace_ops, f->old_func_addr,
1, 0); 1, 0);
if (ret) { if (ret) {
printk("kpatch: can't remove ftrace filter at " printk("kpatch: can't remove ftrace filter at address "
"%lx '%s' (%d)\n", "0x%lx (%d)\n",
f->old_func_addr, f->old_func_name, ret); f->old_func_addr, ret);
goto out; goto out;
} }
} }

View File

@ -2,7 +2,7 @@
* kpatch.h * kpatch.h
* *
* Copyright (C) 2014 Seth Jennings <sjenning@redhat.com> * Copyright (C) 2014 Seth Jennings <sjenning@redhat.com>
* Copyright (C) 2013 Josh Poimboeuf <jpoimboe@redhat.com> * Copyright (C) 2013-2014 Josh Poimboeuf <jpoimboe@redhat.com>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -28,7 +28,6 @@
struct kpatch_func { struct kpatch_func {
unsigned long old_func_addr; unsigned long old_func_addr;
unsigned long new_func_addr; unsigned long new_func_addr;
char *old_func_name;
unsigned long old_func_addr_end; unsigned long old_func_addr_end;
struct module *mod; struct module *mod;
}; };