From 73a29ade16f45a6c333a11ce2ac0b3ef0a6662b4 Mon Sep 17 00:00:00 2001 From: John Johansen Date: Thu, 18 Jul 2024 12:43:21 +0000 Subject: [PATCH] Merge parser: fix unix for all rule By specifying 0 in the unix type, all rules were allowing only the "none" type, when it wanted to allow all types, so replace it by 0xffffffff. Also, add this testcase to the unix regression tests. Fixes: https://gitlab.com/apparmor/apparmor/-/issues/410 I propose this fix for master and apparmor-4.0 Closes #410 MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/1273 Approved-by: John Johansen Merged-by: John Johansen (cherry picked from commit 5b44e33d25cbbe5c29a7e86dc1bb0e91053a8ed2) Signed-off-by: John Johansen --- parser/all_rule.cc | 4 +-- tests/regression/apparmor/aa_exec.sh | 13 ++++++++ tests/regression/apparmor/access.sh | 9 +++++- .../apparmor/attach_disconnected.sh | 9 ++++++ tests/regression/apparmor/dbus_eavesdrop.sh | 5 ++++ tests/regression/apparmor/dbus_message.sh | 6 ++++ tests/regression/apparmor/dbus_service.sh | 8 +++++ .../apparmor/dbus_unrequested_reply.sh | 8 +++++ tests/regression/apparmor/io_uring.sh | 5 ++++ tests/regression/apparmor/mount.sh | 30 +++++++++++++++++++ tests/regression/apparmor/net_inet.sh | 23 +++++++++++--- tests/regression/apparmor/net_raw.sh | 4 +++ tests/regression/apparmor/pivot_root.sh | 5 ++++ tests/regression/apparmor/posix_mq.sh | 4 +++ tests/regression/apparmor/ptrace_v6.inc | 9 ++++++ tests/regression/apparmor/tcp.sh | 6 ++++ tests/regression/apparmor/unix_socket.inc | 5 ++++ tests/regression/apparmor/userns.sh | 5 ++++ 18 files changed, 151 insertions(+), 7 deletions(-) diff --git a/parser/all_rule.cc b/parser/all_rule.cc index 34159349e..4ebc47a8a 100644 --- a/parser/all_rule.cc +++ b/parser/all_rule.cc @@ -39,7 +39,7 @@ void all_rule::add_implied_rules(Profile &prof) prefix_rule_t *rule; const prefixes *prefix = this; - rule = new unix_rule(0, audit, rule_mode); + rule = new unix_rule(0xffffffff, audit, rule_mode); (void) rule->add_prefix(*prefix); prof.rule_ents.push_back(rule); @@ -67,7 +67,7 @@ void all_rule::add_implied_rules(Profile &prof) (void) rule->add_prefix(*prefix); prof.rule_ents.push_back(rule); - rule = new mnt_rule(NULL, NULL, NULL, NULL, 0); + rule = new mnt_rule(NULL, NULL, NULL, NULL, AA_MAY_MOUNT); (void) rule->add_prefix(*prefix); prof.rule_ents.push_back(rule); diff --git a/tests/regression/apparmor/aa_exec.sh b/tests/regression/apparmor/aa_exec.sh index daaefee9b..9ef1f5355 100755 --- a/tests/regression/apparmor/aa_exec.sh +++ b/tests/regression/apparmor/aa_exec.sh @@ -79,3 +79,16 @@ runchecktest "complain (--namespace=${ns})" pass "$aa_exec -n $ns -p $test" "$te genprofile_aa_exec "$test" 0 runchecktest "negative test: bad ns (--namespace=${ns}XXX)" fail "$aa_exec -n ${ns}XXX -p $test" "$test (enforce)" + +if [ "$(parser_supports 'all,')" = "true" ]; then + genprofile --stdin <