From 704feda8233d845d238528d9ae317808af8146bb Mon Sep 17 00:00:00 2001 From: lzwycc Date: Wed, 16 Nov 2022 17:30:19 +0800 Subject: [PATCH] upatch: add functions with __LINE__ macro upatch-diff add functions which handle __LINE__ macro kmod change warn in hacking assembler without UPATCH_CMD --- upatch/kmod/compiler.c | 19 ++++++++++--------- upatch/upatch-build/src/upatch/compiler.rs | 2 +- upatch/upatch-diff/elf-compare.c | 4 +++- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/upatch/kmod/compiler.c b/upatch/kmod/compiler.c index 7453c134..b731de50 100755 --- a/upatch/kmod/compiler.c +++ b/upatch/kmod/compiler.c @@ -459,7 +459,7 @@ static int rewrite_object_path(char __user **argv, char __user **envp) ret = obtain_parameter_addr(envp, ASSEMBLER_DIR_ENV, &dir_addr, NULL); if (ret || dir_addr == 0) { - pr_err("no valid %s found \n", ASSEMBLER_DIR_ENV); + pr_warn("no valid %s found %s \n", ASSEMBLER_DIR_ENV, object_path);\ ret = -EINVAL; goto out; } @@ -591,7 +591,7 @@ static int uprobe_assembler_handler(struct uprobe_consumer *self, struct pt_regs ret = rewrite_object_path(argv, envp); if (ret) { - pr_err("rewrite object path failed - %d \n", ret); + pr_warn("rewrite object path failed - %d \n", ret); run_exit_syscall(regs, ret); } @@ -645,6 +645,7 @@ static int __unregister_uprobe(unsigned int cmd, struct elf_path *ep, struct upr } inode = path.dentry->d_inode; + pr_info("unregister uprobe for %s \n", ep->name); uprobe_unregister(inode, ep->entry_offset, uc); if (cmd == UPATCH_UNREGISTER_COMPILER || cmd == UPATCH_UNREGISTER_ASSEMBLER) { delete_elf_path(cmd, ep->name); @@ -711,13 +712,13 @@ out: return ret; } -static int elf_check(const char *buf, char *elf_path, loff_t *entry_offset) +static int elf_check(char *elf_path, loff_t *entry_offset) { struct file *file; int ret; char *p; - file = filp_open(buf, O_RDONLY, 0); + file = filp_open(elf_path, O_RDONLY, 0); if (IS_ERR(file)) { ret = PTR_ERR(file); pr_err("open elf failed - %d \n", ret); @@ -741,13 +742,13 @@ out: return ret; } -static int __register_uprobe(const char *buf, unsigned int cmd, struct elf_path *ep, struct uprobe_consumer *uc) +static int __register_uprobe(unsigned int cmd, struct elf_path *ep, struct uprobe_consumer *uc) { int ret; struct path path; struct inode *inode; - ret = elf_check(buf, ep->name, &ep->entry_offset); + ret = elf_check(ep->name, &ep->entry_offset); if (ret) goto out; @@ -758,7 +759,7 @@ static int __register_uprobe(const char *buf, unsigned int cmd, struct elf_path } inode = path.dentry->d_inode; - pr_info("register uprobe for %s \n", buf); + pr_info("register uprobe for %s \n", ep->name); ret = uprobe_register(inode, ep->entry_offset, uc); if (ret) { pr_err("uprobe register failed - %d \n", ret); @@ -802,7 +803,7 @@ int handle_compiler_cmd(unsigned long user_addr, unsigned int cmd) ep->count = 1; ep->entry_offset = 0; list_add(&ep->list, &compiler_paths_list); - ret = __register_uprobe(path, cmd, ep, &uprobe_compiler_consumer); + ret = __register_uprobe(cmd, ep, &uprobe_compiler_consumer); } else { ep->count++; } @@ -826,7 +827,7 @@ int handle_compiler_cmd(unsigned long user_addr, unsigned int cmd) ep->count = 1; ep->entry_offset = 0; list_add(&ep->list, &assembler_paths_list); - ret = __register_uprobe(path, cmd, ep, &uprobe_assembler_consumer); + ret = __register_uprobe(cmd, ep, &uprobe_assembler_consumer); } else { ep->count++; } diff --git a/upatch/upatch-build/src/upatch/compiler.rs b/upatch/upatch-build/src/upatch/compiler.rs index 1a8b3cef..d7dce70b 100644 --- a/upatch/upatch-build/src/upatch/compiler.rs +++ b/upatch/upatch-build/src/upatch/compiler.rs @@ -64,7 +64,7 @@ impl Compiler { let tmp_dir = cache_dir.to_string() + "/test"; fs::create_dir(&tmp_dir).unwrap(); let test = tmp_dir.clone() + "/test.c"; - let test_obj = tmp_dir.clone() + "/test.0"; + let test_obj = tmp_dir.clone() + "/test.o"; let mut test_file = OpenOptions::new().create(true).read(true).write(true).open(&test)?; test_file.write_all(b"void main(void) {}")?; diff --git a/upatch/upatch-diff/elf-compare.c b/upatch/upatch-diff/elf-compare.c index ddcb9819..215674ae 100644 --- a/upatch/upatch-diff/elf-compare.c +++ b/upatch/upatch-diff/elf-compare.c @@ -156,7 +156,9 @@ bool upatch_handle_redis_line(const char *symname) { if (!strncmp(symname, "_serverPanic", 12) || !strncmp(symname, "_serverAssert", 13) || - !strncmp(symname, "_serverAssertWithInfo", 21)) + !strncmp(symname, "_serverAssertWithInfo", 21) || + !strncmp(symname, "rdbReportError", 14) || + !strncmp(symname, "RedisModule__Assert", 19)) return true; return false; } -- Gitee