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

From: Mimi Zohar
Date: Mon Dec 02 2019 - 13:00:38 EST


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