Skip to content

Commit

Permalink
tools/deferred_work/3-4-5-deferred: Protect pid_task() with 'rcu_read…
Browse files Browse the repository at this point in the history
…_lock()'

'get_proc()' in 'deferred.c' is calling 'pid_task()' without holding the
rcu read lock.  This result in below lockdep warning:

    =============================
    WARNING: suspicious RCU usage
    4.19.0+ #4 Tainted: G           O
    -----------------------------
    kernel/pid.c:330 suspicious rcu_dereference_check() usage!

This commit fixes it.

Signed-off-by: SeongJae Park <[email protected]>
  • Loading branch information
sjp38 authored and dbaluta committed Jan 12, 2023
1 parent 31eaa1c commit f28449d
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ static struct mon_proc *get_proc(pid_t pid)
struct task_struct *task;
struct mon_proc *p;

rcu_read_lock();
task = pid_task(find_vpid(pid), PIDTYPE_PID);
rcu_read_unlock();
if (!task)
return ERR_PTR(-ESRCH);

Expand Down

0 comments on commit f28449d

Please sign in to comment.