closures: CLOSURE_CALLBACK() to fix type punning
authorKent Overstreet <kent.overstreet@linux.dev>
Sat, 18 Nov 2023 00:13:27 +0000 (19:13 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 24 Nov 2023 05:29:58 +0000 (00:29 -0500)
commitd4e3b928ab487a8aecd1f6a140b40ac365116cfb
tree3beb53d9f7492d60014d84af51ad7e3c56ade753
parent98b1cc82c4affc16f5598d4fa14b1858671b2263
closures: CLOSURE_CALLBACK() to fix type punning

Control flow integrity is now checking that type signatures match on
indirect function calls. That breaks closures, which embed a work_struct
in a closure in such a way that a closure_fn may also be used as a
workqueue fn by the underlying closure code.

So we have to change closure fns to take a work_struct as their
argument - but that results in a loss of clarity, as closure fns have
different semantics from normal workqueue functions (they run owning a
ref on the closure, which must be released with continue_at() or
closure_return()).

Thus, this patc introduces CLOSURE_CALLBACK() and closure_type() macros
as suggested by Kees, to smooth things over a bit.

Suggested-by: Kees Cook <keescook@chromium.org>
Cc: Coly Li <colyli@suse.de>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
16 files changed:
drivers/md/bcache/btree.c
drivers/md/bcache/journal.c
drivers/md/bcache/movinggc.c
drivers/md/bcache/request.c
drivers/md/bcache/request.h
drivers/md/bcache/super.c
drivers/md/bcache/writeback.c
fs/bcachefs/btree_io.c
fs/bcachefs/btree_update_interior.c
fs/bcachefs/fs-io-direct.c
fs/bcachefs/io_write.c
fs/bcachefs/io_write.h
fs/bcachefs/journal_io.c
fs/bcachefs/journal_io.h
include/linux/closure.h
lib/closure.c