[PATCH v12 03/26] ima: Define ima_namespace struct and start moving variables into it
Serge E. Hallyn
serge at hallyn.com
Tue May 24 15:05:51 UTC 2022
On Tue, May 24, 2022 at 10:57:13AM -0400, Stefan Berger wrote:
>
>
> On 5/20/22 22:33, Serge E. Hallyn wrote:
>
> > > diff --git a/security/integrity/ima/ima_queue_keys.c b/security/integrity/ima/ima_queue_keys.c
> > > index 93056c03bf5a..e366a21dd8be 100644
> > > --- a/security/integrity/ima/ima_queue_keys.c
> > > +++ b/security/integrity/ima/ima_queue_keys.c
> > > @@ -10,6 +10,7 @@
> > > #include <linux/user_namespace.h>
> > > #include <linux/workqueue.h>
> > > +#include <linux/ima.h>
> > > #include <keys/asymmetric-type.h>
> > > #include "ima.h"
> > > @@ -42,7 +43,7 @@ static bool timer_expired;
> > > static void ima_keys_handler(struct work_struct *work)
> > > {
> > > timer_expired = true;
> > > - ima_process_queued_keys();
> > > + ima_process_queued_keys(&init_ima_ns);
> > > }
> > > /*
> > > @@ -130,11 +131,15 @@ bool ima_queue_key(struct key *keyring, const void *payload,
> > > * This function sets ima_process_keys to true and processes queued keys.
> > > * From here on keys will be processed right away (not queued).
> > > */
> > > -void ima_process_queued_keys(void)
> > > +void ima_process_queued_keys(struct ima_namespace *ns)
> > > {
> > > struct ima_key_entry *entry, *tmp;
> > > bool process = false;
> > > + /* only applies to init_ima_ns */
> >
> > Hm, yes, it seems to, but it should be unreachable with
> > ns != &init_ima_ns, ever, right?
> >
> > So it seems better to either not have this hunk at all, (both
> > here and at ima_keys_handler()) or to actually have a BUG_ON.
> >
> > Or am I completely misreading the situation?
>
> No, you are right. This function is only calledwith ns = &init_ima_ns at the
> moment. How about changing it to this here?
>
> if (WARN_ON(ns != &init_ima_ns))
> return;
Sounds good, thanks.
More information about the Linux-security-module-archive
mailing list