Re: [PATCH v0 1/2] IMA: Defined queue functions

Mimi Zohar
2019-12-02T18:00:37Z

On Wed, 2019-11-27 at 13:11 -0800, Lakshmi Ramasubramanian wrote:
> On 11/27/19 12:38 PM, Mimi Zohar wrote:

> > I'm not sure why you want to differentiate between IMA being
> > initialized vs. an empty policy.  I would think you would want to know
> > when a custom policy has been loaded.
>
> You are right - When custom ima policy rules are loaded (in
> ima_update_policy() function), ima_process_queued_keys_for_measurement()
> function is called to process queued keys.
>
> The flag ima_process_keys_for_measurement is set to true in
> ima_process_queued_keys_for_measurement(). And, subsequent keys are
> processed immediately.
>
> Please take a look at ima_process_queued_keys_for_measurement() in this
> patch (v0 1/2) and the ima_update_policy() change in "PATCH v0 2/2".

ima_update_policy() is called from multiple places.  Initially, it is
called before a custom policy has been loaded.  The call to
ima_process_queued_keys_for_measurement() needs to be moved to within
the test, otherwise it runs the risk of dropping "key" measurements.

All the queued keys need to be processed at the same time.  Afterwards
the queue should be deleted.  Unfortunately, the current queue locking
assumes ima_process_queued_keys_for_measurement() is called multiple
times.

Perhaps using the RCU method of walking lists would help.  I need to
think about it some more.

Mimi