Messages in this thread | | | Subject | Re: [PATCH] kretprobe: avoid re-registration of the same kretprobe earlier | From | "Wangshaobo (bobo)" <> | Date | Fri, 29 Jan 2021 11:37:39 +0800 |
| |
Dear Masami and Steve,
I have sent v2 but still have confusions:
> OK, I think it is simpler to check the rp->kp.addr && rp->kp.symbol_name > because it is not allowed (it can lead inconsistent setting). > > How about this code? Is this work for you? > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 41fdbb7953c6..73500be564be 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -2103,6 +2103,14 @@ int register_kretprobe(struct kretprobe *rp) > int i; > void *addr; > > + /* It is not allowed to specify addr and symbol_name at the same time */ > + if (rp->kp.addr && rp->kp.symbol_name) > + return -EINVAL; > +
above sentence can be removed because of kprobe_on_func_entry() do it:
kprobe_on_func_entry()
-=>_kprobe_addr() {if (rp->kp.addr && rp->kp.symbol_name) ...}
> + /* If only rp->kp.addr is specified, check reregistering kprobes */ > + if (rp->kp.addr && check_kprobe_rereg(&rp->kp)) > + return -EINVAL;
for arch arm64,x86_64, above sentence can be moved behind following sentence.
kprobe_on_func_entry()
-=>arch_kprobe_on_func_entry() {kp->offset can not be 0 ; ...}
So if offset of kprobe if not 0, do not waste time to excute above sentence.
But for Arch ppc64, I still not figure out better one solution.
Thank you
-- Wang ShaoBo
> if (!kprobe_on_func_entry(rp->kp.addr, rp->kp.symbol_name, rp->kp.offset)) > return -EINVAL; > > > Thank you, >
| |