summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc
diff options
context:
space:
mode:
authorZhao Feng <zhaofeng2@cmss.chinamobile.com>2026-11-09 10:37:53 +0800
committerMikulas Patocka <mpatocka@redhat.com>2026-11-09 13:22:54 +0100
commit8ba1ade3e6b595b9091040feaa3341d7e45ba95d (patch)
treee75fd8590478d139b1a3893b5e3dd10935c7ca8b /rust/kernel/alloc
parentc834161ded1a141a58d5f03b24f6894291222c96 (diff)
dm crypt: fix use of uninitialized percpu_counter in ctr error path
If percpu_counter_init() fails in crypt_ctr() (e.g. when the underlying percpu allocation fails under memory pressure or fault injection), the error path jumps to "bad", which calls crypt_dtr(). crypt_dtr() then evaluates WARN_ON(percpu_counter_sum(&cc->n_allocated_pages) != 0) and calls percpu_counter_destroy() on a counter that was never initialized, because __percpu_counter_init_many() returns -ENOMEM before calling raw_spin_lock_init() on fbc->lock. With lockdep enabled this triggers "INFO: trying to register non-static key" in __percpu_counter_sum(), as reported by syzbot. The console additionally shows "crypt: Unknown error (-ENOMEM)" because this failure path sets no ti->error. Move percpu_counter_init() to right after the allocation of cc, before ti->private is set and before any "goto bad" can happen. On failure, set ti->error and free cc directly, so that crypt_dtr() is only ever called with an initialized counter. Reported-by: syzbot+4b232570d625662eaab4@syzkaller.appspotmail.com Closes: https://syzbot.org/bug?extid=4b232570d625662eaab4 Fixes: 5059353df86e ("dm crypt: limit the number of allocated pages") Cc: stable@vger.kernel.org Signed-off-by: Zhao Feng <zhaofeng2@cmss.chinamobile.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Diffstat (limited to 'rust/kernel/alloc')
0 files changed, 0 insertions, 0 deletions