mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 16:24:13 +08:00
d4e3b928ab
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>
66 lines
1.6 KiB
C
66 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _BCACHEFS_JOURNAL_IO_H
|
|
#define _BCACHEFS_JOURNAL_IO_H
|
|
|
|
/*
|
|
* Only used for holding the journal entries we read in btree_journal_read()
|
|
* during cache_registration
|
|
*/
|
|
struct journal_replay {
|
|
struct journal_ptr {
|
|
bool csum_good;
|
|
u8 dev;
|
|
u32 bucket;
|
|
u32 bucket_offset;
|
|
u64 sector;
|
|
} ptrs[BCH_REPLICAS_MAX];
|
|
unsigned nr_ptrs;
|
|
|
|
bool csum_good;
|
|
bool ignore;
|
|
/* must be last: */
|
|
struct jset j;
|
|
};
|
|
|
|
static inline struct jset_entry *__jset_entry_type_next(struct jset *jset,
|
|
struct jset_entry *entry, unsigned type)
|
|
{
|
|
while (entry < vstruct_last(jset)) {
|
|
if (entry->type == type)
|
|
return entry;
|
|
|
|
entry = vstruct_next(entry);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
#define for_each_jset_entry_type(entry, jset, type) \
|
|
for (entry = (jset)->start; \
|
|
(entry = __jset_entry_type_next(jset, entry, type)); \
|
|
entry = vstruct_next(entry))
|
|
|
|
#define jset_entry_for_each_key(_e, _k) \
|
|
for (_k = (_e)->start; \
|
|
_k < vstruct_last(_e); \
|
|
_k = bkey_next(_k))
|
|
|
|
#define for_each_jset_key(k, entry, jset) \
|
|
for_each_jset_entry_type(entry, jset, BCH_JSET_ENTRY_btree_keys)\
|
|
jset_entry_for_each_key(entry, k)
|
|
|
|
int bch2_journal_entry_validate(struct bch_fs *, struct jset *,
|
|
struct jset_entry *, unsigned, int,
|
|
enum bkey_invalid_flags);
|
|
void bch2_journal_entry_to_text(struct printbuf *, struct bch_fs *,
|
|
struct jset_entry *);
|
|
|
|
void bch2_journal_ptrs_to_text(struct printbuf *, struct bch_fs *,
|
|
struct journal_replay *);
|
|
|
|
int bch2_journal_read(struct bch_fs *, u64 *, u64 *, u64 *);
|
|
|
|
CLOSURE_CALLBACK(bch2_journal_write);
|
|
|
|
#endif /* _BCACHEFS_JOURNAL_IO_H */
|