|
Goldwyn Rodrigues |
68ae09 |
From: Jeff Mahoney <jeffm@suse.com>
|
|
Goldwyn Rodrigues |
68ae09 |
Subject: apparmor: update apparmor-basic-networking-rules for 4.11-rc1
|
|
Goldwyn Rodrigues |
68ae09 |
Patch-mainline: depends on apparmor-basic-networking-rules.patch
|
|
Goldwyn Rodrigues |
68ae09 |
References: FATE#300516
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
4.11-rc1 changed op from a index into an array of strings to the strings
|
|
Goldwyn Rodrigues |
68ae09 |
themselves.
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
It also renamed: OP_SOCK_SHUTDOWN to OP_SHUTDOWN and
|
|
Goldwyn Rodrigues |
68ae09 |
common_audit_data.aad to common_audit_data.apparmor_audit_data and removed
|
|
Goldwyn Rodrigues |
68ae09 |
the gfp_t parameter from aa_audit.
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
|
|
Goldwyn Rodrigues |
68ae09 |
---
|
|
Goldwyn Rodrigues |
ae8385 |
security/apparmor/include/net.h | 4 ++--
|
|
Goldwyn Rodrigues |
ae8385 |
security/apparmor/lsm.c | 2 +-
|
|
Goldwyn Rodrigues |
ae8385 |
security/apparmor/net.c | 40 +++++++++++++++++++++-------------------
|
|
Goldwyn Rodrigues |
ae8385 |
3 files changed, 24 insertions(+), 22 deletions(-)
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
--- a/security/apparmor/include/net.h
|
|
Goldwyn Rodrigues |
68ae09 |
+++ b/security/apparmor/include/net.h
|
|
Goldwyn Rodrigues |
68ae09 |
@@ -32,9 +32,9 @@ struct aa_net {
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
ae8385 |
extern struct aa_fs_entry aa_fs_entry_network[];
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
ae8385 |
-extern int aa_net_perm(int op, struct aa_profile *profile, u16 family,
|
|
Goldwyn Rodrigues |
ae8385 |
+extern int aa_net_perm(const char *op, struct aa_profile *profile, u16 family,
|
|
Goldwyn Rodrigues |
68ae09 |
int type, int protocol, struct sock *sk);
|
|
Goldwyn Rodrigues |
ae8385 |
-extern int aa_revalidate_sk(int op, struct sock *sk);
|
|
Goldwyn Rodrigues |
ae8385 |
+extern int aa_revalidate_sk(const char *op, struct sock *sk);
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
static inline void aa_free_net_rules(struct aa_net *new)
|
|
Goldwyn Rodrigues |
68ae09 |
{
|
|
Goldwyn Rodrigues |
68ae09 |
--- a/security/apparmor/lsm.c
|
|
Goldwyn Rodrigues |
68ae09 |
+++ b/security/apparmor/lsm.c
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -683,7 +683,7 @@ static int apparmor_socket_shutdown(stru
|
|
Goldwyn Rodrigues |
68ae09 |
{
|
|
Goldwyn Rodrigues |
68ae09 |
struct sock *sk = sock->sk;
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
- return aa_revalidate_sk(OP_SOCK_SHUTDOWN, sk);
|
|
Goldwyn Rodrigues |
68ae09 |
+ return aa_revalidate_sk(OP_SHUTDOWN, sk);
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
static struct security_hook_list apparmor_hooks[] __lsm_ro_after_init = {
|
|
Goldwyn Rodrigues |
68ae09 |
--- a/security/apparmor/net.c
|
|
Goldwyn Rodrigues |
68ae09 |
+++ b/security/apparmor/net.c
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -37,12 +37,12 @@ static void audit_cb(struct audit_buffer
|
|
Goldwyn Rodrigues |
68ae09 |
audit_log_format(ab, "\"unknown(%d)\"", sa->u.net->family);
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
audit_log_format(ab, " sock_type=");
|
|
Goldwyn Rodrigues |
68ae09 |
- if (sock_type_names[sa->aad->net.type]) {
|
|
Goldwyn Rodrigues |
68ae09 |
- audit_log_string(ab, sock_type_names[sa->aad->net.type]);
|
|
Goldwyn Rodrigues |
68ae09 |
+ if (sock_type_names[aad(sa)->net.type]) {
|
|
Goldwyn Rodrigues |
68ae09 |
+ audit_log_string(ab, sock_type_names[aad(sa)->net.type]);
|
|
Goldwyn Rodrigues |
68ae09 |
} else {
|
|
Goldwyn Rodrigues |
68ae09 |
- audit_log_format(ab, "\"unknown(%d)\"", sa->aad->net.type);
|
|
Goldwyn Rodrigues |
68ae09 |
+ audit_log_format(ab, "\"unknown(%d)\"", aad(sa)->net.type);
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
- audit_log_format(ab, " protocol=%d", sa->aad->net.protocol);
|
|
Goldwyn Rodrigues |
68ae09 |
+ audit_log_format(ab, " protocol=%d", aad(sa)->net.protocol);
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
/**
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -57,8 +57,9 @@ static void audit_cb(struct audit_buffer
|
|
Goldwyn Rodrigues |
68ae09 |
*
|
|
Goldwyn Rodrigues |
68ae09 |
* Returns: %0 or sa->error else other errorcode on failure
|
|
Goldwyn Rodrigues |
68ae09 |
*/
|
|
Goldwyn Rodrigues |
68ae09 |
-static int audit_net(struct aa_profile *profile, int op, u16 family, int type,
|
|
Goldwyn Rodrigues |
68ae09 |
- int protocol, struct sock *sk, int error)
|
|
Goldwyn Rodrigues |
68ae09 |
+static int audit_net(struct aa_profile *profile, const char *op,
|
|
Goldwyn Rodrigues |
68ae09 |
+ u16 family, int type, int protocol,
|
|
Goldwyn Rodrigues |
68ae09 |
+ struct sock *sk, int error)
|
|
Goldwyn Rodrigues |
68ae09 |
{
|
|
Goldwyn Rodrigues |
68ae09 |
int audit_type = AUDIT_APPARMOR_AUTO;
|
|
Goldwyn Rodrigues |
68ae09 |
struct common_audit_data sa;
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -70,25 +71,26 @@ static int audit_net(struct aa_profile *
|
|
Goldwyn Rodrigues |
68ae09 |
sa.type = LSM_AUDIT_DATA_NONE;
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
/* todo fill in socket addr info */
|
|
Goldwyn Rodrigues |
68ae09 |
- sa.aad = &aad;
|
|
Goldwyn Rodrigues |
ae8385 |
+
|
|
Goldwyn Rodrigues |
68ae09 |
+ aad(&sa) = &aad;
|
|
Goldwyn Rodrigues |
68ae09 |
sa.u.net = &net;
|
|
Goldwyn Rodrigues |
68ae09 |
- sa.aad->op = op,
|
|
Goldwyn Rodrigues |
68ae09 |
+ aad(&sa)->op = op,
|
|
Goldwyn Rodrigues |
68ae09 |
sa.u.net->family = family;
|
|
Goldwyn Rodrigues |
68ae09 |
sa.u.net->sk = sk;
|
|
Goldwyn Rodrigues |
68ae09 |
- sa.aad->net.type = type;
|
|
Goldwyn Rodrigues |
68ae09 |
- sa.aad->net.protocol = protocol;
|
|
Goldwyn Rodrigues |
68ae09 |
- sa.aad->error = error;
|
|
Goldwyn Rodrigues |
68ae09 |
+ aad(&sa)->net.type = type;
|
|
Goldwyn Rodrigues |
68ae09 |
+ aad(&sa)->net.protocol = protocol;
|
|
Goldwyn Rodrigues |
68ae09 |
+ aad(&sa)->error = error;
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
- if (likely(!sa.aad->error)) {
|
|
Goldwyn Rodrigues |
68ae09 |
+ if (likely(!aad(&sa)->error)) {
|
|
Goldwyn Rodrigues |
68ae09 |
u16 audit_mask = profile->net.audit[sa.u.net->family];
|
|
Goldwyn Rodrigues |
68ae09 |
if (likely((AUDIT_MODE(profile) != AUDIT_ALL) &&
|
|
Goldwyn Rodrigues |
68ae09 |
- !(1 << sa.aad->net.type & audit_mask)))
|
|
Goldwyn Rodrigues |
68ae09 |
+ !(1 << aad(&sa)->net.type & audit_mask)))
|
|
Goldwyn Rodrigues |
68ae09 |
return 0;
|
|
Goldwyn Rodrigues |
68ae09 |
audit_type = AUDIT_APPARMOR_AUDIT;
|
|
Goldwyn Rodrigues |
68ae09 |
} else {
|
|
Goldwyn Rodrigues |
68ae09 |
u16 quiet_mask = profile->net.quiet[sa.u.net->family];
|
|
Goldwyn Rodrigues |
68ae09 |
u16 kill_mask = 0;
|
|
Jeff Mahoney |
eb353f |
- u16 denied = (1 << sa.aad->net.type);
|
|
Goldwyn Rodrigues |
ae8385 |
+ u16 denied = (1 << aad(&sa)->net.type) & ~quiet_mask;
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
if (denied & kill_mask)
|
|
Goldwyn Rodrigues |
68ae09 |
audit_type = AUDIT_APPARMOR_KILL;
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -96,10 +98,10 @@ static int audit_net(struct aa_profile *
|
|
Goldwyn Rodrigues |
68ae09 |
if ((denied & quiet_mask) &&
|
|
Goldwyn Rodrigues |
68ae09 |
AUDIT_MODE(profile) != AUDIT_NOQUIET &&
|
|
Goldwyn Rodrigues |
68ae09 |
AUDIT_MODE(profile) != AUDIT_ALL)
|
|
Goldwyn Rodrigues |
68ae09 |
- return COMPLAIN_MODE(profile) ? 0 : sa.aad->error;
|
|
Goldwyn Rodrigues |
68ae09 |
+ return COMPLAIN_MODE(profile) ? 0 : aad(&sa)->error;
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
- return aa_audit(audit_type, profile, GFP_KERNEL, &sa, audit_cb);
|
|
Goldwyn Rodrigues |
68ae09 |
+ return aa_audit(audit_type, profile, &sa, audit_cb);
|
|
Goldwyn Rodrigues |
68ae09 |
}
|
|
Goldwyn Rodrigues |
68ae09 |
|
|
Goldwyn Rodrigues |
68ae09 |
/**
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -112,8 +114,8 @@ static int audit_net(struct aa_profile *
|
|
Goldwyn Rodrigues |
68ae09 |
*
|
|
Goldwyn Rodrigues |
68ae09 |
* Returns: %0 else error if permission denied
|
|
Goldwyn Rodrigues |
68ae09 |
*/
|
|
Goldwyn Rodrigues |
68ae09 |
-int aa_net_perm(int op, struct aa_profile *profile, u16 family, int type,
|
|
Goldwyn Rodrigues |
68ae09 |
- int protocol, struct sock *sk)
|
|
Goldwyn Rodrigues |
68ae09 |
+int aa_net_perm(const char *op, struct aa_profile *profile, u16 family,
|
|
Goldwyn Rodrigues |
68ae09 |
+ int type, int protocol, struct sock *sk)
|
|
Goldwyn Rodrigues |
68ae09 |
{
|
|
Goldwyn Rodrigues |
68ae09 |
u16 family_mask;
|
|
Goldwyn Rodrigues |
68ae09 |
int error;
|
|
Goldwyn Rodrigues |
ae8385 |
@@ -142,7 +144,7 @@ int aa_net_perm(int op, struct aa_profil
|
|
Goldwyn Rodrigues |
68ae09 |
*
|
|
Goldwyn Rodrigues |
68ae09 |
* Returns: %0 else error if permission denied
|
|
Goldwyn Rodrigues |
68ae09 |
*/
|
|
Goldwyn Rodrigues |
68ae09 |
-int aa_revalidate_sk(int op, struct sock *sk)
|
|
Goldwyn Rodrigues |
68ae09 |
+int aa_revalidate_sk(const char *op, struct sock *sk)
|
|
Goldwyn Rodrigues |
68ae09 |
{
|
|
Goldwyn Rodrigues |
ae8385 |
struct aa_profile *profile;
|
|
Goldwyn Rodrigues |
68ae09 |
int error = 0;
|