[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5dfd4844-6c36-3b8d-203b-564d7ad7103d@arm.com>
Date: Sun, 15 Sep 2019 15:33:29 +0100
From: Valentin Schneider <valentin.schneider@....com>
To: 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 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.
Powered by blists - more mailing lists