Skip to content

Commit b302d5a

Browse files
oleg-nesterovPeter Zijlstra
authored andcommitted
uprobes: don't abuse get_utask() in pre_ssout() and prepare_uretprobe()
handle_swbp() calls get_utask() before prepare_uretprobe() or pre_ssout() can be called, they can simply use current->utask which can't be NULL. Signed-off-by: Oleg Nesterov <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d3fe6f0 commit b302d5a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

kernel/events/uprobes.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,18 +1905,14 @@ static void cleanup_return_instances(struct uprobe_task *utask, bool chained,
19051905

19061906
static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs)
19071907
{
1908-
struct return_instance *ri;
1909-
struct uprobe_task *utask;
1908+
struct uprobe_task *utask = current->utask;
19101909
unsigned long orig_ret_vaddr, trampoline_vaddr;
1910+
struct return_instance *ri;
19111911
bool chained;
19121912

19131913
if (!get_xol_area())
19141914
return;
19151915

1916-
utask = get_utask();
1917-
if (!utask)
1918-
return;
1919-
19201916
if (utask->depth >= MAX_URETPROBE_DEPTH) {
19211917
printk_ratelimited(KERN_INFO "uprobe: omit uretprobe due to"
19221918
" nestedness limit pid/tgid=%d/%d\n",
@@ -1977,14 +1973,10 @@ static void prepare_uretprobe(struct uprobe *uprobe, struct pt_regs *regs)
19771973
static int
19781974
pre_ssout(struct uprobe *uprobe, struct pt_regs *regs, unsigned long bp_vaddr)
19791975
{
1980-
struct uprobe_task *utask;
1976+
struct uprobe_task *utask = current->utask;
19811977
unsigned long xol_vaddr;
19821978
int err;
19831979

1984-
utask = get_utask();
1985-
if (!utask)
1986-
return -ENOMEM;
1987-
19881980
if (!try_get_uprobe(uprobe))
19891981
return -EINVAL;
19901982

0 commit comments

Comments
 (0)