From: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
To: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] rcu_read_lock/unlock protect find_task_by_vpid call
Date: Sat, 30 Oct 2010 12:32:34 +0300 [thread overview]
Message-ID: <20101030093234.GK3932@swordfish.minsk.epam.com> (raw)
In-Reply-To: <20101029201648.GK2367@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 3659 bytes --]
On (10/29/10 13:16), Paul E. McKenney wrote:
> On Fri, Oct 29, 2010 at 03:55:50PM +0300, Sergey Senozhatsky wrote:
> > Commit 4221a9918e38b7494cee341dda7b7b4bb8c04bde "Add RCU check for
> > find_task_by_vpid()" introduced rcu_lockdep_assert to find_task_by_pid_ns.
> > Assertion failed in sys_ioprio_get. The patch is fixing assertion
> > failure in ioprio_set as well.
> >
> > ===================================================
> > [ INFO: suspicious rcu_dereference_check() usage. ]
> > ---------------------------------------------------
> > kernel/pid.c:419 invoked rcu_dereference_check() without protection!
> >
> > rcu_scheduler_active = 1, debug_locks = 0
> > 1 lock held by iotop/4254:
> > #0: (tasklist_lock){.?.?..}, at: [<ffffffff811104b4>] sys_ioprio_get+0x22/0x2da
> >
> > stack backtrace:
> > Pid: 4254, comm: iotop Not tainted
> > Call Trace:
> > [<ffffffff810656f2>] lockdep_rcu_dereference+0xaa/0xb2
> > [<ffffffff81053c67>] find_task_by_pid_ns+0x4f/0x68
> > [<ffffffff81053c9d>] find_task_by_vpid+0x1d/0x1f
> > [<ffffffff811104e2>] sys_ioprio_get+0x50/0x2da
> > [<ffffffff81002182>] system_call_fastpath+0x16/0x1b
> >
> >
> > Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> >
> > ---
> >
> > diff --git a/fs/ioprio.c b/fs/ioprio.c
> > index 748cfb9..666343d 100644
> > --- a/fs/ioprio.c
> > +++ b/fs/ioprio.c
> > @@ -113,8 +113,11 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
>
> Interesting...
>
> The task-list lock is read-held at this point, which should mean that
> the PID mapping cannot change. The lockdep_tasklist_lock_is_held()
> function does lockdep_is_held(&tasklist_lock), which must therefore
> only be checking for write-holding the lock. The fix would be to
> make lockdep_tasklist_lock_is_held() check for either read-holding or
> write-holding tasklist lock.
>
> Or is there some subtle reason that read-holding the tasklist lock is
> not sufficient?
>
Hello,
On the kernel/pid.c side we have the requirement that
find_task_by_vpid -> find_task_by_pid_ns
should be called with rcu_read_lock.
/*
* Must be called under rcu_read_lock().
*/
struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
{
rcu_lockdep_assert(rcu_read_lock_held());
return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
}
Should it be changed to (let's say)
struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
{
- rcu_lockdep_assert(rcu_read_lock_held());
+ rcu_lockdep_assert(rcu_read_lock_held() || lockdep_tasklist_lock_is_held());
return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
}
Sergey
> Thanx, Paul
>
> > case IOPRIO_WHO_PROCESS:
> > if (!who)
> > p = current;
> > - else
> > + else {
> > + rcu_read_lock();
> > p = find_task_by_vpid(who);
> > + rcu_read_unlock();
> > + }
> > if (p)
> > ret = set_task_ioprio(p, ioprio);
> > break;
> > @@ -202,8 +205,11 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
> > case IOPRIO_WHO_PROCESS:
> > if (!who)
> > p = current;
> > - else
> > + else {
> > + rcu_read_lock();
> > p = find_task_by_vpid(who);
> > + rcu_read_unlock();
> > + }
> > if (p)
> > ret = get_task_ioprio(p);
> > break;
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at http://www.tux.org/lkml/
>
[-- Attachment #2: Type: application/pgp-signature, Size: 316 bytes --]
next prev parent reply other threads:[~2010-10-30 9:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-29 12:55 Sergey Senozhatsky
2010-10-29 20:16 ` Paul E. McKenney
2010-10-30 9:32 ` Sergey Senozhatsky [this message]
2010-10-30 13:14 ` Tetsuo Handa
2010-10-30 21:02 ` Paul E. McKenney
2010-10-30 23:33 ` Tetsuo Handa
2010-11-07 19:43 ` Paul E. McKenney
2010-11-07 22:04 ` Tetsuo Handa
2010-11-08 3:01 ` Paul E. McKenney
2010-11-08 10:28 ` Sergey Senozhatsky
2010-11-08 13:19 ` Paul E. McKenney
2010-11-08 16:01 ` Davidlohr Bueso
2010-11-08 16:18 ` Sergey Senozhatsky
2010-11-08 16:37 ` Davidlohr Bueso
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=20101030093234.GK3932@swordfish.minsk.epam.com \
--to=sergey.senozhatsky@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=paulmck@linux.vnet.ibm.com \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®