Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 73245
b: refs/heads/master
c: 7351a22
h: refs/heads/master
i:
  73243: 1afbf9b
v: v3
  • Loading branch information
Alexey Dobriyan authored and David S. Miller committed Nov 7, 2007
1 parent 97a5448 commit c963b4e
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 169 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: eae1920a21b4f87e89cea802e7df39442b119617
refs/heads/master: 7351a22a3ae005422488139365e9a80f560c80b9
2 changes: 1 addition & 1 deletion trunk/arch/frv/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void __init mem_init(void)
/*
* free the memory that was only required for initialisation
*/
void free_initmem(void)
void __init free_initmem(void)
{
#if defined(CONFIG_RAMKERNEL) && !defined(CONFIG_PROTECT_KERNEL)
unsigned long start, end, addr;
Expand Down
11 changes: 4 additions & 7 deletions trunk/drivers/firewire/fw-sbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,13 @@ static void sbp2_login(struct work_struct *work)
if (sbp2_send_management_orb(lu, node_id, generation,
SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
if (lu->retries++ < 5) {
if (queue_delayed_work(sbp2_wq, &lu->work,
DIV_ROUND_UP(HZ, 5)))
kref_get(&lu->tgt->kref);
queue_delayed_work(sbp2_wq, &lu->work,
DIV_ROUND_UP(HZ, 5));
} else {
fw_error("failed to login to %s LUN %04x\n",
unit->device.bus_id, lu->lun);
kref_put(&lu->tgt->kref, sbp2_release_target);
}
kref_put(&lu->tgt->kref, sbp2_release_target);
return;
}

Expand Down Expand Up @@ -915,9 +914,7 @@ static void sbp2_reconnect(struct work_struct *work)
lu->retries = 0;
PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
}
if (queue_delayed_work(sbp2_wq, &lu->work, DIV_ROUND_UP(HZ, 5)))
kref_get(&lu->tgt->kref);
kref_put(&lu->tgt->kref, sbp2_release_target);
queue_delayed_work(sbp2_wq, &lu->work, DIV_ROUND_UP(HZ, 5));
return;
}

Expand Down
37 changes: 20 additions & 17 deletions trunk/net/ipv4/netfilter/ip_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/spinlock.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/security.h>
#include <linux/mutex.h>
#include <net/net_namespace.h>
Expand Down Expand Up @@ -607,15 +608,11 @@ static ctl_table ipq_root_table[] = {
{ .ctl_name = 0 }
};

#ifdef CONFIG_PROC_FS
static int
ipq_get_info(char *buffer, char **start, off_t offset, int length)
static int ip_queue_show(struct seq_file *m, void *v)
{
int len;

read_lock_bh(&queue_lock);

len = sprintf(buffer,
seq_printf(m,
"Peer PID : %d\n"
"Copy mode : %hu\n"
"Copy range : %u\n"
Expand All @@ -632,16 +629,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
queue_user_dropped);

read_unlock_bh(&queue_lock);
return 0;
}

*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
else if (len < 0)
len = 0;
return len;
static int ip_queue_open(struct inode *inode, struct file *file)
{
return single_open(file, ip_queue_show, NULL);
}
#endif /* CONFIG_PROC_FS */

static const struct file_operations ip_queue_proc_fops = {
.open = ip_queue_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};

static struct nf_queue_handler nfqh = {
.name = "ip_queue",
Expand All @@ -661,10 +663,11 @@ static int __init ip_queue_init(void)
goto cleanup_netlink_notifier;
}

proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info);
if (proc)
proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
if (proc) {
proc->owner = THIS_MODULE;
else {
proc->proc_fops = &ip_queue_proc_fops;
} else {
printk(KERN_ERR "ip_queue: failed to create proc entry\n");
goto cleanup_ipqnl;
}
Expand Down
37 changes: 20 additions & 17 deletions trunk/net/ipv6/netfilter/ip6_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/spinlock.h>
#include <linux/sysctl.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/mutex.h>
#include <net/net_namespace.h>
#include <net/sock.h>
Expand Down Expand Up @@ -596,15 +597,11 @@ static ctl_table ipq_root_table[] = {
{ .ctl_name = 0 }
};

#ifdef CONFIG_PROC_FS
static int
ipq_get_info(char *buffer, char **start, off_t offset, int length)
static int ip6_queue_show(struct seq_file *m, void *v)
{
int len;

read_lock_bh(&queue_lock);

len = sprintf(buffer,
seq_printf(m,
"Peer PID : %d\n"
"Copy mode : %hu\n"
"Copy range : %u\n"
Expand All @@ -621,16 +618,21 @@ ipq_get_info(char *buffer, char **start, off_t offset, int length)
queue_user_dropped);

read_unlock_bh(&queue_lock);
return 0;
}

*start = buffer + offset;
len -= offset;
if (len > length)
len = length;
else if (len < 0)
len = 0;
return len;
static int ip6_queue_open(struct inode *inode, struct file *file)
{
return single_open(file, ip6_queue_show, NULL);
}
#endif /* CONFIG_PROC_FS */

static const struct file_operations ip6_queue_proc_fops = {
.open = ip6_queue_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
.owner = THIS_MODULE,
};

static struct nf_queue_handler nfqh = {
.name = "ip6_queue",
Expand All @@ -650,10 +652,11 @@ static int __init ip6_queue_init(void)
goto cleanup_netlink_notifier;
}

proc = proc_net_create(&init_net, IPQ_PROC_FS_NAME, 0, ipq_get_info);
if (proc)
proc = create_proc_entry(IPQ_PROC_FS_NAME, 0, init_net.proc_net);
if (proc) {
proc->owner = THIS_MODULE;
else {
proc->proc_fops = &ip6_queue_proc_fops;
} else {
printk(KERN_ERR "ip6_queue: failed to create proc entry\n");
goto cleanup_ipqnl;
}
Expand Down
32 changes: 4 additions & 28 deletions trunk/security/selinux/ss/avtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,18 @@ static uint16_t spec_order[] = {
AVTAB_MEMBER
};

int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
int avtab_read_item(void *fp, u32 vers, struct avtab *a,
int (*insertf)(struct avtab *a, struct avtab_key *k,
struct avtab_datum *d, void *p),
void *p)
{
__le16 buf16[4];
u16 enabled;
__le32 buf32[7];
u32 items, items2, val, vers = pol->policyvers;
u32 items, items2, val;
struct avtab_key key;
struct avtab_datum datum;
int i, rc;
unsigned set;

memset(&key, 0, sizeof(struct avtab_key));
memset(&datum, 0, sizeof(struct avtab_datum));
Expand Down Expand Up @@ -421,35 +420,12 @@ int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
key.target_class = le16_to_cpu(buf16[items++]);
key.specified = le16_to_cpu(buf16[items++]);

if (!policydb_type_isvalid(pol, key.source_type) ||
!policydb_type_isvalid(pol, key.target_type) ||
!policydb_class_isvalid(pol, key.target_class)) {
printk(KERN_WARNING "security: avtab: invalid type or class\n");
return -1;
}

set = 0;
for (i = 0; i < ARRAY_SIZE(spec_order); i++) {
if (key.specified & spec_order[i])
set++;
}
if (!set || set > 1) {
printk(KERN_WARNING
"security: avtab: more than one specifier\n");
return -1;
}

rc = next_entry(buf32, fp, sizeof(u32));
if (rc < 0) {
printk("security: avtab: truncated entry\n");
return -1;
}
datum.data = le32_to_cpu(*buf32);
if ((key.specified & AVTAB_TYPE) &&
!policydb_type_isvalid(pol, datum.data)) {
printk(KERN_WARNING "security: avtab: invalid type\n");
return -1;
}
return insertf(a, &key, &datum, p);
}

Expand All @@ -459,7 +435,7 @@ static int avtab_insertf(struct avtab *a, struct avtab_key *k,
return avtab_insert(a, k, d);
}

int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
int avtab_read(struct avtab *a, void *fp, u32 vers)
{
int rc;
__le32 buf[1];
Expand All @@ -483,7 +459,7 @@ int avtab_read(struct avtab *a, void *fp, struct policydb *pol)
goto bad;

for (i = 0; i < nel; i++) {
rc = avtab_read_item(a, fp, pol, avtab_insertf, NULL);
rc = avtab_read_item(fp,vers, a, avtab_insertf, NULL);
if (rc) {
if (rc == -ENOMEM)
printk(KERN_ERR "security: avtab: out of memory\n");
Expand Down
5 changes: 2 additions & 3 deletions trunk/security/selinux/ss/avtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ struct avtab_datum *avtab_search(struct avtab *h, struct avtab_key *k);
void avtab_destroy(struct avtab *h);
void avtab_hash_eval(struct avtab *h, char *tag);

struct policydb;
int avtab_read_item(struct avtab *a, void *fp, struct policydb *pol,
int avtab_read_item(void *fp, uint32_t vers, struct avtab *a,
int (*insert)(struct avtab *a, struct avtab_key *k,
struct avtab_datum *d, void *p),
void *p);

int avtab_read(struct avtab *a, void *fp, struct policydb *pol);
int avtab_read(struct avtab *a, void *fp, u32 vers);

struct avtab_node *avtab_insert_nonunique(struct avtab *h, struct avtab_key *key,
struct avtab_datum *datum);
Expand Down
3 changes: 1 addition & 2 deletions trunk/security/selinux/ss/conditional.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,7 @@ static int cond_read_av_list(struct policydb *p, void *fp, struct cond_av_list *
data.head = NULL;
data.tail = NULL;
for (i = 0; i < len; i++) {
rc = avtab_read_item(&p->te_cond_avtab, fp, p, cond_insertf,
&data);
rc = avtab_read_item(fp, p->policyvers, &p->te_cond_avtab, cond_insertf, &data);
if (rc)
return rc;

Expand Down
2 changes: 1 addition & 1 deletion trunk/security/selinux/ss/ebitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ int ebitmap_netlbl_export(struct ebitmap *ebmap,
cmap_sft = delta % NETLBL_CATMAP_MAPSIZE;
c_iter->bitmap[cmap_idx]
|= e_iter->maps[cmap_idx] << cmap_sft;
e_iter = e_iter->next;
}
e_iter = e_iter->next;
}

return 0;
Expand Down
66 changes: 30 additions & 36 deletions trunk/security/selinux/ss/mls.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,55 +157,49 @@ void mls_sid_to_context(struct context *context,
return;
}

int mls_level_isvalid(struct policydb *p, struct mls_level *l)
{
struct level_datum *levdatum;
struct ebitmap_node *node;
int i;

if (!l->sens || l->sens > p->p_levels.nprim)
return 0;
levdatum = hashtab_search(p->p_levels.table,
p->p_sens_val_to_name[l->sens - 1]);
if (!levdatum)
return 0;

ebitmap_for_each_positive_bit(&l->cat, node, i) {
if (i > p->p_cats.nprim)
return 0;
if (!ebitmap_get_bit(&levdatum->level->cat, i)) {
/*
* Category may not be associated with
* sensitivity.
*/
return 0;
}
}

return 1;
}

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]));
}

/*
* Return 1 if the MLS fields in the security context
* structure `c' are valid. Return 0 otherwise.
*/
int mls_context_isvalid(struct policydb *p, struct context *c)
{
struct level_datum *levdatum;
struct user_datum *usrdatum;
struct ebitmap_node *node;
int i, l;

if (!selinux_mls_enabled)
return 1;

if (!mls_range_isvalid(p, &c->range))
/*
* MLS range validity checks: high must dominate low, low level must
* be valid (category set <-> sensitivity check), and high level must
* be valid (category set <-> sensitivity check)
*/
if (!mls_level_dom(&c->range.level[1], &c->range.level[0]))
/* High does not dominate low. */
return 0;

for (l = 0; l < 2; l++) {
if (!c->range.level[l].sens || c->range.level[l].sens > p->p_levels.nprim)
return 0;
levdatum = hashtab_search(p->p_levels.table,
p->p_sens_val_to_name[c->range.level[l].sens - 1]);
if (!levdatum)
return 0;

ebitmap_for_each_positive_bit(&c->range.level[l].cat, node, i) {
if (i > p->p_cats.nprim)
return 0;
if (!ebitmap_get_bit(&levdatum->level->cat, i))
/*
* Category may not be associated with
* sensitivity in low level.
*/
return 0;
}
}

if (c->role == OBJECT_R_VAL)
return 1;

Expand Down
2 changes: 0 additions & 2 deletions trunk/security/selinux/ss/mls.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
int mls_compute_context_len(struct context *context);
void mls_sid_to_context(struct context *context, char **scontext);
int mls_context_isvalid(struct policydb *p, struct context *c);
int mls_range_isvalid(struct policydb *p, struct mls_range *r);
int mls_level_isvalid(struct policydb *p, struct mls_level *l);

int mls_context_to_sid(char oldc,
char **scontext,
Expand Down
Loading

0 comments on commit c963b4e

Please sign in to comment.