/* * Use IPv6 port labeling if IPv6 is enabled and secmarks * are not being used.
*/ #if IS_ENABLED(CONFIG_IPV6) && !defined(CONFIG_SECURITY_SMACK_NETFILTER) #define SMACK_IPV6_PORT_LABELING 1 #endif
/* * Smack labels were limited to 23 characters for a long time.
*/ #define SMK_LABELLEN 24 #define SMK_LONGLABEL 256
/* * This is the repository for labels seen so that it is * not necessary to keep allocating tiny chunks of memory * and so that they can be shared. * * Labels are never modified in place. Anytime a label * is imported (e.g. xattrset on a file) the list is checked * for it and it is added if it doesn't exist. The address * is passed out in either case. Entries are added, but * never deleted. * * Since labels are hanging around anyway it doesn't * hurt to maintain a secid for those awkward situations * where kernel components that ought to use LSM independent * interfaces don't. The secid should go away when all of * these components have been repaired. * * The cipso value associated with the label gets stored here, too. * * Keep the access rules for this subject label here so that * the entire set of rules does not need to be examined every * time.
*/ struct smack_known { struct list_head list; struct hlist_node smk_hashed; char *smk_known;
u32 smk_secid; struct netlbl_lsm_secattr smk_netlabel; /* on wire labels */ struct list_head smk_rules; /* access rules */ struct mutex smk_rules_lock; /* lock for rules */
};
/* * Maximum number of bytes for the levels in a CIPSO IP option. * Why 23? CIPSO is constrained to 30, so a 32 byte buffer is * bigger than can be used, and 24 is the next lower multiple * of 8, and there are too many issues if there isn't space set * aside for the terminating null byte.
*/ #define SMK_CIPSOLEN 24
/* * CIPSO defaults.
*/ #define SMACK_CIPSO_DOI_DEFAULT 3 /* Historical */ #define SMACK_CIPSO_DOI_INVALID -1 /* Not a DOI */ #define SMACK_CIPSO_DIRECT_DEFAULT 250 /* Arbitrary */ #define SMACK_CIPSO_MAPPED_DEFAULT 251 /* Also arbitrary */ #define SMACK_CIPSO_MAXLEVEL 255 /* CIPSO 2.2 standard */ /* * CIPSO 2.2 standard is 239, but Smack wants to use the * categories in a structured way that limits the value to * the bits in 23 bytes, hence the unusual number.
*/ #define SMACK_CIPSO_MAXCATNUM 184 /* 23 * 8 */
/* * Flags for untraditional access modes. * It shouldn't be necessary to avoid conflicts with definitions * in fs.h, but do so anyway.
*/ #define MAY_TRANSMUTE 0x00001000 /* Controls directory labeling */ #define MAY_LOCK 0x00002000 /* Locks should be writes, but ... */ #define MAY_BRINGUP 0x00004000 /* Report use of this rule */
/* * The policy for delivering signals is configurable. * It is usually "write", but can be "append".
*/ #ifdef CONFIG_SECURITY_SMACK_APPEND_SIGNALS #define MAY_DELIVER MAY_APPEND /* Signal delivery requires append */ #else #define MAY_DELIVER MAY_WRITE /* Signal delivery requires write */ #endif
/* * Just to make the common cases easier to deal with
*/ #define MAY_ANYREAD (MAY_READ | MAY_EXEC) #define MAY_READWRITE (MAY_READ | MAY_WRITE) #define MAY_NOT 0
/* * Number of access types used by Smack (rwxatlb)
*/ #define SMK_NUM_ACCESS_TYPE 7
/* SMACK data */ struct smack_audit_data { constchar *function; char *subject; char *object; char *request; int result;
};
/* * Smack audit data; is empty if CONFIG_AUDIT not set * to save some stack
*/ struct smk_audit_info { #ifdef CONFIG_AUDIT struct common_audit_data a; struct smack_audit_data sad; #endif
};
/* * These functions are in smack_access.c
*/ int smk_access_entry(char *, char *, struct list_head *); int smk_access(struct smack_known *, struct smack_known *, int, struct smk_audit_info *); int smk_tskacc(struct task_smack *, struct smack_known *,
u32, struct smk_audit_info *); int smk_curacc(struct smack_known *, u32, struct smk_audit_info *); int smack_str_from_perm(char *string, int access); struct smack_known *smack_from_secid(const u32); char *smk_parse_smack(constchar *string, int len); int smk_netlbl_mls(int, char *, struct netlbl_lsm_secattr *, int); struct smack_known *smk_import_entry(constchar *, int); void smk_insert_entry(struct smack_known *skp); struct smack_known *smk_find_entry(constchar *); bool smack_privileged(int cap); bool smack_privileged_cred(int cap, conststruct cred *cred); void smk_destroy_label_list(struct list_head *list); int smack_populate_secattr(struct smack_known *skp);
/* * Present a pointer to the smack label entry in an inode blob.
*/ staticinlinestruct smack_known *smk_of_inode(conststruct inode *isp)
{ struct inode_smack *sip = smack_inode(isp); return sip->smk_inode;
}
/* * Present a pointer to the smack label entry in an task blob.
*/ staticinlinestruct smack_known *smk_of_task(conststruct task_smack *tsp)
{ return tsp->smk_task;
}
/* * Present a pointer to the forked smack label entry in an task blob.
*/ staticinlinestruct smack_known *smk_of_forked(conststruct task_smack *tsp)
{ return tsp->smk_forked;
}
/* * Present a pointer to the smack label in the current task blob.
*/ staticinlinestruct smack_known *smk_of_current(void)
{ return smk_of_task(smack_cred(current_cred()));
}
void smack_log(char *subject_label, char *object_label, int request, int result, struct smk_audit_info *auditdata);
/* * some inline functions to set up audit data * they do nothing if CONFIG_AUDIT is not set *
*/ staticinlinevoid smk_ad_init(struct smk_audit_info *a, constchar *func, char type)
{
memset(&a->sad, 0, sizeof(a->sad));
a->a.type = type;
a->a.smack_audit_data = &a->sad;
a->a.smack_audit_data->function = func;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.