Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 201853
b: refs/heads/master
c: 7509315
h: refs/heads/master
i:
  201851: f92437f
v: v3
  • Loading branch information
Tetsuo Handa authored and James Morris committed Aug 2, 2010
1 parent f0aea64 commit ac08277
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 158 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: 99a852596beb26cc449ca1a79834c107ef4080e1
refs/heads/master: 75093152a97ee0ec281895b4f6229ff3c481fd64
44 changes: 22 additions & 22 deletions trunk/security/tomoyo/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,12 @@ static int tomoyo_update_manager_entry(const char *manager,
struct tomoyo_policy_manager_entry e = { };
int error;

if (tomoyo_is_domain_def(manager)) {
if (!tomoyo_is_correct_domain(manager))
if (tomoyo_domain_def(manager)) {
if (!tomoyo_correct_domain(manager))
return -EINVAL;
e.is_domain = true;
} else {
if (!tomoyo_is_correct_path(manager))
if (!tomoyo_correct_path(manager))
return -EINVAL;
}
e.manager = tomoyo_get_name(manager);
Expand Down Expand Up @@ -565,14 +565,14 @@ static int tomoyo_read_manager_policy(struct tomoyo_io_buffer *head)
}

/**
* tomoyo_is_policy_manager - Check whether the current process is a policy manager.
* tomoyo_policy_manager - Check whether the current process is a policy manager.
*
* Returns true if the current process is permitted to modify policy
* via /sys/kernel/security/tomoyo/ interface.
*
* Caller holds tomoyo_read_lock().
*/
static bool tomoyo_is_policy_manager(void)
static bool tomoyo_policy_manager(void)
{
struct tomoyo_policy_manager_entry *ptr;
const char *exe;
Expand Down Expand Up @@ -617,7 +617,7 @@ static bool tomoyo_is_policy_manager(void)
}

/**
* tomoyo_is_select_one - Parse select command.
* tomoyo_select_one - Parse select command.
*
* @head: Pointer to "struct tomoyo_io_buffer".
* @data: String to parse.
Expand All @@ -626,7 +626,7 @@ static bool tomoyo_is_policy_manager(void)
*
* Caller holds tomoyo_read_lock().
*/
static bool tomoyo_is_select_one(struct tomoyo_io_buffer *head,
static bool tomoyo_select_one(struct tomoyo_io_buffer *head,
const char *data)
{
unsigned int pid;
Expand All @@ -647,7 +647,7 @@ static bool tomoyo_is_select_one(struct tomoyo_io_buffer *head,
read_unlock(&tasklist_lock);
rcu_read_unlock();
} else if (!strncmp(data, "domain=", 7)) {
if (tomoyo_is_domain_def(data + 7))
if (tomoyo_domain_def(data + 7))
domain = tomoyo_find_domain(data + 7);
} else
return false;
Expand Down Expand Up @@ -748,12 +748,12 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head)
is_delete = true;
else if (tomoyo_str_starts(&data, TOMOYO_KEYWORD_SELECT))
is_select = true;
if (is_select && tomoyo_is_select_one(head, data))
if (is_select && tomoyo_select_one(head, data))
return 0;
/* Don't allow updating policies by non manager programs. */
if (!tomoyo_is_policy_manager())
if (!tomoyo_policy_manager())
return -EPERM;
if (tomoyo_is_domain_def(data)) {
if (tomoyo_domain_def(data)) {
domain = NULL;
if (is_delete)
tomoyo_delete_domain(data);
Expand Down Expand Up @@ -894,26 +894,26 @@ static bool tomoyo_print_path_number_acl(struct tomoyo_io_buffer *head,
}

/**
* tomoyo_print_path_number3_acl - Print a path_number3 ACL entry.
* tomoyo_print_mkdev_acl - Print a mkdev ACL entry.
*
* @head: Pointer to "struct tomoyo_io_buffer".
* @ptr: Pointer to "struct tomoyo_path_number3_acl".
* @ptr: Pointer to "struct tomoyo_mkdev_acl".
*
* Returns true on success, false otherwise.
*/
static bool tomoyo_print_path_number3_acl(struct tomoyo_io_buffer *head,
struct tomoyo_path_number3_acl *ptr)
static bool tomoyo_print_mkdev_acl(struct tomoyo_io_buffer *head,
struct tomoyo_mkdev_acl *ptr)
{
int pos;
u8 bit;
const u16 perm = ptr->perm;
for (bit = head->read_bit; bit < TOMOYO_MAX_PATH_NUMBER3_OPERATION;
for (bit = head->read_bit; bit < TOMOYO_MAX_MKDEV_OPERATION;
bit++) {
if (!(perm & (1 << bit)))
continue;
pos = head->read_avail;
if (!tomoyo_io_printf(head, "allow_%s",
tomoyo_path_number32keyword(bit)) ||
tomoyo_mkdev2keyword(bit)) ||
!tomoyo_print_name_union(head, &ptr->name) ||
!tomoyo_print_number_union(head, &ptr->mode) ||
!tomoyo_print_number_union(head, &ptr->major) ||
Expand Down Expand Up @@ -984,11 +984,11 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head,
head);
return tomoyo_print_path_number_acl(head, acl);
}
if (acl_type == TOMOYO_TYPE_PATH_NUMBER3_ACL) {
struct tomoyo_path_number3_acl *acl
= container_of(ptr, struct tomoyo_path_number3_acl,
if (acl_type == TOMOYO_TYPE_MKDEV_ACL) {
struct tomoyo_mkdev_acl *acl
= container_of(ptr, struct tomoyo_mkdev_acl,
head);
return tomoyo_print_path_number3_acl(head, acl);
return tomoyo_print_mkdev_acl(head, acl);
}
if (acl_type == TOMOYO_TYPE_MOUNT_ACL) {
struct tomoyo_mount_acl *acl
Expand Down Expand Up @@ -1910,7 +1910,7 @@ int tomoyo_write_control(struct file *file, const char __user *buffer,
/* Don't allow updating policies by non manager programs. */
if (head->write != tomoyo_write_pid &&
head->write != tomoyo_write_domain_policy &&
!tomoyo_is_policy_manager())
!tomoyo_policy_manager())
return -EPERM;
if (mutex_lock_interruptible(&head->io_sem))
return -EINTR;
Expand Down
42 changes: 21 additions & 21 deletions trunk/security/tomoyo/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ enum tomoyo_acl_entry_type_index {
TOMOYO_TYPE_PATH_ACL,
TOMOYO_TYPE_PATH2_ACL,
TOMOYO_TYPE_PATH_NUMBER_ACL,
TOMOYO_TYPE_PATH_NUMBER3_ACL,
TOMOYO_TYPE_MKDEV_ACL,
TOMOYO_TYPE_MOUNT_ACL,
};

Expand Down Expand Up @@ -114,10 +114,10 @@ enum tomoyo_path_acl_index {

#define TOMOYO_RW_MASK ((1 << TOMOYO_TYPE_READ) | (1 << TOMOYO_TYPE_WRITE))

enum tomoyo_path_number3_acl_index {
enum tomoyo_mkdev_acl_index {
TOMOYO_TYPE_MKBLOCK,
TOMOYO_TYPE_MKCHAR,
TOMOYO_MAX_PATH_NUMBER3_OPERATION
TOMOYO_MAX_MKDEV_OPERATION
};

enum tomoyo_path2_acl_index {
Expand Down Expand Up @@ -342,7 +342,7 @@ struct tomoyo_number_group_member {
*
* Packing "struct tomoyo_acl_info" allows
* "struct tomoyo_path_acl" to embed "u16" and "struct tomoyo_path2_acl"
* "struct tomoyo_path_number_acl" "struct tomoyo_path_number3_acl" to embed
* "struct tomoyo_path_number_acl" "struct tomoyo_mkdev_acl" to embed
* "u8" without enlarging their structure size.
*/
struct tomoyo_acl_info {
Expand Down Expand Up @@ -439,7 +439,7 @@ struct tomoyo_path_number_acl {
};

/*
* tomoyo_path_number3_acl is a structure which is used for holding an
* tomoyo_mkdev_acl is a structure which is used for holding an
* entry with one pathname and three numbers operation.
* It has following fields.
*
Expand All @@ -452,8 +452,8 @@ struct tomoyo_path_number_acl {
* Directives held by this structure are "allow_mkchar", "allow_mkblock".
*
*/
struct tomoyo_path_number3_acl {
struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_NUMBER3_ACL */
struct tomoyo_mkdev_acl {
struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_MKDEV_ACL */
u8 perm;
struct tomoyo_name_union name;
struct tomoyo_number_union mode;
Expand Down Expand Up @@ -756,12 +756,12 @@ int tomoyo_get_mode(const u8 profile, const u8 index);
bool tomoyo_io_printf(struct tomoyo_io_buffer *head, const char *fmt, ...)
__attribute__ ((format(printf, 2, 3)));
/* Check whether the domainname is correct. */
bool tomoyo_is_correct_domain(const unsigned char *domainname);
bool tomoyo_correct_domain(const unsigned char *domainname);
/* Check whether the token is correct. */
bool tomoyo_is_correct_path(const char *filename);
bool tomoyo_is_correct_word(const char *string);
bool tomoyo_correct_path(const char *filename);
bool tomoyo_correct_word(const char *string);
/* Check whether the token can be a domainname. */
bool tomoyo_is_domain_def(const unsigned char *buffer);
bool tomoyo_domain_def(const unsigned char *buffer);
bool tomoyo_parse_name_union(const char *filename,
struct tomoyo_name_union *ptr);
/* Check whether the given filename matches the given path_group. */
Expand Down Expand Up @@ -807,7 +807,7 @@ bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
/* Convert double path operation to operation name. */
const char *tomoyo_path22keyword(const u8 operation);
const char *tomoyo_path_number2keyword(const u8 operation);
const char *tomoyo_path_number32keyword(const u8 operation);
const char *tomoyo_mkdev2keyword(const u8 operation);
/* Get the last component of the given domainname. */
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
/* Convert single path operation to operation name. */
Expand Down Expand Up @@ -919,8 +919,8 @@ int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
struct path *path, const int flag);
int tomoyo_path_number_perm(const u8 operation, struct path *path,
unsigned long number);
int tomoyo_path_number3_perm(const u8 operation, struct path *path,
const unsigned int mode, unsigned int dev);
int tomoyo_mkdev_perm(const u8 operation, struct path *path,
const unsigned int mode, unsigned int dev);
int tomoyo_path_perm(const u8 operation, struct path *path);
int tomoyo_path2_perm(const u8 operation, struct path *path1,
struct path *path2);
Expand Down Expand Up @@ -1008,25 +1008,25 @@ static inline bool tomoyo_pathcmp(const struct tomoyo_path_info *a,
}

/**
* tomoyo_is_valid - Check whether the character is a valid char.
* tomoyo_valid - Check whether the character is a valid char.
*
* @c: The character to check.
*
* Returns true if @c is a valid character, false otherwise.
*/
static inline bool tomoyo_is_valid(const unsigned char c)
static inline bool tomoyo_valid(const unsigned char c)
{
return c > ' ' && c < 127;
}

/**
* tomoyo_is_invalid - Check whether the character is an invalid char.
* tomoyo_invalid - Check whether the character is an invalid char.
*
* @c: The character to check.
*
* Returns true if @c is an invalid character, false otherwise.
*/
static inline bool tomoyo_is_invalid(const unsigned char c)
static inline bool tomoyo_invalid(const unsigned char c)
{
return c && (c <= ' ' || c >= 127);
}
Expand Down Expand Up @@ -1063,20 +1063,20 @@ static inline struct tomoyo_domain_info *tomoyo_real_domain(struct task_struct
return task_cred_xxx(task, security);
}

static inline bool tomoyo_is_same_acl_head(const struct tomoyo_acl_info *p1,
static inline bool tomoyo_same_acl_head(const struct tomoyo_acl_info *p1,
const struct tomoyo_acl_info *p2)
{
return p1->type == p2->type;
}

static inline bool tomoyo_is_same_name_union
static inline bool tomoyo_same_name_union
(const struct tomoyo_name_union *p1, const struct tomoyo_name_union *p2)
{
return p1->filename == p2->filename && p1->group == p2->group &&
p1->is_group == p2->is_group;
}

static inline bool tomoyo_is_same_number_union
static inline bool tomoyo_same_number_union
(const struct tomoyo_number_union *p1, const struct tomoyo_number_union *p2)
{
return p1->values[0] == p2->values[0] && p1->values[1] == p2->values[1]
Expand Down
Loading

0 comments on commit ac08277

Please sign in to comment.