Skip to content

Commit 161671a

Browse files
committed
Merge tag 'probes-fixes-v6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull fprobe fix from Masami Hiramatsu: - allocate entry_data_size buffer for each rethook instance. This fixes a buffer overrun bug (which leads a kernel crash) when fprobe user uses its entry_data in the entry_handler. * tag 'probes-fixes-v6.8-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: fprobe: Fix to allocate entry_data_size buffer with rethook instances
2 parents 2f03fc3 + 6572786 commit 161671a

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

kernel/trace/fprobe.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,23 @@ static int fprobe_init_rethook(struct fprobe *fp, int num)
189189
{
190190
int size;
191191

192-
if (num <= 0)
193-
return -EINVAL;
194-
195192
if (!fp->exit_handler) {
196193
fp->rethook = NULL;
197194
return 0;
198195
}
199196

200197
/* Initialize rethook if needed */
201198
if (fp->nr_maxactive)
202-
size = fp->nr_maxactive;
199+
num = fp->nr_maxactive;
203200
else
204-
size = num * num_possible_cpus() * 2;
205-
if (size <= 0)
201+
num *= num_possible_cpus() * 2;
202+
if (num <= 0)
206203
return -EINVAL;
207204

205+
size = sizeof(struct fprobe_rethook_node) + fp->entry_data_size;
206+
208207
/* Initialize rethook */
209-
fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler,
210-
sizeof(struct fprobe_rethook_node), size);
208+
fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler, size, num);
211209
if (IS_ERR(fp->rethook))
212210
return PTR_ERR(fp->rethook);
213211

0 commit comments

Comments
 (0)