Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755001Ab0KIKVm (ORCPT ); Tue, 9 Nov 2010 05:21:42 -0500 Received: from mail-ey0-f174.google.com ([209.85.215.174]:49070 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754609Ab0KIKVj (ORCPT ); Tue, 9 Nov 2010 05:21:39 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=JDXQrYdj+TP3seAs01jwPHyms+4qu6fQxa7fB1KU6GwQNy61I7+4e4JvPLf8Lc2Im8 5gcsenLBHiY1cX4MG16KN+j/IdNfUeG7Lg368jpazVBbx939P40HPukCReZXNKXqUlIJ NvZDhICd1f6pSg2LJ6l5atHnWZpxim3kCkdGA= Date: Tue, 9 Nov 2010 12:21:24 +0200 From: Sergey Senozhatsky To: Alexander Viro Cc: Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, "Paul E. McKenney" , Ingo Molnar , Tetsuo Handa Subject: [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2) Message-ID: <20101109102124.GA3916@swordfish.minsk.epam.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2135 Lines: 66 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. kernel/pid.c:419 invoked rcu_dereference_check() without protection! 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 V2: rcu critical section expanded according to comment by Paul E. McKenne: | Looking over the patch again, the scope of the RCU read-side critical | section needs to expand to cover the use of the pointer as well as the | call to find_task_by_vpid(). Signed-off-by: Sergey Senozhatsky --- diff --git a/fs/ioprio.c b/fs/ioprio.c index 748cfb9..64cd50b 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c @@ -111,12 +111,14 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio) read_lock(&tasklist_lock); switch (which) { case IOPRIO_WHO_PROCESS: + rcu_read_lock(); if (!who) p = current; else p = find_task_by_vpid(who); if (p) ret = set_task_ioprio(p, ioprio); + rcu_read_unlock(); break; case IOPRIO_WHO_PGRP: if (!who) @@ -200,12 +202,14 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) read_lock(&tasklist_lock); switch (which) { case IOPRIO_WHO_PROCESS: + rcu_read_lock(); if (!who) p = current; else p = find_task_by_vpid(who); if (p) ret = get_task_ioprio(p); + rcu_read_unlock(); break; case IOPRIO_WHO_PGRP: if (!who) -- 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/