~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/security/apparmor/include/net.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 /*
  3  * AppArmor security module
  4  *
  5  * This file contains AppArmor network mediation definitions.
  6  *
  7  * Copyright (C) 1998-2008 Novell/SUSE
  8  * Copyright 2009-2017 Canonical Ltd.
  9  */
 10 
 11 #ifndef __AA_NET_H
 12 #define __AA_NET_H
 13 
 14 #include <net/sock.h>
 15 #include <linux/path.h>
 16 
 17 #include "apparmorfs.h"
 18 #include "label.h"
 19 #include "perms.h"
 20 #include "policy.h"
 21 
 22 #define AA_MAY_SEND             AA_MAY_WRITE
 23 #define AA_MAY_RECEIVE          AA_MAY_READ
 24 
 25 #define AA_MAY_SHUTDOWN         AA_MAY_DELETE
 26 
 27 #define AA_MAY_CONNECT          AA_MAY_OPEN
 28 #define AA_MAY_ACCEPT           0x00100000
 29 
 30 #define AA_MAY_BIND             0x00200000
 31 #define AA_MAY_LISTEN           0x00400000
 32 
 33 #define AA_MAY_SETOPT           0x01000000
 34 #define AA_MAY_GETOPT           0x02000000
 35 
 36 #define NET_PERMS_MASK (AA_MAY_SEND | AA_MAY_RECEIVE | AA_MAY_CREATE |    \
 37                         AA_MAY_SHUTDOWN | AA_MAY_BIND | AA_MAY_LISTEN |   \
 38                         AA_MAY_CONNECT | AA_MAY_ACCEPT | AA_MAY_SETATTR | \
 39                         AA_MAY_GETATTR | AA_MAY_SETOPT | AA_MAY_GETOPT)
 40 
 41 #define NET_FS_PERMS (AA_MAY_SEND | AA_MAY_RECEIVE | AA_MAY_CREATE |    \
 42                       AA_MAY_SHUTDOWN | AA_MAY_CONNECT | AA_MAY_RENAME |\
 43                       AA_MAY_SETATTR | AA_MAY_GETATTR | AA_MAY_CHMOD |  \
 44                       AA_MAY_CHOWN | AA_MAY_CHGRP | AA_MAY_LOCK |       \
 45                       AA_MAY_MPROT)
 46 
 47 #define NET_PEER_MASK (AA_MAY_SEND | AA_MAY_RECEIVE | AA_MAY_CONNECT |  \
 48                        AA_MAY_ACCEPT)
 49 struct aa_sk_ctx {
 50         struct aa_label *label;
 51         struct aa_label *peer;
 52 };
 53 
 54 static inline struct aa_sk_ctx *aa_sock(const struct sock *sk)
 55 {
 56         return sk->sk_security + apparmor_blob_sizes.lbs_sock;
 57 }
 58 
 59 #define DEFINE_AUDIT_NET(NAME, OP, SK, F, T, P)                           \
 60         struct lsm_network_audit NAME ## _net = { .sk = (SK),             \
 61                                                   .family = (F)};         \
 62         DEFINE_AUDIT_DATA(NAME,                                           \
 63                           ((SK) && (F) != AF_UNIX) ? LSM_AUDIT_DATA_NET : \
 64                                                      LSM_AUDIT_DATA_NONE, \
 65                                                      AA_CLASS_NET,        \
 66                           OP);                                            \
 67         NAME.common.u.net = &(NAME ## _net);                              \
 68         NAME.net.type = (T);                                              \
 69         NAME.net.protocol = (P)
 70 
 71 #define DEFINE_AUDIT_SK(NAME, OP, SK)                                   \
 72         DEFINE_AUDIT_NET(NAME, OP, SK, (SK)->sk_family, (SK)->sk_type,  \
 73                          (SK)->sk_protocol)
 74 
 75 
 76 #define af_select(FAMILY, FN, DEF_FN)           \
 77 ({                                              \
 78         int __e;                                \
 79         switch ((FAMILY)) {                     \
 80         default:                                \
 81                 __e = DEF_FN;                   \
 82         }                                       \
 83         __e;                                    \
 84 })
 85 
 86 struct aa_secmark {
 87         u8 audit;
 88         u8 deny;
 89         u32 secid;
 90         char *label;
 91 };
 92 
 93 extern struct aa_sfs_entry aa_sfs_entry_network[];
 94 
 95 void audit_net_cb(struct audit_buffer *ab, void *va);
 96 int aa_profile_af_perm(struct aa_profile *profile,
 97                        struct apparmor_audit_data *ad,
 98                        u32 request, u16 family, int type);
 99 int aa_af_perm(const struct cred *subj_cred, struct aa_label *label,
100                const char *op, u32 request, u16 family,
101                int type, int protocol);
102 static inline int aa_profile_af_sk_perm(struct aa_profile *profile,
103                                         struct apparmor_audit_data *ad,
104                                         u32 request,
105                                         struct sock *sk)
106 {
107         return aa_profile_af_perm(profile, ad, request, sk->sk_family,
108                                   sk->sk_type);
109 }
110 int aa_sk_perm(const char *op, u32 request, struct sock *sk);
111 
112 int aa_sock_file_perm(const struct cred *subj_cred, struct aa_label *label,
113                       const char *op, u32 request,
114                       struct socket *sock);
115 
116 int apparmor_secmark_check(struct aa_label *label, char *op, u32 request,
117                            u32 secid, const struct sock *sk);
118 
119 #endif /* __AA_NET_H */
120 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php