]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
kern: cpuset: resolve race between cpuset_lookup/cpuset_rel
authorkevans <kevans@FreeBSD.org>
Tue, 8 Dec 2020 18:45:47 +0000 (18:45 +0000)
committerkevans <kevans@FreeBSD.org>
Tue, 8 Dec 2020 18:45:47 +0000 (18:45 +0000)
commit7797617b36d19cb8326460dc357cf354dd599e14
tree27a1c626ef31c6bda4c3482ef06bdc2bbe20d260
parentbe6234a2164099e1b54ae9bee82520cd747df71a
kern: cpuset: resolve race between cpuset_lookup/cpuset_rel

The race plays out like so between threads A and B:

1. A ref's cpuset 10
2. B does a lookup of cpuset 10, grabs the cpuset lock and searches
   cpuset_ids
3. A rel's cpuset 10 and observes the last ref, waits on the cpuset lock
   while B is still searching and not yet ref'd
4. B ref's cpuset 10 and drops the cpuset lock
5. A proceeds to free the cpuset out from underneath B

Resolve the race by only releasing the last reference under the cpuset lock.
Thread A now picks up the spinlock and observes that the cpuset has been
revived, returning immediately for B to deal with later.

Reported by: syzbot+92dff413e201164c796b@syzkaller.appspotmail.com
Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27498
sys/kern/kern_cpuset.c