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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <463d3d8d-5d6c-6c83-561b-199ab1bd8887@redhat.com>
Date:   Fri, 7 Oct 2022 14:59:42 -0400
From:   Waiman Long <longman@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Ingo Molnar <mingo@...hat.com>, Juri Lelli <juri.lelli@...hat.com>,
        Vincent Guittot <vincent.guittot@...aro.org>,
        Dietmar Eggemann <dietmar.eggemann@....com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ben Segall <bsegall@...gle.com>, Mel Gorman <mgorman@...e.de>,
        Daniel Bristot de Oliveira <bristot@...hat.com>,
        Valentin Schneider <vschneid@...hat.com>,
        Tejun Heo <tj@...nel.org>, Zefan Li <lizefan.x@...edance.com>,
        Johannes Weiner <hannes@...xchg.org>,
        Will Deacon <will@...nel.org>, linux-kernel@...r.kernel.org,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Lai Jiangshan <jiangshanlai@...il.com>
Subject: Re: [PATCH v10 4/5] sched: Handle set_cpus_allowed_ptr(),
 sched_setaffinity() & other races

On 10/7/22 08:47, Peter Zijlstra wrote:
> On Thu, Sep 22, 2022 at 02:00:40PM -0400, Waiman Long wrote:
>> Racing is possible between set_cpus_allowed_ptr() and sched_setaffinity()
>> or between multiple sched_setaffinity() calls from different
>> CPUs. To resolve these race conditions, we need to update both
>> user_cpus_ptr and cpus_mask in a single lock critical section instead
>> of separated ones. This requires moving the user_cpus_ptr update
>> to set_cpus_allowed_common() by putting the user_mask into a new
>> affinity_context structure and using it to pass information around
>> various functions.
>>
>> This patch also changes the handling of the race between the
>> sched_setaffinity() call and the changing of cpumask of the current
>> cpuset. In case the new mask conflicts with newly updated cpuset,
>> the cpus_mask will be reset to the cpuset cpumask and an error value
>> of -EINVAL will be returned. If a previous user_cpus_ptr value exists,
>> it will be swapped back in and the new_mask will be further restricted
>> to what is allowed in the cpumask pointed to by the old user_cpus_ptr.
>>
>> The potential race between sched_setaffinity() and a fork/clone()
>> syscall calling dup_user_cpus_ptr() is also being handled.
> This is still arse-backwards... You're still fixing races you've
> introduced earlier in the series.
>
> Since I don't think telling you again is going to help; I've done it for
> you :/ How's this then?
>
>    https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git/log/?h=sched/affinity
>
Thank you very much for updating the patch series. Beside the minor nit 
that I talked about in the previous mail, the result looks good to me. 
Do you mind if I send another patch on top of your branch to make the 
adjustment or you want to do it yourself?

Cheers,
Longman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ