Re: [PATCH] kretprobe: check re-registration of the same kretprobe earlier

From: chengjian (D)
Date: Mon Mar 09 2020 - 03:38:46 EST



On 2020/3/7 17:54, Masami Hiramatsu wrote:
Ah, I see. I thought that you said ri is use-after-free, but in reality,
rp is use-after-free (use-after-init). OK.

And the problem here is destructive, it destroyed all the data of the
previously registered kretprobe,
it can lead to a system crash, memory leak, use-after-free and even some
other unexpected behavior.
Yes, so I think we should do

+ /* Return error if it's being re-registered */
+ ret = check_kprobe_rereg(&rp->kp);
+ if (WARN_ON(ret))
+ return ret;

This will give a warning message to the developer.

Thank you,

OK, I will add the WARN_ON in V2.

Thank you.


----Cheng Jian