--- a/include/linux/kprobes.h +++ b/include/linux/kprobes.h @@ -154,6 +154,8 @@ struct kretprobe { struct kretprobe_holder *rph; }; +#define KRETPROBE_MAX_DATA_SIZE 4096 + struct kretprobe_instance { union { struct freelist_node freelist; --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -2006,6 +2006,9 @@ int register_kretprobe(struct kretprobe } } + if (rp->data_size > KRETPROBE_MAX_DATA_SIZE) + return -E2BIG; + rp->kp.pre_handler = pre_handler_kretprobe; rp->kp.post_handler = NULL;