2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* An access vector table (avtab) is a hash table
|
|
|
|
* of access vectors and transition types indexed
|
|
|
|
* by a type pair and a class. An access vector
|
|
|
|
* table is used to represent the type enforcement
|
|
|
|
* tables.
|
|
|
|
*
|
|
|
|
* Author : Stephen Smalley, <sds@epoch.ncsc.mil>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Updated: Frank Mayer <mayerf@tresys.com> and Karl MacMillan <kmacmillan@tresys.com>
|
|
|
|
*
|
|
|
|
* Added conditional policy language extensions
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Tresys Technology, LLC
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
SELinux: Use dentry name in new object labeling
Currently SELinux has rules which label new objects according to 3 criteria.
The label of the process creating the object, the label of the parent
directory, and the type of object (reg, dir, char, block, etc.) This patch
adds a 4th criteria, the dentry name, thus we can distinguish between
creating a file in an etc_t directory called shadow and one called motd.
There is no file globbing, regex parsing, or anything mystical. Either the
policy exactly (strcmp) matches the dentry name of the object or it doesn't.
This patch has no changes from today if policy does not implement the new
rules.
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-02-02 00:05:40 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2005-04-17 06:20:36 +08:00
|
|
|
* the Free Software Foundation, version 2.
|
2007-08-24 10:55:11 +08:00
|
|
|
*
|
|
|
|
* Updated: Yuichi Nakamura <ynakam@hitachisoft.jp>
|
|
|
|
* Tuned number of hash slots for avtab to reduce memory usage
|
2005-04-17 06:20:36 +08:00
|
|
|
*/
|
|
|
|
#ifndef _SS_AVTAB_H_
|
|
|
|
#define _SS_AVTAB_H_
|
|
|
|
|
2015-07-11 05:19:56 +08:00
|
|
|
#include "security.h"
|
2015-03-25 04:54:16 +08:00
|
|
|
#include <linux/flex_array.h>
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
struct avtab_key {
|
2005-09-04 06:55:16 +08:00
|
|
|
u16 source_type; /* source type */
|
|
|
|
u16 target_type; /* target type */
|
|
|
|
u16 target_class; /* target object class */
|
SELinux: Use dentry name in new object labeling
Currently SELinux has rules which label new objects according to 3 criteria.
The label of the process creating the object, the label of the parent
directory, and the type of object (reg, dir, char, block, etc.) This patch
adds a 4th criteria, the dentry name, thus we can distinguish between
creating a file in an etc_t directory called shadow and one called motd.
There is no file globbing, regex parsing, or anything mystical. Either the
policy exactly (strcmp) matches the dentry name of the object or it doesn't.
This patch has no changes from today if policy does not implement the new
rules.
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-02-02 00:05:40 +08:00
|
|
|
#define AVTAB_ALLOWED 0x0001
|
|
|
|
#define AVTAB_AUDITALLOW 0x0002
|
|
|
|
#define AVTAB_AUDITDENY 0x0004
|
|
|
|
#define AVTAB_AV (AVTAB_ALLOWED | AVTAB_AUDITALLOW | AVTAB_AUDITDENY)
|
|
|
|
#define AVTAB_TRANSITION 0x0010
|
|
|
|
#define AVTAB_MEMBER 0x0020
|
|
|
|
#define AVTAB_CHANGE 0x0040
|
|
|
|
#define AVTAB_TYPE (AVTAB_TRANSITION | AVTAB_MEMBER | AVTAB_CHANGE)
|
2015-07-11 05:19:56 +08:00
|
|
|
/* extended permissions */
|
|
|
|
#define AVTAB_XPERMS_ALLOWED 0x0100
|
|
|
|
#define AVTAB_XPERMS_AUDITALLOW 0x0200
|
|
|
|
#define AVTAB_XPERMS_DONTAUDIT 0x0400
|
|
|
|
#define AVTAB_XPERMS (AVTAB_XPERMS_ALLOWED | \
|
|
|
|
AVTAB_XPERMS_AUDITALLOW | \
|
|
|
|
AVTAB_XPERMS_DONTAUDIT)
|
SELinux: Use dentry name in new object labeling
Currently SELinux has rules which label new objects according to 3 criteria.
The label of the process creating the object, the label of the parent
directory, and the type of object (reg, dir, char, block, etc.) This patch
adds a 4th criteria, the dentry name, thus we can distinguish between
creating a file in an etc_t directory called shadow and one called motd.
There is no file globbing, regex parsing, or anything mystical. Either the
policy exactly (strcmp) matches the dentry name of the object or it doesn't.
This patch has no changes from today if policy does not implement the new
rules.
Signed-off-by: Eric Paris <eparis@redhat.com>
2011-02-02 00:05:40 +08:00
|
|
|
#define AVTAB_ENABLED_OLD 0x80000000 /* reserved for used in cond_avtab */
|
|
|
|
#define AVTAB_ENABLED 0x8000 /* reserved for used in cond_avtab */
|
2005-09-04 06:55:16 +08:00
|
|
|
u16 specified; /* what field is specified */
|
|
|
|
};
|
|
|
|
|
2015-07-11 05:19:56 +08:00
|
|
|
/*
|
|
|
|
* For operations that require more than the 32 permissions provided by the avc
|
|
|
|
* extended permissions may be used to provide 256 bits of permissions.
|
|
|
|
*/
|
|
|
|
struct avtab_extended_perms {
|
|
|
|
/* These are not flags. All 256 values may be used */
|
|
|
|
#define AVTAB_XPERMS_IOCTLFUNCTION 0x01
|
|
|
|
#define AVTAB_XPERMS_IOCTLDRIVER 0x02
|
|
|
|
/* extension of the avtab_key specified */
|
|
|
|
u8 specified; /* ioctl, netfilter, ... */
|
|
|
|
/*
|
|
|
|
* if 256 bits is not adequate as is often the case with ioctls, then
|
|
|
|
* multiple extended perms may be used and the driver field
|
|
|
|
* specifies which permissions are included.
|
|
|
|
*/
|
|
|
|
u8 driver;
|
|
|
|
/* 256 bits of permissions */
|
|
|
|
struct extended_perms_data perms;
|
|
|
|
};
|
|
|
|
|
2005-09-04 06:55:16 +08:00
|
|
|
struct avtab_datum {
|
2015-07-11 05:19:56 +08:00
|
|
|
union {
|
|
|
|
u32 data; /* access vector or type value */
|
|
|
|
struct avtab_extended_perms *xperms;
|
|
|
|
} u;
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct avtab_node {
|
|
|
|
struct avtab_key key;
|
|
|
|
struct avtab_datum datum;
|
|
|
|
struct avtab_node *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct avtab {
|
2015-03-25 04:54:16 +08:00
|
|
|
struct flex_array *htable;
|
2005-04-17 06:20:36 +08:00
|
|
|
u32 nel; /* number of elements */
|
2007-08-24 10:55:11 +08:00
|
|
|
u32 nslot; /* number of hash slots */
|
2015-03-25 04:54:17 +08:00
|
|
|
u32 mask; /* mask to compute hash func */
|
2007-08-24 10:55:11 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
int avtab_init(struct avtab *);
|
2007-08-24 10:55:11 +08:00
|
|
|
int avtab_alloc(struct avtab *, u32);
|
2005-09-04 06:55:16 +08:00
|
|
|
struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k);
|
2005-04-17 06:20:36 +08:00
|
|
|
void avtab_destroy(struct avtab *h);
|
|
|
|
void avtab_hash_eval(struct avtab *h, char *tag);
|
|
|
|
|
2007-11-07 23:08:00 +08:00
|
|
|
struct policydb;
|
|
|
|
int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
|
2005-09-04 06:55:16 +08:00
|
|
|
int (*insert)(struct avtab *a, struct avtab_key *k,
|
|
|
|
struct avtab_datum *d, void *p),
|
|
|
|
void *p);
|
|
|
|
|
2007-11-07 23:08:00 +08:00
|
|
|
int avtab_read(struct avtab *a, void *fp, struct policydb *pol);
|
2010-10-14 05:50:25 +08:00
|
|
|
int avtab_write_item(struct policydb *p, struct avtab_node *cur, void *fp);
|
|
|
|
int avtab_write(struct policydb *p, struct avtab *a, void *fp);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_key *key,
|
|
|
|
struct avtab_datum *datum);
|
|
|
|
|
2005-09-04 06:55:16 +08:00
|
|
|
struct avtab_node *avtab_search_node(struct avtab *h, struct avtab_key *key);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
struct avtab_node *avtab_search_node_next(struct avtab_node *node, int specified);
|
|
|
|
|
|
|
|
void avtab_cache_init(void);
|
|
|
|
void avtab_cache_destroy(void);
|
|
|
|
|
2015-03-25 04:54:18 +08:00
|
|
|
#define MAX_AVTAB_HASH_BITS 16
|
2007-08-24 10:55:11 +08:00
|
|
|
#define MAX_AVTAB_HASH_BUCKETS (1 << MAX_AVTAB_HASH_BITS)
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#endif /* _SS_AVTAB_H_ */
|
|
|
|
|