lib: prevent module unloading if memory is not freed
Skip freeing module's data section if there are non-zero allocation tags because otherwise, once these allocations are freed, the access to their code tag would cause UAF. Link: https://lkml.kernel.org/r/20240321163705.3067592-13-surenb@google.com Signed-off-by: Suren Baghdasaryan <surenb@google.com> Tested-by: Kees Cook <keescook@chromium.org> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Alex Gaynor <alex.gaynor@gmail.com> Cc: Alice Ryhl <aliceryhl@google.com> Cc: Andreas Hindborg <a.hindborg@samsung.com> Cc: Benno Lossin <benno.lossin@proton.me> Cc: "Björn Roy Baron" <bjorn3_gh@protonmail.com> Cc: Boqun Feng <boqun.feng@gmail.com> Cc: Christoph Lameter <cl@linux.com> Cc: Dennis Zhou <dennis@kernel.org> Cc: Gary Guo <gary@garyguo.net> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: Miguel Ojeda <ojeda@kernel.org> Cc: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Tejun Heo <tj@kernel.org> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Wedson Almeida Filho <wedsonaf@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
committed by
Andrew Morton
parent
a473573964
commit
47a92dfbe0
@@ -35,7 +35,7 @@ struct codetag_type_desc {
|
||||
size_t tag_size;
|
||||
void (*module_load)(struct codetag_type *cttype,
|
||||
struct codetag_module *cmod);
|
||||
void (*module_unload)(struct codetag_type *cttype,
|
||||
bool (*module_unload)(struct codetag_type *cttype,
|
||||
struct codetag_module *cmod);
|
||||
};
|
||||
|
||||
@@ -71,10 +71,10 @@ codetag_register_type(const struct codetag_type_desc *desc);
|
||||
|
||||
#if defined(CONFIG_CODE_TAGGING) && defined(CONFIG_MODULES)
|
||||
void codetag_load_module(struct module *mod);
|
||||
void codetag_unload_module(struct module *mod);
|
||||
bool codetag_unload_module(struct module *mod);
|
||||
#else
|
||||
static inline void codetag_load_module(struct module *mod) {}
|
||||
static inline void codetag_unload_module(struct module *mod) {}
|
||||
static inline bool codetag_unload_module(struct module *mod) { return true; }
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_CODETAG_H */
|
||||
|
||||
Reference in New Issue
Block a user