Skip to content

Commit 6cc6a05

Browse files
committed
apparmor: lift kernel socket check out of critical section
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>
1 parent 9045aa2 commit 6cc6a05

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

security/apparmor/lsm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,10 +1095,14 @@ static int apparmor_socket_create(int family, int type, int protocol, int kern)
10951095

10961096
AA_BUG(in_interrupt());
10971097

1098+
if (kern)
1099+
return 0;
1100+
10981101
label = begin_current_label_crit_section();
1099-
if (!(kern || unconfined(label)))
1102+
if (!unconfined(label)) {
11001103
error = aa_af_perm(current_cred(), label, OP_CREATE,
11011104
AA_MAY_CREATE, family, type, protocol);
1105+
}
11021106
end_current_label_crit_section(label);
11031107

11041108
return error;

0 commit comments

Comments
 (0)