security/smack/smack.h

Source file repositories/reference/linux-study-clean/security/smack/smack.h

File Facts

System
Linux kernel
Corpus path
security/smack/smack.h
Extension
.h
Size
14474 bytes
Lines
542
Domain
Core OS
Bucket
Security And Isolation
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

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

struct superblock_smack {
	struct smack_known	*smk_root;
	struct smack_known	*smk_floor;
	struct smack_known	*smk_hat;
	struct smack_known	*smk_default;
	int			smk_flags;
};

/*
 * Superblock flags
 */
#define SMK_SB_INITIALIZED	0x01
#define SMK_SB_UNTRUSTED	0x02

struct socket_smack {
	struct smack_known	*smk_out;	/* outbound label */
	struct smack_known	*smk_in;	/* inbound label */
	struct smack_known	*smk_packet;	/* TCP peer label */
	int			smk_state;	/* netlabel socket states */
};
#define	SMK_NETLBL_UNSET	0
#define	SMK_NETLBL_UNLABELED	1
#define	SMK_NETLBL_LABELED	2
#define	SMK_NETLBL_REQSKB	3

/*
 * Inode smack data
 */
struct inode_smack {
	struct smack_known	*smk_inode;	/* label of the fso */
	struct smack_known	*smk_task;	/* label of the task */
	struct smack_known	*smk_mmap;	/* label of the mmap domain */
	int			smk_flags;	/* smack inode flags */
};

struct task_smack {
	struct smack_known	*smk_task;	/* label for access control */
	struct smack_known	*smk_forked;	/* label when forked */
	struct smack_known	*smk_transmuted;/* label when transmuted */
	struct list_head	smk_rules;	/* per task access rules */
	struct mutex		smk_rules_lock;	/* lock for the rules */
	struct list_head	smk_relabel;	/* transit allowed labels */
};

#define	SMK_INODE_INSTANT	0x01	/* inode is instantiated */
#define	SMK_INODE_TRANSMUTE	0x02	/* directory is transmuting */
#define	SMK_INODE_CHANGED	0x04	/* smack was transmuted (unused) */
#define	SMK_INODE_IMPURE	0x08	/* involved in an impure transaction */

/*
 * A label access rule.
 */
struct smack_rule {
	struct list_head	list;
	struct smack_known	*smk_subject;
	struct smack_known	*smk_object;
	int			smk_access;
};

/*
 * An entry in the table identifying IPv4 hosts.
 */
struct smk_net4addr {
	struct list_head	list;
	struct in_addr		smk_host;	/* network address */
	struct in_addr		smk_mask;	/* network mask */
	int			smk_masks;	/* mask size */
	struct smack_known	*smk_label;	/* label */
};

#if IS_ENABLED(CONFIG_IPV6)

Annotation

Implementation Notes