Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754680Ab0KHQhc (ORCPT ); Mon, 8 Nov 2010 11:37:32 -0500 Received: from caiajhbdcaib.dreamhost.com ([208.97.132.81]:47095 "EHLO homiemail-a7.g.dreamhost.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752720Ab0KHQhb (ORCPT ); Mon, 8 Nov 2010 11:37:31 -0500 X-Greylist: delayed 2143 seconds by postgrey-1.27 at vger.kernel.org; Mon, 08 Nov 2010 11:37:31 EST Subject: Re: [PATCH] rcu_read_lock/unlock protect find_task_by_vpid call From: Davidlohr Bueso Reply-To: dave@gnu.org To: Sergey Senozhatsky Cc: "Paul E. McKenney" , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , Ingo Molnar In-Reply-To: <20101108161801.GD3971@swordfish.minsk.epam.com> References: <20101029125550.GA3932@swordfish.minsk.epam.com> <1289232095.2206.5.camel@cowboy> <20101108161801.GD3971@swordfish.minsk.epam.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 08 Nov 2010 13:37:20 -0300 Message-ID: <1289234240.2206.6.camel@cowboy> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2701 Lines: 76 On Mon, 2010-11-08 at 18:18 +0200, Sergey Senozhatsky wrote: > On (11/08/10 13:01), Davidlohr Bueso wrote: > > On Fri, 2010-10-29 at 15:55 +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: [] sys_ioprio_get+0x22/0x2da > > > > > > stack backtrace: > > > Pid: 4254, comm: iotop Not tainted > > > Call Trace: > > > [] lockdep_rcu_dereference+0xaa/0xb2 > > > [] find_task_by_pid_ns+0x4f/0x68 > > > [] find_task_by_vpid+0x1d/0x1f > > > [] sys_ioprio_get+0x50/0x2da > > > [] system_call_fastpath+0x16/0x1b > > > > > > > > > Signed-off-by: Sergey Senozhatsky > > > > > > --- > > > > > > 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) > > > 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; > > > > If you add the rcu_read_lock/unlock() sections, we would also need to > > update the comment above accordingly. > > Ah, yes indeed, misread the cases, sorry about the noise. Thanks, Davidlohr -- 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/