Re: [PATCH 3/5] Call security hooks conditionally if the security_op is filled out.

Chris Wright
2005-08-25T16:24:09Z

* Kurt Garloff (garloff@suse.de) wrote:
> You did not like my macro abuse, apparently.
> That's too bad, as it allowed you to do changes without changing
> hundreds of lines of code.

It was handy that way, but I think this way is just cleaner and simpler.
Esp. when checking against the function ptr, not the security_ops ptr.

> Just one remark:
> Make sure you don't set security_ops->XXX ever back to NULL or you
> might take an oops.
> Security module unloading is racy and always has been. It's not well
> defined at what point in time the new functions become effective.
> And we certainly don't want to use locking for performance reasons.
> One could think of using RCU, though, thus the security_ops pointer
> would only be changed after all CPUs schedule()d ...

Removing a security module has always been unsafe.

> In my version of the patches, I maintained the capability_security_ops
> structure fully filled-in and pointed security_ops to it, so you'll
> always have a valid function pointer. If you wanted to avoid a pointer
> compare, I had an integer to look at ...

Yes, that's how 2/5 is. At KS, there was specific mention of not doing
unconditional call. Comparing against security_ops only helps the case
where a module is not loaded. Checking the function ptr should help any
module with sparse ops.