mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Fix af_unix downgrade of network rules
with unix rules we output a downgraded rule compatible with network rules so that policy will work on kernels that support network socket controls but not the extended af_unix rules however this is currently broken if the socket type is left unspecified (initialized to -1), resulting in denials for kernels that don't support the extended af_unix rules. cherry-pick: lp:apparmor r3700 Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: timeout
This commit is contained in:
parent
bc5634f2af
commit
878ebd4b33
1 changed files with 8 additions and 4 deletions
|
@ -196,16 +196,20 @@ static void writeu16(std::ostringstream &o, int v)
|
|||
#define CMD_OPT 4
|
||||
|
||||
void unix_rule::downgrade_rule(Profile &prof) {
|
||||
unsigned int mask = (unsigned int) -1;
|
||||
|
||||
if (!prof.net.allow && !prof.alloc_net_table())
|
||||
yyerror(_("Memory allocation error."));
|
||||
if (sock_type_n != -1)
|
||||
mask = 1 << sock_type_n;
|
||||
if (deny) {
|
||||
prof.net.deny[AF_UNIX] |= 1 << sock_type_n;
|
||||
prof.net.deny[AF_UNIX] |= mask;
|
||||
if (!audit)
|
||||
prof.net.quiet[AF_UNIX] |= 1 << sock_type_n;
|
||||
prof.net.quiet[AF_UNIX] |= mask;
|
||||
} else {
|
||||
prof.net.allow[AF_UNIX] |= 1 << sock_type_n;
|
||||
prof.net.allow[AF_UNIX] |= mask;
|
||||
if (audit)
|
||||
prof.net.audit[AF_UNIX] |= 1 << sock_type_n;
|
||||
prof.net.audit[AF_UNIX] |= mask;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue