linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2)
@ 2010-11-09 10:21 Sergey Senozhatsky
  2010-11-09 20:15 ` Paul E. McKenney
  0 siblings, 1 reply; 4+ messages in thread
From: Sergey Senozhatsky @ 2010-11-09 10:21 UTC (permalink / raw)
  To: Alexander Viro
  Cc: Andrew Morton, linux-fsdevel, linux-kernel, Paul E. McKenney,
	Ingo Molnar, Tetsuo Handa

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:
 [<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
                     
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 <sergey.senozhatsky@gmail.com>

---

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)


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2)
  2010-11-09 10:21 [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2) Sergey Senozhatsky
@ 2010-11-09 20:15 ` Paul E. McKenney
  2010-11-09 20:20   ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2010-11-09 20:15 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: Alexander Viro, Andrew Morton, linux-fsdevel, linux-kernel,
	Ingo Molnar, Tetsuo Handa, jaxboe

On Tue, Nov 09, 2010 at 12:21:24PM +0200, 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.
> 
>  kernel/pid.c:419 invoked rcu_dereference_check() without protection!
> 
>  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
>                      
> 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().

Thank you, Sergey!

Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>

Jens, are you willing to take this one?

							Thanx, Paul

> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> 
> ---
> 
> 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)
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2)
  2010-11-09 20:15 ` Paul E. McKenney
@ 2010-11-09 20:20   ` Jens Axboe
  2010-11-09 20:48     ` Sergey Senozhatsky
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2010-11-09 20:20 UTC (permalink / raw)
  To: paulmck@linux.vnet.ibm.com
  Cc: Sergey Senozhatsky, Alexander Viro, Andrew Morton,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ingo Molnar, Tetsuo Handa

On 2010-11-09 21:15, Paul E. McKenney wrote:
> On Tue, Nov 09, 2010 at 12:21:24PM +0200, 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.
>>
>>  kernel/pid.c:419 invoked rcu_dereference_check() without protection!
>>
>>  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
>>                      
>> 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().
> 
> Thank you, Sergey!
> 
> Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> 
> Jens, are you willing to take this one?

Certainly, thanks guys!

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2)
  2010-11-09 20:20   ` Jens Axboe
@ 2010-11-09 20:48     ` Sergey Senozhatsky
  0 siblings, 0 replies; 4+ messages in thread
From: Sergey Senozhatsky @ 2010-11-09 20:48 UTC (permalink / raw)
  To: Jens Axboe
  Cc: paulmck@linux.vnet.ibm.com, Sergey Senozhatsky, Alexander Viro,
	Andrew Morton, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, Ingo Molnar, Tetsuo Handa

[-- Attachment #1: Type: text/plain, Size: 238 bytes --]

On (11/09/10 21:20), Jens Axboe wrote:
> > Thank you, Sergey!
> > 
> > Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
> > 
> > Jens, are you willing to take this one?
> 
> Certainly, thanks guys!
> 

Thank you,
	Sergey

[-- Attachment #2: Type: application/pgp-signature, Size: 316 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-11-09 20:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-09 10:21 [PATCH] ioprio: rcu_read_lock/unlock protect find_task_by_vpid call (V2) Sergey Senozhatsky
2010-11-09 20:15 ` Paul E. McKenney
2010-11-09 20:20   ` Jens Axboe
2010-11-09 20:48     ` Sergey Senozhatsky

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).