There is no need for the kern check to be in the critical section,
it only complicates the code and slows down the case where the
socket is being created by the kernel.
Lifting it out will also allow socket_create to share common template
code, with other socket_permission checks.
Signed-off-by: John Johansen <john.johansen@canonical.com>
AA_BUG(in_interrupt());
+ if (kern)
+ return 0;
+
label = begin_current_label_crit_section();
- if (!(kern || unconfined(label)))
+ if (!unconfined(label)) {
error = aa_af_perm(current_cred(), label, OP_CREATE,
AA_MAY_CREATE, family, type, protocol);
+ }
end_current_label_crit_section(label);
return error;