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: <CANaxB-yma9W3WdDwC+UZ3HnOHgWbc0WGC6a3S-qt+C_ThtPGbQ@mail.gmail.com>
Date:	Thu, 10 Nov 2011 13:27:21 +0300
From:	Andrew Wagin <avagin@...il.com>
To:	Glauber Costa <glommer@...allels.com>
Cc:	linux-kernel@...r.kernel.org, paul@...lmenage.org,
	lizf@...fujitsu.com, daniel.lezcano@...e.fr,
	a.p.zijlstra@...llo.nl, jbottomley@...allels.com, pjt@...gle.com,
	fweisbec@...il.com
Subject: Re: [PATCH v2 09/14] Keep nr_iowait per cgroup

This code has a race condition.
A task may be moved in another group between  task_group_nr_iowait_inc
and task_group_nr_iowait_dec.

# dd if=/dev/sda of=//dev/null bs=4095 & pid=$!
# echo $pid > /cgroup/1/tasks
# kill $pid
# cat /cgroup/1/cpu.proc.stat  | grep procs_blocked
procs_blocked 18446744073709551615

> +static inline void task_group_nr_iowait_inc(struct task_struct *p, int cpu)
> +{
> +
> +       atomic_inc(&per_cpu(kernel_cpustat, cpu).nr_iowait);
> +
> +#ifdef CONFIG_CGROUP_SCHED
> +       if (static_branch(&sched_cgroup_enabled)) {
> +               struct kernel_cpustat *kcpustat;
> +               struct task_group *tg;
> +
> +               rcu_read_lock();
> +               tg = task_group(p);
> +               while (tg && (tg != &root_task_group)) {
> +                       kcpustat = per_cpu_ptr(tg->cpustat, cpu);
> +                       atomic_inc(&kcpustat->nr_iowait);
> +                       tg = tg->parent;
> +               }
> +               rcu_read_unlock();
> +       }
> +#endif
> +}
> +
> +static inline void task_group_nr_iowait_dec(struct task_struct *p, int cpu)
> +{
> +
> +       atomic_dec(&per_cpu(kernel_cpustat, cpu).nr_iowait);
> +
> +#ifdef CONFIG_CGROUP_SCHED
> +       if (static_branch(&sched_cgroup_enabled)) {
> +               struct kernel_cpustat *kcpustat;
> +               struct task_group *tg;
> +
> +               rcu_read_lock();
> +               tg = task_group(p);
> +               while (tg && (tg != &root_task_group)) {
> +                       kcpustat = per_cpu_ptr(tg->cpustat, cpu);
> +                       atomic_dec(&kcpustat->nr_iowait);
> +                       tg = tg->parent;
> +               }
> +               rcu_read_unlock();
> +       }
> +#endif
> +}
> +
--
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