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: <40680310-60b3-589a-d0e8-b4dd723db10a@arm.com>
Date:   Mon, 23 Sep 2019 17:43:14 +0200
From:   Dietmar Eggemann <dietmar.eggemann@....com>
To:     Valentin Schneider <valentin.schneider@....com>,
        shikemeng <shikemeng@...wei.com>, mingo@...hat.com,
        peterz@...radead.org
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched: fix migration to invalid cpu in
 __set_cpus_allowed_ptr

On 9/15/19 4:33 PM, Valentin Schneider wrote:
> On 15/09/2019 09:21, shikemeng wrote:
>>> It's more thoughtful to add check in cpumask_test_cpu.It can solve this problem and can prevent other potential bugs.I will test it and resend
>>> a new patch.
>>>
>>
>> Think again and again. As cpumask_check will fire a warning if cpu >= nr_cpu_ids, it seems that cpumask_check only expects cpu < nr_cpu_ids and it's
>> caller's responsibility to very cpu is in valid range. Interfaces like cpumask_test_and_set_cpu, cpumask_test_and_clear_cpu and so on are not checking
>> cpu < nr_cpu_ids either and may cause demage if cpu is out of range.
>>
> 
> cpumask operations clearly should never be fed CPU numbers > nr_cpu_ids,
> but we can get some sneaky mishaps like the one you're fixing. The answer
> might just be to have more folks turn on DEBUG_PER_CPU_MAPS in their test
> runs (I don't for instance - will do from now on), since I get the feeling
> people like to be able to disable these checks for producty kernels.
> 
> In any case, don't feel like you have to fix this globally - your fix is
> fine on its own.

I'm not sure that CONFIG_DEBUG_PER_CPU_MAPS=y will help you here.

__set_cpus_allowed_ptr(...)
{
    ...
    dest_cpu = cpumask_any_and(...)
    ...
}

With:

#define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2))
#define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p),
(src2p))

cpumask_next_and() is called with n = -1 and in this case does not
invoke cpumask_check().

---

BTW, I can recreate the issue quite easily with:

  qemu-system-x86_64 ... -smp cores=64 ... -enable-kvm

with the default kernel config.



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ