lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1260345601.5489.64.camel@laptop>
Date:	Wed, 09 Dec 2009 09:00:01 +0100
From:	Peter Zijlstra <peterz@...radead.org>
To:	Thomas Gleixner <tglx@...utronix.de>
Cc:	LKML <linux-kernel@...r.kernel.org>, Ingo Molnar <mingo@...e.hu>
Subject: Re: [patch 1/2] sched: Protect task->cpus_allowed access in
 sched_getaffinity()

On Tue, 2009-12-08 at 20:24 +0000, Thomas Gleixner wrote:
> plain text document attachment
> (sched-fix-sched-get-affinity-racy-access.patch)
> sched_getaffinity() is not protected against a concurrent modification
> of the tasks affinity.
> 
> Serialize the access with task_rq_lock(task).
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> ---
>  kernel/sched.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> Index: linux-2.6-tip/kernel/sched.c
> ===================================================================
> --- linux-2.6-tip.orig/kernel/sched.c
> +++ linux-2.6-tip/kernel/sched.c
> @@ -6631,6 +6631,8 @@ SYSCALL_DEFINE3(sched_setaffinity, pid_t
>  long sched_getaffinity(pid_t pid, struct cpumask *mask)
>  {
>  	struct task_struct *p;
> +	unsigned long flags;
> +	struct rq *rq;
>  	int retval;
>  
>  	get_online_cpus();
> @@ -6645,7 +6647,9 @@ long sched_getaffinity(pid_t pid, struct
>  	if (retval)
>  		goto out_unlock;
>  
> +	rq = task_rq_lock(p, &flags);
>  	cpumask_and(mask, &p->cpus_allowed, cpu_online_mask);
> +	task_rq_unlock(rq, &flags);
>  
>  out_unlock:
>  	read_unlock(&tasklist_lock);
> 

Hehe, I wrote the exact same patch last night :-)

Acked-by: Peter Zijlstra <a.p.zijlstra@...llo.nl>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ