]> git.baikalelectronics.ru Git - kernel.git/commit
percpu_ref_init(): clean ->percpu_count_ref on failure
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 18 May 2022 06:13:40 +0000 (02:13 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 18 May 2022 06:20:17 +0000 (02:20 -0400)
commit0b58261473f55ef3732b7fef1f73c2b870a86c9b
tree05ca2e6cf5a7d10291af1bdf2dc7bd164e85a234
parentf63d8bc4ac2007db06c865f01dcc2b9e8c9c02e0
percpu_ref_init(): clean ->percpu_count_ref on failure

That way percpu_ref_exit() is safe after failing percpu_ref_init().
At least one user (cgroup_create()) had a double-free that way;
there might be other similar bugs.  Easier to fix in percpu_ref_init(),
rather than playing whack-a-mole in sloppy users...

Usual symptoms look like a messed refcounting in one of subsystems
that use percpu allocations (might be percpu-refcount, might be
something else).  Having refcounts for two different objects share
memory is Not Nice(tm)...

Reported-by: syzbot+5b1e53987f858500ec00@syzkaller.appspotmail.com
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
lib/percpu-refcount.c