Projectname large_stringclasses 15
values | Filepath large_stringlengths 4 106 ⌀ | Function large_stringlengths 11 3.45k | Label list |
|---|---|---|---|
Linux Kernel | security/selinux/netlabel.c | static inline int selinux_netlbl_option(int level, int optname) {
return (level == IPPROTO_IP && optname == IP_OPTIONS) ||
(level == IPPROTO_IPV6 && optname == IPV6_HOPOPTS);
} | [
0,
0
] |
Linux Kernel | security/selinux/netlabel.c | int selinux_netlbl_socket_setsockopt(struct socket *sock, int level,
int optname) {
int rc = 0;
struct sock *sk = sock->sk;
struct sk_security_struct *sksec = sk->sk_security;
struct netlbl_lsm_secattr secattr;
if (selinux_netlbl_option(level, optname) &&
(sksec->nl... | [
0,
0
] |
Linux Kernel | security/selinux/netlabel.c | static int selinux_netlbl_socket_connect_helper(struct sock *sk,
struct sockaddr *addr) {
int rc;
struct sk_security_struct *sksec = sk->sk_security;
struct netlbl_lsm_secattr *secattr;
if (addr->sa_family == AF_UNSPEC) {
netlbl_sock_delattr(sk);
sksec->n... | [
0,
0
] |
Linux Kernel | security/selinux/netnode.c | static unsigned int sel_netnode_hashfn_ipv4(__be32 addr) {
return (addr & (SEL_NETNODE_HASH_SIZE - 1));
} | [
0,
0
] |
Linux Kernel | security/selinux/netnode.c | static struct sel_netnode *sel_netnode_find(const void *addr, u16 family) {
unsigned int idx;
struct sel_netnode *node;
switch (family) {
case PF_INET:
idx = sel_netnode_hashfn_ipv4(*(const __be32 *)addr);
break;
case PF_INET6:
idx = sel_netnode_hashfn_ipv6(addr);
break;
default:
BUG();... | [
1,
0
] |
Linux Kernel | security/selinux/netnode.c | void sel_netnode_flush(void) {
unsigned int idx;
struct sel_netnode *node, *node_tmp;
spin_lock_bh(&sel_netnode_lock);
for (idx = 0; idx < SEL_NETNODE_HASH_SIZE; idx++) {
list_for_each_entry_safe(node, node_tmp, &sel_netnode_hash[idx].list,
list) {
list_del_rcu(&node->lis... | [
0,
0
] |
Linux Kernel | security/selinux/netport.c | static unsigned int sel_netport_hashfn(u16 pnum) {
return (pnum & (SEL_NETPORT_HASH_SIZE - 1));
} | [
0,
0
] |
Linux Kernel | security/selinux/netport.c | static struct sel_netport *sel_netport_find(u8 protocol, u16 pnum) {
unsigned int idx;
struct sel_netport *port;
idx = sel_netport_hashfn(pnum);
list_for_each_entry_rcu(port, &sel_netport_hash[idx].list,
list) if (port->psec.port == pnum &&
port->ps... | [
1,
0
] |
Linux Kernel | security/selinux/netport.c | static void sel_netport_insert(struct sel_netport *port) {
unsigned int idx;
idx = sel_netport_hashfn(port->psec.port);
list_add_rcu(&port->list, &sel_netport_hash[idx].list);
if (sel_netport_hash[idx].size == SEL_NETPORT_HASH_BKT_LIMIT) {
struct sel_netport *tail;
tail = list_entry(
rcu_derefe... | [
0,
0
] |
Linux Kernel | security/selinux/netport.c | void sel_netport_flush(void) {
unsigned int idx;
struct sel_netport *port, *port_tmp;
spin_lock_bh(&sel_netport_lock);
for (idx = 0; idx < SEL_NETPORT_HASH_SIZE; idx++) {
list_for_each_entry_safe(port, port_tmp, &sel_netport_hash[idx].list,
list) {
list_del_rcu(&port->lis... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c | static ssize_t sel_read_enforce(struct file *filp, char __user *buf,
size_t count, loff_t *ppos) {
struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info;
char tmpbuf[TMPBUFLEN];
ssize_t length;
length = scnprintf(tmpbuf, TMPBUFLEN, "%d", enforcing_enabled(fsi->state));... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static ssize_t sel_read_handle_unknown(struct file *filp, char __user *buf,
size_t count, loff_t *ppos) {
struct selinux_fs_info *fsi = file_inode(filp)->i_sb->s_fs_info;
struct selinux_state *state = fsi->state;
char tmpbuf[TMPBUFLEN];
ssize_t length;
ino_t ino = file_... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static ssize_t sel_read_handle_status(struct file *filp, char __user *buf,
size_t count, loff_t *ppos) {
struct page *status = filp->private_data;
BUG_ON(!status);
return simple_read_from_buffer(buf, count, ppos, page_address(status),
sizeo... | [
1,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static int sel_release_policy(struct inode *inode, struct file *filp) {
struct selinux_fs_info *fsi = inode->i_sb->s_fs_info;
struct policy_load_memory *plm = filp->private_data;
BUG_ON(!plm);
fsi->policy_opened = 0;
vfree(plm->data);
kfree(plm);
return 0;
} | [
1,
0
] |
Linux Kernel | security/selinux/selinuxfs.c | static ssize_t sel_write_load(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)
{
struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info;
struct selinux_load_state load_state;
ssize_t length;
void *data = NULL;
mutex_lock(&fsi->state->policy_mutex)... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static ssize_t selinux_transaction_write(struct file *file,
const char __user *buf, size_t size,
loff_t *pos) {
ino_t ino = file_inode(file)->i_ino;
char *data;
ssize_t rv;
if (ino >= ARRAY_SIZE(write_op) || !write_op[ino])
... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static int sel_avc_stats_seq_show(struct seq_file *seq, void *v) {
struct avc_cache_stats *st = v;
if (v == SEQ_START_TOKEN) {
seq_puts(seq, "lookups hits misses allocations reclaims frees\n");
} else {
unsigned int lookups = st->lookups;
unsigned int misses = st->misses;
unsigned int hits = loo... | [
1,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static int sel_make_avc_files(struct dentry *dir) {
struct super_block *sb = dir->d_sb;
struct selinux_fs_info *fsi = sb->s_fs_info;
int i;
static const struct tree_descr files[] = {
{"cache_threshold", &sel_avc_cache_threshold_ops, S_IRUGO | S_IWUSR},
{"hash_stats", &sel_avc_hash_stats_ops, S_IRUG... | [
1,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static ssize_t sel_read_initcon(struct file *file, char __user *buf,
size_t count, loff_t *ppos) {
struct selinux_fs_info *fsi = file_inode(file)->i_sb->s_fs_info;
char *con;
u32 sid, len;
ssize_t ret;
sid = file_inode(file)->i_ino & SEL_INO_MASK;
ret = security_sid_to_cont... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static ssize_t sel_read_perm(struct file *file, char __user *buf, size_t count,
loff_t *ppos) {
unsigned long ino = file_inode(file)->i_ino;
char res[TMPBUFLEN];
ssize_t len = scnprintf(res, sizeof(res), "%d", sel_ino_to_perm(ino));
return simple_read_from_buffer(buf, count, ppos, ... | [
1,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static int sel_make_policycap(struct selinux_fs_info *fsi) {
unsigned int iter;
struct dentry *dentry = NULL;
struct inode *inode = NULL;
for (iter = 0; iter <= POLICYDB_CAP_MAX; iter++) {
if (iter < ARRAY_SIZE(selinux_policycap_names))
dentry = d_alloc_name(fsi->policycap_dir, selinux_policycap_nam... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c | static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
unsigned long *ino) {
struct dentry *dentry = d_alloc_name(dir, name);
struct inode *inode;
if (!dentry)
return ERR_PTR(-ENOMEM);
inode = sel_make_inode(dir->d_sb, S_IFDIR | S_IRUGO | S_IXUGO);
if... | [
0,
0
] |
Linux Kernel | security/selinux/selinuxfs.c |
static int sel_init_fs_context(struct fs_context *fc) {
fc->ops = &sel_context_ops;
return 0;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/avtab.c |
static struct avtab_node *avtab_insert_node(struct avtab *h, int hvalue,
struct avtab_node *prev,
const struct avtab_key *key,
const struct avtab_datum *datum) {
struct avtab_node *newn... | [
0,
0
] |
Linux Kernel | security/selinux/ss/avtab.c | struct avtab_node *avtab_search_node(struct avtab *h,
const struct avtab_key *key) {
int hvalue;
struct avtab_node *cur;
u16 specified = key->specified & ~(AVTAB_ENABLED | AVTAB_ENABLED_OLD);
if (!h || !h->nslot)
return NULL;
hvalue = avtab_hash(key, h->mask);
for ... | [
0,
0
] |
Linux Kernel | security/selinux/ss/avtab.c |
int avtab_alloc(struct avtab *h, u32 nrules) {
int rc;
u32 nslot = 0;
if (nrules != 0) {
u32 shift = 1;
u32 work = nrules >> 3;
while (work) {
work >>= 1;
shift++;
}
nslot = 1 << shift;
if (nslot > MAX_AVTAB_HASH_BUCKETS)
nslot = MAX_AVTAB_HASH_BUCKETS;
rc = avtab_... | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c | static int cond_evaluate_expr(struct policydb *p, struct cond_expr *expr) {
u32 i;
int s[COND_EXPR_MAXDEPTH];
int sp = -1;
if (expr->len == 0)
return -1;
for (i = 0; i < expr->len; i++) {
struct cond_expr_node *node = &expr->nodes[i];
switch (node->expr_type) {
case COND_BOOL:
if (sp ... | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c | static void evaluate_cond_node(struct policydb *p, struct cond_node *node) {
struct avtab_node *avnode;
int new_state;
u32 i;
new_state = cond_evaluate_expr(p, &node->expr);
if (new_state != node->cur_state) {
node->cur_state = new_state;
if (new_state == -1)
pr_err(
"SELinux: express... | [
0,
0
] |
Linux Kernel | security/selinux/ss/conditional.c |
void cond_policydb_destroy(struct policydb *p) {
kfree(p->bool_val_to_struct);
avtab_destroy(&p->te_cond_avtab);
cond_list_destroy(p);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/conditional.c |
int cond_init_bool_indexes(struct policydb *p) {
kfree(p->bool_val_to_struct);
p->bool_val_to_struct = kmalloc_array(
p->p_bools.nprim, sizeof(*p->bool_val_to_struct), GFP_KERNEL);
if (!p->bool_val_to_struct)
return -ENOMEM;
return 0;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c |
static int bool_isvalid(struct cond_bool_datum *b) {
if (!(b->state == 0 || b->state == 1))
return 0;
return 1;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c | static int cond_read_node(struct policydb *p, struct cond_node *node,
void *fp) {
__le32 buf[2];
u32 i, len;
int rc;
rc = next_entry(buf, fp, sizeof(u32) * 2);
if (rc)
return rc;
node->cur_state = le32_to_cpu(buf[0]);
len = le32_to_cpu(buf[1]);
node->expr.nodes = kcalloc... | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c | static int cond_write_av_list(struct policydb *p, struct cond_av_list *list,
struct policy_file *fp) {
__le32 buf[1];
u32 i;
int rc;
buf[0] = cpu_to_le32(list->len);
rc = put_entry(buf, sizeof(u32), 1, fp);
if (rc)
return rc;
for (i = 0; i < list->len; i++) {
rc = a... | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c | static int cond_bools_copy(struct hashtab_node *new, struct hashtab_node *orig,
void *args) {
struct cond_bool_datum *datum;
datum = kmemdup(orig->datum, sizeof(struct cond_bool_datum), GFP_KERNEL);
if (!datum)
return -ENOMEM;
new->key = orig->key;
new->datum = datum;
return... | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c |
static int duplicate_policydb_bools(struct policydb *newdb,
struct policydb *orig) {
struct cond_bool_datum **cond_bool_array;
int rc;
cond_bool_array = kmalloc_array(
orig->p_bools.nprim, sizeof(*orig->bool_val_to_struct), GFP_KERNEL);
if (!cond_bool_array)
retur... | [
1,
0
] |
Linux Kernel | security/selinux/ss/conditional.c |
int cond_policydb_dup(struct policydb *new, struct policydb *orig) {
cond_policydb_init(new);
if (duplicate_policydb_bools(new, orig))
return -ENOMEM;
if (duplicate_policydb_cond_list(new, orig)) {
cond_policydb_destroy_dup(new);
return -ENOMEM;
}
return 0;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/context.h |
static inline void context_init(struct context *c) { memset(c, 0, sizeof(*c)); } | [
1,
0
] |
Linux Kernel | security/selinux/ss/context.h |
static inline int context_cpy(struct context *dst, const struct context *src) {
int rc;
dst->user = src->user;
dst->role = src->role;
dst->type = src->type;
if (src->str) {
dst->str = kstrdup(src->str, GFP_ATOMIC);
if (!dst->str)
return -ENOMEM;
dst->len = src->len;
} else {
dst->str... | [
0,
0
] |
Linux Kernel | security/selinux/ss/context.h |
static inline void context_destroy(struct context *c) {
c->user = c->role = c->type = 0;
kfree(c->str);
c->str = NULL;
c->len = 0;
mls_context_destroy(c);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/ebitmap.c | int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value) {
struct ebitmap_node *n, *prev, *new;
prev = NULL;
n = e->node;
while (n && n->startbit <= bit) {
if ((n->startbit + EBITMAP_SIZE) > bit) {
if (value) {
ebitmap_node_set_bit(n, bit);
} else {
unsigned int s;
... | [
1,
0
] |
Linux Kernel | security/selinux/ss/ebitmap.c |
void ebitmap_destroy(struct ebitmap *e) {
struct ebitmap_node *n, *temp;
if (!e)
return;
n = e->node;
while (n) {
temp = n;
n = n->next;
kmem_cache_free(ebitmap_node_cachep, temp);
}
e->highbit = 0;
e->node = NULL;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/ebitmap.c |
void __init ebitmap_cache_init(void) {
ebitmap_node_cachep = kmem_cache_create(
"ebitmap_node", sizeof(struct ebitmap_node), 0, SLAB_PANIC, NULL);
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/ebitmap.h |
static inline void ebitmap_init(struct ebitmap *e) { memset(e, 0, sizeof(*e)); } | [
1,
0
] |
Linux Kernel | security/selinux/ss/ebitmap.h |
static inline void ebitmap_node_set_bit(struct ebitmap_node *n,
unsigned int bit) {
unsigned int index = EBITMAP_NODE_INDEX(n, bit);
unsigned int ofs = EBITMAP_NODE_OFFSET(n, bit);
BUG_ON(index >= EBITMAP_UNIT_NUMS);
n->maps[index] |= (EBITMAP_BIT << ofs);
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/hashtab.c | int hashtab_init(struct hashtab *h, u32 nel_hint) {
u32 size = hashtab_compute_size(nel_hint);
h->nel = 0;
h->size = 0;
h->htable = NULL;
if (size) {
h->htable = kcalloc(size, sizeof(*h->htable), GFP_KERNEL);
if (!h->htable)
return -ENOMEM;
h->size = size;
}
return 0;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/hashtab.c |
int hashtab_duplicate(struct hashtab *new, struct hashtab *orig,
int (*copy)(struct hashtab_node *new,
struct hashtab_node *orig, void *args),
int (*destroy)(void *k, void *d, void *args),
void *args) {
struct hashtab... | [
1,
0
] |
Linux Kernel | security/selinux/ss/mls.c |
int mls_range_isvalid(struct policydb *p, struct mls_range *r) {
return (mls_level_isvalid(p, &r->level[0]) &&
mls_level_isvalid(p, &r->level[1]) &&
mls_level_dom(&r->level[1], &r->level[0]));
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/mls.c | int mls_context_isvalid(struct policydb *p, struct context *c) {
struct user_datum *usrdatum;
if (!p->mls_enabled)
return 1;
if (!mls_range_isvalid(p, &c->range))
return 0;
if (c->role == OBJECT_R_VAL)
return 1;
if (!c->user || c->user > p->p_users.nprim)
return 0;
usrdatum = p->user_val... | [
1,
0
] |
Linux Kernel | security/selinux/ss/mls.c | int mls_from_string(struct policydb *p, char *str, struct context *context,
gfp_t gfp_mask) {
char *tmpstr;
int rc;
if (!p->mls_enabled)
return -EINVAL;
tmpstr = kstrdup(str, gfp_mask);
if (!tmpstr) {
rc = -ENOMEM;
} else {
rc = mls_context_to_sid(p, ':', tmpstr, context, N... | [
0,
0
] |
Linux Kernel | security/selinux/ss/mls.c | int mls_compute_sid(struct policydb *p, struct context *scontext,
struct context *tcontext, u16 tclass, u32 specified,
struct context *newcontext, bool sock) {
struct range_trans rtr;
struct mls_range *r;
struct class_datum *cladatum;
int default_range = 0;
if (!p->mls... | [
1,
0
] |
Linux Kernel | security/selinux/ss/mls.c | int mls_import_netlbl_cat(struct policydb *p, struct context *context,
struct netlbl_lsm_secattr *secattr) {
int rc;
if (!p->mls_enabled)
return 0;
rc = ebitmap_netlbl_import(&context->range.level[0].cat,
secattr->attr.mls.cat);
if (rc)
goto impor... | [
1,
0
] |
Linux Kernel | security/selinux/ss/mls.h | static inline void mls_import_netlbl_lvl(struct policydb *p,
struct context *context,
struct netlbl_lsm_secattr *secattr) {
return;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/mls.h | static inline int mls_export_netlbl_cat(struct policydb *p,
struct context *context,
struct netlbl_lsm_secattr *secattr) {
return -ENOMEM;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/mls_types.h |
static inline int mls_level_dom(const struct mls_level *l1,
const struct mls_level *l2) {
return ((l1->sens >= l2->sens) && ebitmap_contains(&l1->cat, &l2->cat, 0));
}
#define mls_level_incomp(l1, l2) \
(!mls_level_dom((l1), (l2)) && !m... | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int cls_destroy(void *key, void *datum, void *p) {
struct class_datum *cladatum;
struct constraint_node *constraint, *ctemp;
struct constraint_expr *e, *etmp;
kfree(key);
if (datum) {
cladatum = datum;
hashtab_map(&cladatum->permissions.table, perm_destroy, NULL);
hashtab_destroy(&cladatu... | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int role_destroy(void *key, void *datum, void *p) {
struct role_datum *role;
kfree(key);
if (datum) {
role = datum;
ebitmap_destroy(&role->dominates);
ebitmap_destroy(&role->types);
}
kfree(datum);
return 0;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int sens_destroy(void *key, void *datum, void *p) {
struct level_datum *levdatum;
kfree(key);
if (datum) {
levdatum = datum;
if (levdatum->level)
ebitmap_destroy(&levdatum->level->cat);
kfree(levdatum->level);
}
kfree(datum);
return 0;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int filenametr_destroy(void *key, void *datum, void *p) {
struct filename_trans_key *ft = key;
struct filename_trans_datum *next, *d = datum;
kfree(ft->name);
kfree(key);
do {
ebitmap_destroy(&d->stypes);
next = d->next;
kfree(d);
d = next;
} while (unlikely(d));
cond_resched();
... | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int role_tr_destroy(void *key, void *datum, void *p) {
kfree(key);
kfree(datum);
return 0;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static void ocontext_destroy(struct ocontext *c, int i) {
if (!c)
return;
context_destroy(&c->context[0]);
context_destroy(&c->context[1]);
if (i == OCON_ISID || i == OCON_FS || i == OCON_NETIF || i == OCON_FSUSE)
kfree(c->u.name);
kfree(c);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
struct filename_trans_datum *
policydb_filenametr_search(struct policydb *p, struct filename_trans_key *key) {
return hashtab_search(&p->filename_trans, key, filenametr_key_params);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int rangetr_cmp(const void *k1, const void *k2) {
const struct range_trans *key1 = k1, *key2 = k2;
int v;
v = key1->source_type - key2->source_type;
if (v)
return v;
v = key1->target_type - key2->target_type;
if (v)
return v;
v = key1->target_class - key2->target_class;
return v;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/policydb.c | static int common_index(void *key, void *datum, void *datap) {
struct policydb *p;
struct common_datum *comdatum;
comdatum = datum;
p = datap;
if (!comdatum->value || comdatum->value > p->p_commons.nprim)
return -EINVAL;
p->sym_val_to_name[SYM_COMMONS][comdatum->value - 1] = key;
return 0;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int role_index(void *key, void *datum, void *datap) {
struct policydb *p;
struct role_datum *role;
role = datum;
p = datap;
if (!role->value || role->value > p->p_roles.nprim ||
role->bounds > p->p_roles.nprim)
return -EINVAL;
p->sym_val_to_name[SYM_ROLES][role->value - 1] = key;
p->ro... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int sens_index(void *key, void *datum, void *datap) {
struct policydb *p;
struct level_datum *levdatum;
levdatum = datum;
p = datap;
if (!levdatum->isalias) {
if (!levdatum->level->sens || levdatum->level->sens > p->p_levels.nprim)
return -EINVAL;
p->sym_val_to_name[SYM_LEVELS][levdat... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
int policydb_type_isvalid(struct policydb *p, unsigned int type) {
if (!type || type > p->p_types.nprim)
return 0;
return 1;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c | static int mls_read_range_helper(struct mls_range *r, void *fp) {
__le32 buf[2];
u32 items;
int rc;
rc = next_entry(buf, fp, sizeof(u32));
if (rc)
goto out;
rc = -EINVAL;
items = le32_to_cpu(buf[0]);
if (items > ARRAY_SIZE(buf)) {
pr_err("SELinux: mls: range overflow\n");
goto out;
}
... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c | static int mls_read_level(struct mls_level *lp, void *fp) {
__le32 buf[1];
int rc;
memset(lp, 0, sizeof(*lp));
rc = next_entry(buf, fp, sizeof buf);
if (rc) {
pr_err("SELinux: mls: truncated level\n");
return rc;
}
lp->sens = le32_to_cpu(buf[0]);
rc = ebitmap_read(&lp->cat, fp);
if (rc) {
... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int user_read(struct policydb *p, struct symtab *s, void *fp) {
char *key = NULL;
struct user_datum *usrdatum;
int rc, to_read = 2;
__le32 buf[3];
u32 len;
usrdatum = kzalloc(sizeof(*usrdatum), GFP_KERNEL);
if (!usrdatum)
return -ENOMEM;
if (p->policyvers >= POLICYDB_VERSION_BOUNDARY)
... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int user_bounds_sanity_check(void *key, void *datum, void *datap) {
struct user_datum *upper, *user;
struct policydb *p = datap;
int depth = 0;
upper = user = datum;
while (upper->bounds) {
struct ebitmap_node *node;
unsigned long bit;
if (++depth == POLICYDB_BOUNDS_MAXDEPTH) {
pr_... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c | static int mls_write_level(struct mls_level *l, void *fp) {
__le32 buf[1];
int rc;
buf[0] = cpu_to_le32(l->sens);
rc = put_entry(buf, sizeof(u32), 1, fp);
if (rc)
return rc;
rc = ebitmap_write(&l->cat, fp);
if (rc)
return rc;
return 0;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c | static int mls_write_range_helper(struct mls_range *r, void *fp) {
__le32 buf[3];
size_t items;
int rc, eq;
eq = mls_level_eq(&r->level[1], &r->level[0]);
if (eq)
items = 2;
else
items = 3;
buf[0] = cpu_to_le32(items - 1);
buf[1] = cpu_to_le32(r->level[0].sens);
if (!eq)
buf[2] = cpu_to_... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int type_set_write(struct type_set *t, void *fp) {
int rc;
__le32 buf[1];
if (ebitmap_write(&t->types, fp))
return -EINVAL;
if (ebitmap_write(&t->negset, fp))
return -EINVAL;
buf[0] = cpu_to_le32(t->flags);
rc = put_entry(buf, sizeof(u32), 1, fp);
if (rc)
return -EINVAL;
return 0;... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c | static int range_write(struct policydb *p, void *fp) {
__le32 buf[1];
int rc;
struct policy_data pd;
pd.p = p;
pd.fp = fp;
buf[0] = cpu_to_le32(p->range_tr.nel);
rc = put_entry(buf, sizeof(u32), 1, fp);
if (rc)
return rc;
rc = hashtab_map(&p->range_tr, range_write_helper, &pd);
if (rc)
re... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.c |
static int filename_write_helper(void *key, void *data, void *ptr) {
struct filename_trans_key *ft = key;
struct filename_trans_datum *datum;
void *fp = ptr;
__le32 buf[3];
int rc;
u32 ndatum, len = strlen(ft->name);
buf[0] = cpu_to_le32(len);
rc = put_entry(buf, sizeof(u32), 1, fp);
if (rc)
ret... | [
1,
0
] |
Linux Kernel | security/selinux/ss/policydb.h |
static inline char *sym_name(struct policydb *p, unsigned int sym_num,
unsigned int element_nr) {
return p->sym_val_to_name[sym_num][element_nr];
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c | static void map_decision(struct selinux_map *map, u16 tclass,
struct av_decision *avd, int allow_unknown) {
if (tclass < map->size) {
struct selinux_mapping *mapping = &map->mapping[tclass];
unsigned int i, n = mapping->num_perms;
u32 result;
for (i = 0, result = 0; i < n; i+... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c | static void type_attribute_bounds_av(struct policydb *policydb,
struct context *scontext,
struct context *tcontext, u16 tclass,
struct av_decision *avd) {
struct context lo_scontext;
struct context lo_tcon... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static void avd_init(struct selinux_policy *policy, struct av_decision *avd) {
avd->allowed = 0;
avd->auditallow = 0;
avd->auditdeny = 0xffffffff;
if (policy)
avd->seqno = policy->latest_granting;
else
avd->seqno = 0;
avd->flags = 0;
} | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c | void security_compute_av(struct selinux_state *state, u32 ssid, u32 tsid,
u16 orig_tclass, struct av_decision *avd,
struct extended_perms *xperms) {
struct selinux_policy *policy;
struct policydb *policydb;
struct sidtab *sidtab;
u16 tclass;
struct context *sc... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c | static int context_struct_to_string(struct policydb *p, struct context *context,
char **scontext, u32 *scontext_len) {
char *scontextp;
if (scontext)
*scontext = NULL;
*scontext_len = 0;
if (context->len) {
*scontext_len = context->len;
if (scontext) {
*sc... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c | int security_sid_to_context(struct selinux_state *state, u32 sid,
char **scontext, u32 *scontext_len) {
return security_sid_to_context_core(state, sid, scontext, scontext_len, 0, 0);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
int security_sid_to_context_force(struct selinux_state *state, u32 sid,
char **scontext, u32 *scontext_len) {
return security_sid_to_context_core(state, sid, scontext, scontext_len, 1, 0);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c | static int string_to_context_struct(struct policydb *pol,
struct sidtab *sidtabp, char *scontext,
struct context *ctx, u32 def_sid) {
struct role_datum *role;
struct type_datum *typdatum;
struct user_datum *usrdatum;
char *scontextp, *p, ol... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c | static int compute_sid_handle_invalid_context(struct selinux_state *state,
struct selinux_policy *policy,
struct sidtab_entry *sentry,
struct sidtab_entry *tentry,
... | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c | int security_transition_sid(struct selinux_state *state, u32 ssid, u32 tsid,
u16 tclass, const struct qstr *qstr, u32 *out_sid) {
return security_compute_sid(state, ssid, tsid, tclass, AVTAB_TRANSITION,
qstr ? qstr->name : NULL, out_sid, true);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
int security_transition_sid_user(struct selinux_state *state, u32 ssid,
u32 tsid, u16 tclass, const char *objname,
u32 *out_sid) {
return security_compute_sid(state, ssid, tsid, tclass, AVTAB_TRANSITION,
objname, out_sid,... | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static inline int
convert_context_handle_invalid_context(struct selinux_state *state,
struct policydb *policydb,
struct context *context) {
char *s;
u32 len;
if (enforcing_enabled(state))
return -EINVAL;
if (!context_struct_to_... | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static void security_load_policycaps(struct selinux_state *state,
struct selinux_policy *policy) {
struct policydb *p;
unsigned int i;
struct ebitmap_node *node;
p = &policy->policydb;
for (i = 0; i < ARRAY_SIZE(state->policycap); i++)
WRITE_ONCE(state->policycap[i]... | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static void selinux_policy_free(struct selinux_policy *policy) {
if (!policy)
return;
sidtab_destroy(policy->sidtab);
kfree(policy->map.mapping);
policydb_destroy(&policy->policydb);
kfree(policy->sidtab);
kfree(policy);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static void selinux_policy_cond_free(struct selinux_policy *policy) {
cond_policydb_destroy_dup(&policy->policydb);
kfree(policy);
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
void selinux_policy_cancel(struct selinux_state *state,
struct selinux_load_state *load_state) {
struct selinux_policy *oldpolicy;
oldpolicy = rcu_dereference_protected(state->policy,
lockdep_is_held(&state->policy_mutex));
sidtab_cancel_conver... | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static int match_ipv6_addrmask(u32 *input, u32 *addr, u32 *mask) {
int i, fail = 0;
for (i = 0; i < 4; i++)
if (addr[i] != (input[i] & mask[i])) {
fail = 1;
break;
}
return !fail;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c | int security_node_sid(struct selinux_state *state, u16 domain, void *addrp,
u32 addrlen, u32 *out_sid) {
struct selinux_policy *policy;
struct policydb *policydb;
struct sidtab *sidtab;
int rc;
struct ocontext *c;
if (!selinux_initialized(state)) {
*out_sid = SECINITSID_NODE;
... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c |
int security_get_bools(struct selinux_policy *policy, u32 *len, char ***names,
int **values) {
struct policydb *policydb;
u32 i;
int rc;
policydb = &policy->policydb;
*names = NULL;
*values = NULL;
rc = 0;
*len = policydb->p_bools.nprim;
if (!*len)
goto out;
rc = -ENO... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c |
int security_get_classes(struct selinux_policy *policy, char ***classes,
int *nclasses) {
struct policydb *policydb;
int rc;
policydb = &policy->policydb;
rc = -ENOMEM;
*nclasses = policydb->p_classes.nprim;
*classes = kcalloc(*nclasses, sizeof(**classes), GFP_ATOMIC);
if (!*cl... | [
1,
0
] |
Linux Kernel | security/selinux/ss/services.c |
static int get_permissions_callback(void *k, void *d, void *args) {
struct perm_datum *datum = d;
char *name = k, **perms = args;
int value = datum->value - 1;
perms[value] = kstrdup(name, GFP_ATOMIC);
if (!perms[value])
return -ENOMEM;
return 0;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c |
int security_get_reject_unknown(struct selinux_state *state) {
struct selinux_policy *policy;
int value;
if (!selinux_initialized(state))
return 0;
rcu_read_lock();
policy = rcu_dereference(state->policy);
value = policy->policydb.reject_unknown;
rcu_read_unlock();
return value;
} | [
0,
0
] |
Linux Kernel | security/selinux/ss/services.c | int selinux_audit_rule_known(struct audit_krule *rule) {
int i;
for (i = 0; i < rule->field_count; i++) {
struct audit_field *f = &rule->fields[i];
switch (f->type) {
case AUDIT_SUBJ_USER:
case AUDIT_SUBJ_ROLE:
case AUDIT_SUBJ_TYPE:
case AUDIT_SUBJ_SEN:
case AUDIT_SUBJ_CLR:
case AUD... | [
1,
0
] |
Linux Kernel | security/selinux/ss/sidtab.c | int sidtab_set_initial(struct sidtab *s, u32 sid, struct context *context) {
struct sidtab_isid_entry *isid;
u32 hash;
int rc;
if (sid == 0 || sid > SECINITSID_NUM)
return -EINVAL;
isid = &s->isids[sid - 1];
rc = context_cpy(&isid->entry.context, context);
if (rc)
return rc;
#if CONFIG_SECURIT... | [
0,
0
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.