Re: [PATCH] sys_getppid: add missing rcu_dereference
From: Kees Cook
Date: Wed Dec 07 2011 - 18:03:26 EST
On Tue, Dec 6, 2011 at 6:45 PM, Mandeep Singh Baines <msb@xxxxxxxxxxxx> wrote:
> In order to safely dereference current->real_parent inside an
> rcu_read_lock, we need an rcu_dereference.
>
> Signed-off-by: Mandeep Singh Baines <msb@xxxxxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Pavel Emelyanov <xemul@xxxxxxxxxx>
> Cc: Oleg Nesterov <oleg@xxxxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Kees Cook <keescook@xxxxxxxxxxxx>
> ---
> kernel/timer.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/kernel/timer.c b/kernel/timer.c
> index dbaa624..9c3c62b 100644
> --- a/kernel/timer.c
> +++ b/kernel/timer.c
> @@ -1368,7 +1368,7 @@ SYSCALL_DEFINE0(getppid)
> int pid;
>
> rcu_read_lock();
> - pid = task_tgid_vnr(current->real_parent);
> + pid = task_tgid_vnr(rcu_dereference(current->real_parent));
> rcu_read_unlock();
>
> return pid;
Should parent and real_parent also be marked in sched.h with __rcu so
sparse can find other missing rcu_dereference()s? And if not, why?
(tasklist lock?)
I think I see at least are few other users (security/apparmor/audit.c,
security/tomoyo/common.h, kernel/sched.c) that need rcu_dereference()
when accessing real_parent, there are probably more.
-Kees
--
Kees Cook
ChromeOS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/