Skip to content

Commit

Permalink
module: Make module_flags_taint() accept a module's taints bitmap and…
Browse files Browse the repository at this point in the history
… usable outside core code

No functional change.

The purpose of this patch is to modify module_flags_taint() to accept
a module's taints bitmap as a parameter and modifies all users
accordingly. Furthermore, it is now possible to access a given
module's taint flags data outside of non-essential code yet does
remain for internal use only.

This is in preparation for module unload taint tracking support.

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
  • Loading branch information
Aaron Tomlin authored and Luis Chamberlain committed May 12, 2022
1 parent 80140a8 commit c14e522
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions kernel/module/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ int cmp_name(const void *name, const void *sym);
long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr,
unsigned int section);
char *module_flags(struct module *mod, char *buf);
size_t module_flags_taint(unsigned long taints, char *buf);

static inline unsigned long kernel_symbol_value(const struct kernel_symbol *sym)
{
Expand Down
8 changes: 4 additions & 4 deletions kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -890,13 +890,13 @@ static inline int module_unload_init(struct module *mod)
}
#endif /* CONFIG_MODULE_UNLOAD */

static size_t module_flags_taint(struct module *mod, char *buf)
size_t module_flags_taint(unsigned long taints, char *buf)
{
size_t l = 0;
int i;

for (i = 0; i < TAINT_FLAGS_COUNT; i++) {
if (taint_flags[i].module && test_bit(i, &mod->taints))
if (taint_flags[i].module && test_bit(i, &taints))
buf[l++] = taint_flags[i].c_true;
}

Expand Down Expand Up @@ -974,7 +974,7 @@ static ssize_t show_taint(struct module_attribute *mattr,
{
size_t l;

l = module_flags_taint(mk->mod, buffer);
l = module_flags_taint(mk->mod->taints, buffer);
buffer[l++] = '\n';
return l;
}
Expand Down Expand Up @@ -2993,7 +2993,7 @@ char *module_flags(struct module *mod, char *buf)
mod->state == MODULE_STATE_GOING ||
mod->state == MODULE_STATE_COMING) {
buf[bx++] = '(';
bx += module_flags_taint(mod, buf + bx);
bx += module_flags_taint(mod->taints, buf + bx);
/* Show a - for module-is-being-unloaded */
if (mod->state == MODULE_STATE_GOING)
buf[bx++] = '-';
Expand Down

0 comments on commit c14e522

Please sign in to comment.