From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
oleg@redhat.com, tglx@linutronix.de,
linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com,
linux-security-module@vger.kernel.org
Subject: Re: [PATCH] Update comment on find_task_by_pid_ns
Date: Wed, 10 Feb 2010 10:30:33 -0600 [thread overview]
Message-ID: <20100210163033.GA12251@us.ibm.com> (raw)
In-Reply-To: <20100209140818.43bb9770.akpm@linux-foundation.org>
Quoting Andrew Morton (akpm@linux-foundation.org):
> On Tue, 9 Feb 2010 06:42:45 +0900
> Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
>
> > OK. I updated description.
> >
> > As of 2.6.32 , below users are missing rcu_read_lock().
> >
> > Users missing rcu_read_lock() when calling find_task_by_vpid():
> >
> > SYSCALL_DEFINE3(ioprio_set) in fs/ioprio.c
> > SYSCALL_DEFINE2(ioprio_get) in fs/ioprio.c
> > cap_get_target_pid() in kernel/capability.c
>
> Actually, cap_get_target_pid() uses rcu_read_lock() and doesn't take
> tasklist_lock.
Hmm - is that in -mm? In my copy here it takes read_lock(&tasklist_lock)
And I'll admit I'm a bit confused as to the current state of things:
do I understand correctly that we now need to take both the tasklist_lock
and rcu_read_lock? (Presumably only for read_lock()?)
> > audit_prepare_user_tty() in kernel/audit.c
> > audit_receive_msg() in kernel/audit.c
> > check_clock() in kernel/posix-cpu-timers.c
> > posix_cpu_timer_create() in kernel/posix-cpu-timers.c
> > SYSCALL_DEFINE3(setpriority) in kernel/sys.c
> > SYSCALL_DEFINE2(getpriority) in kernel/sys.c
> > SYSCALL_DEFINE2(setpgid) in kernel/sys.c
> > SYSCALL_DEFINE1(sched_getscheduler) in kernel/sched.c
> > SYSCALL_DEFINE2(sched_getparam) in kernel/sched.c
> > sched_setaffinity() in kernel/sched.c
> > sched_getaffinity() in kernel/sched.c
> > SYSCALL_DEFINE2(sched_rr_get_interval) in kernel/sched.c
> > tomoyo_is_select_one() in security/tomoyo/common.c
> > tomoyo_read_pid() in security/tomoyo/common.c
> > SYSCALL_DEFINE6(move_pages) in mm/migrate.c
> > SYSCALL_DEFINE4(migrate_pages) in mm/mempolicy.c
> > find_process_by_pid() in arch/mips/kernel/mips-mt-fpaff.c
> > pfm_get_task() in arch/ia64/kernel/perfmon.c
> > cxn_pin_by_pid() in arch/frv/mm/mmu-context.c
> >
> > Users missing rcu_read_lock() when calling find_task_by_pid_ns():
> >
> > rest_init() in init/main.c
> > getthread() in kernel/kgdb.c
> > mconsole_stack() in arch/um/drivers/mconsole_kern.c
> >
> > What should we do? Adding rcu_read_lock()/rcu_read_unlock() to each
> > callers? Or adding rcu_read_lock()/rcu_read_unlock() inside
> > find_task_by_pid_ns()?
>
> Putting rcu_read_lock() in the callee isn't a complete solution.
> Because the function would still be returning a task_struct* without
> any locking held and without taking a reference against it. So that
> pointer is useless to the caller!
>
> We could add a new function which looks up the task and then takes a
> reference on it, insde suitable locks. The caller would then use the
> task_struct and then remember to call put_task_struct() to unpin it.
> This prevents the task_struct from getting freed while it's being
> manipulated, but it doesn't prevent fields within it from being altered
> - that's up to the caller to sort out.
>
> One fix is to go through all those callsites and add the rcu_read_lock.
> That kinda sucks. Perhaps writing the new function which returns a
> pinned task_struct is better?
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-02-10 16:30 UTC|newest]
Thread overview: 72+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-10 0:52 [patch 0/9] Fix various __task_cred related invalid RCU assumptions Thomas Gleixner
2009-12-10 0:52 ` [patch 1/9] sys: Fix missing rcu protection for __task_cred() access Thomas Gleixner
2009-12-10 1:25 ` Paul E. McKenney
2009-12-10 2:29 ` Tetsuo Handa
2009-12-10 2:43 ` Paul E. McKenney
2009-12-10 14:29 ` Oleg Nesterov
2009-12-10 14:44 ` Thomas Gleixner
2009-12-11 13:45 ` David Howells
2009-12-11 13:52 ` Thomas Gleixner
2009-12-10 14:20 ` Oleg Nesterov
2009-12-10 14:38 ` Thomas Gleixner
2009-12-10 15:08 ` [patch 1/9] sys: Fix missing rcu protection for __task_cred()access Tetsuo Handa
2009-12-10 21:17 ` Thomas Gleixner
2009-12-11 3:25 ` Tetsuo Handa
2010-02-08 12:30 ` [PATCH] Update comment on find_task_by_pid_ns Tetsuo Handa
2010-02-08 13:21 ` Oleg Nesterov
2010-02-08 17:07 ` Thomas Gleixner
2010-02-08 17:16 ` Oleg Nesterov
2010-02-08 21:42 ` Tetsuo Handa
2010-02-09 22:08 ` Andrew Morton
2010-02-10 16:30 ` Serge E. Hallyn [this message]
2010-02-10 17:57 ` Andrew Morton
2010-02-10 18:39 ` Thomas Gleixner
2010-02-10 20:18 ` Serge E. Hallyn
2010-02-10 20:30 ` Paul E. McKenney
2010-02-11 1:21 ` Tetsuo Handa
2010-02-11 12:04 ` [PATCH] sys: Fix missing rcu protection for sys_getpriority Tetsuo Handa
2010-02-12 14:22 ` Serge E. Hallyn
2009-12-10 22:09 ` [tip:core/urgent] sys: Fix missing rcu protection for __task_cred() access tip-bot for Thomas Gleixner
2009-12-10 0:52 ` [patch 2/9] fs: Add missing rcu protection for __task_cred() in sys_ioprio_get Thomas Gleixner
2009-12-10 0:53 ` [patch 3/9] proc: Add missing rcu protection for __task_cred() in task_sig() Thomas Gleixner
2009-12-10 0:53 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks Thomas Gleixner
2009-12-10 1:57 ` KOSAKI Motohiro
2009-12-10 0:53 ` [patch 5/9] security: Use get_task_cred() in keyctl_session_to_parent() Thomas Gleixner
2009-12-10 2:45 ` Paul E. McKenney
2009-12-10 0:53 ` [patch 6/9] signal: Fix racy access to __task_cred in kill_pid_info_as_uid() Thomas Gleixner
2009-12-10 15:11 ` Oleg Nesterov
2009-12-10 22:09 ` [tip:core/urgent] " tip-bot for Thomas Gleixner
2009-12-10 0:53 ` [patch 7/9] signals: Fix more rcu assumptions Thomas Gleixner
2009-12-10 14:34 ` Oleg Nesterov
2009-12-10 14:45 ` Thomas Gleixner
2009-12-11 13:59 ` David Howells
2009-12-10 22:09 ` [tip:core/urgent] " tip-bot for Thomas Gleixner
2009-12-10 0:53 ` [patch 8/9] Documentation: Fix invalid " Thomas Gleixner
2009-12-10 23:55 ` Vegard Nossum
2009-12-11 21:28 ` Arnd Bergmann
2009-12-11 22:01 ` Paul E. McKenney
2009-12-10 0:53 ` [patch 9/9] security: Fix invalid rcu assumptions in comments Thomas Gleixner
2009-12-10 2:28 ` [patch 0/9] Fix various __task_cred related invalid RCU assumptions Paul E. McKenney
2009-12-10 3:15 ` Linus Torvalds
2009-12-10 5:13 ` Peter Zijlstra
2009-12-10 5:34 ` Paul E. McKenney
2009-12-13 18:56 ` Peter Zijlstra
2009-12-14 1:53 ` Paul E. McKenney
2009-12-14 10:17 ` Peter Zijlstra
2009-12-14 14:16 ` Paul E. McKenney
2009-12-14 14:30 ` Peter Zijlstra
2009-12-15 1:23 ` Paul E. McKenney
2009-12-11 13:39 ` David Howells
2009-12-11 16:35 ` Paul E. McKenney
2009-12-11 13:41 ` [patch 1/9] sys: Fix missing rcu protection for __task_cred() access David Howells
2009-12-11 13:46 ` [patch 2/9] fs: Add missing rcu protection for __task_cred() in sys_ioprio_get David Howells
2009-12-11 13:46 ` [patch 3/9] proc: Add missing rcu protection for __task_cred() in task_sig() David Howells
2009-12-11 13:49 ` [patch 4/9] oom: Add missing rcu protection of __task_cred() in dump_tasks David Howells
2009-12-11 13:52 ` Thomas Gleixner
2009-12-11 13:52 ` [patch 5/9] security: Use get_task_cred() in keyctl_session_to_parent() David Howells
2009-12-11 13:53 ` [patch 6/9] signal: Fix racy access to __task_cred in kill_pid_info_as_uid() David Howells
2009-12-11 14:00 ` [patch 8/9] Documentation: Fix invalid rcu assumptions David Howells
2009-12-11 16:07 ` Linus Torvalds
2009-12-11 16:37 ` Paul E. McKenney
2009-12-11 18:08 ` Thomas Gleixner
2009-12-11 14:01 ` [patch 9/9] security: Fix invalid rcu assumptions in comments David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100210163033.GA12251@us.ibm.com \
--to=serue@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).