Skip to content

Commit 7ef6123

Browse files
Tetsuo HandaJames Morris
authored andcommitted
TOMOYO: Use shorter names.
Use shorter name to reduce newlines needed for 80 columns limit. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <jmorris@namei.org>
1 parent 084da35 commit 7ef6123

File tree

5 files changed

+250
-299
lines changed

5 files changed

+250
-299
lines changed

security/tomoyo/common.c

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -841,25 +841,22 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_domain_info * const domain)
841841
return true;
842842
list_for_each_entry_rcu(ptr, &domain->acl_info_list, list) {
843843
switch (ptr->type) {
844-
struct tomoyo_single_path_acl_record *acl;
844+
struct tomoyo_path_acl *acl;
845845
u32 perm;
846846
u8 i;
847-
case TOMOYO_TYPE_SINGLE_PATH_ACL:
848-
acl = container_of(ptr,
849-
struct tomoyo_single_path_acl_record,
850-
head);
847+
case TOMOYO_TYPE_PATH_ACL:
848+
acl = container_of(ptr, struct tomoyo_path_acl, head);
851849
perm = acl->perm | (((u32) acl->perm_high) << 16);
852-
for (i = 0; i < TOMOYO_MAX_SINGLE_PATH_OPERATION; i++)
850+
for (i = 0; i < TOMOYO_MAX_PATH_OPERATION; i++)
853851
if (perm & (1 << i))
854852
count++;
855-
if (perm & (1 << TOMOYO_TYPE_READ_WRITE_ACL))
853+
if (perm & (1 << TOMOYO_TYPE_READ_WRITE))
856854
count -= 2;
857855
break;
858-
case TOMOYO_TYPE_DOUBLE_PATH_ACL:
859-
perm = container_of(ptr,
860-
struct tomoyo_double_path_acl_record,
861-
head)->perm;
862-
for (i = 0; i < TOMOYO_MAX_DOUBLE_PATH_OPERATION; i++)
856+
case TOMOYO_TYPE_PATH2_ACL:
857+
perm = container_of(ptr, struct tomoyo_path2_acl, head)
858+
->perm;
859+
for (i = 0; i < TOMOYO_MAX_PATH2_OPERATION; i++)
863860
if (perm & (1 << i))
864861
count++;
865862
break;
@@ -1366,16 +1363,15 @@ static int tomoyo_write_domain_policy(struct tomoyo_io_buffer *head)
13661363
}
13671364

13681365
/**
1369-
* tomoyo_print_single_path_acl - Print a single path ACL entry.
1366+
* tomoyo_print_path_acl - Print a single path ACL entry.
13701367
*
13711368
* @head: Pointer to "struct tomoyo_io_buffer".
1372-
* @ptr: Pointer to "struct tomoyo_single_path_acl_record".
1369+
* @ptr: Pointer to "struct tomoyo_path_acl".
13731370
*
13741371
* Returns true on success, false otherwise.
13751372
*/
1376-
static bool tomoyo_print_single_path_acl(struct tomoyo_io_buffer *head,
1377-
struct tomoyo_single_path_acl_record *
1378-
ptr)
1373+
static bool tomoyo_print_path_acl(struct tomoyo_io_buffer *head,
1374+
struct tomoyo_path_acl *ptr)
13791375
{
13801376
int pos;
13811377
u8 bit;
@@ -1384,17 +1380,15 @@ static bool tomoyo_print_single_path_acl(struct tomoyo_io_buffer *head,
13841380
const u32 perm = ptr->perm | (((u32) ptr->perm_high) << 16);
13851381

13861382
filename = ptr->filename->name;
1387-
for (bit = head->read_bit; bit < TOMOYO_MAX_SINGLE_PATH_OPERATION;
1388-
bit++) {
1383+
for (bit = head->read_bit; bit < TOMOYO_MAX_PATH_OPERATION; bit++) {
13891384
const char *msg;
13901385
if (!(perm & (1 << bit)))
13911386
continue;
13921387
/* Print "read/write" instead of "read" and "write". */
1393-
if ((bit == TOMOYO_TYPE_READ_ACL ||
1394-
bit == TOMOYO_TYPE_WRITE_ACL)
1395-
&& (perm & (1 << TOMOYO_TYPE_READ_WRITE_ACL)))
1388+
if ((bit == TOMOYO_TYPE_READ || bit == TOMOYO_TYPE_WRITE)
1389+
&& (perm & (1 << TOMOYO_TYPE_READ_WRITE)))
13961390
continue;
1397-
msg = tomoyo_sp2keyword(bit);
1391+
msg = tomoyo_path2keyword(bit);
13981392
pos = head->read_avail;
13991393
if (!tomoyo_io_printf(head, "allow_%s %s%s\n", msg,
14001394
atmark, filename))
@@ -1409,16 +1403,15 @@ static bool tomoyo_print_single_path_acl(struct tomoyo_io_buffer *head,
14091403
}
14101404

14111405
/**
1412-
* tomoyo_print_double_path_acl - Print a double path ACL entry.
1406+
* tomoyo_print_path2_acl - Print a double path ACL entry.
14131407
*
14141408
* @head: Pointer to "struct tomoyo_io_buffer".
1415-
* @ptr: Pointer to "struct tomoyo_double_path_acl_record".
1409+
* @ptr: Pointer to "struct tomoyo_path2_acl".
14161410
*
14171411
* Returns true on success, false otherwise.
14181412
*/
1419-
static bool tomoyo_print_double_path_acl(struct tomoyo_io_buffer *head,
1420-
struct tomoyo_double_path_acl_record *
1421-
ptr)
1413+
static bool tomoyo_print_path2_acl(struct tomoyo_io_buffer *head,
1414+
struct tomoyo_path2_acl *ptr)
14221415
{
14231416
int pos;
14241417
const char *atmark1 = "";
@@ -1430,12 +1423,11 @@ static bool tomoyo_print_double_path_acl(struct tomoyo_io_buffer *head,
14301423

14311424
filename1 = ptr->filename1->name;
14321425
filename2 = ptr->filename2->name;
1433-
for (bit = head->read_bit; bit < TOMOYO_MAX_DOUBLE_PATH_OPERATION;
1434-
bit++) {
1426+
for (bit = head->read_bit; bit < TOMOYO_MAX_PATH2_OPERATION; bit++) {
14351427
const char *msg;
14361428
if (!(perm & (1 << bit)))
14371429
continue;
1438-
msg = tomoyo_dp2keyword(bit);
1430+
msg = tomoyo_path22keyword(bit);
14391431
pos = head->read_avail;
14401432
if (!tomoyo_io_printf(head, "allow_%s %s%s %s%s\n", msg,
14411433
atmark1, filename1, atmark2, filename2))
@@ -1462,19 +1454,15 @@ static bool tomoyo_print_entry(struct tomoyo_io_buffer *head,
14621454
{
14631455
const u8 acl_type = ptr->type;
14641456

1465-
if (acl_type == TOMOYO_TYPE_SINGLE_PATH_ACL) {
1466-
struct tomoyo_single_path_acl_record *acl
1467-
= container_of(ptr,
1468-
struct tomoyo_single_path_acl_record,
1469-
head);
1470-
return tomoyo_print_single_path_acl(head, acl);
1457+
if (acl_type == TOMOYO_TYPE_PATH_ACL) {
1458+
struct tomoyo_path_acl *acl
1459+
= container_of(ptr, struct tomoyo_path_acl, head);
1460+
return tomoyo_print_path_acl(head, acl);
14711461
}
1472-
if (acl_type == TOMOYO_TYPE_DOUBLE_PATH_ACL) {
1473-
struct tomoyo_double_path_acl_record *acl
1474-
= container_of(ptr,
1475-
struct tomoyo_double_path_acl_record,
1476-
head);
1477-
return tomoyo_print_double_path_acl(head, acl);
1462+
if (acl_type == TOMOYO_TYPE_PATH2_ACL) {
1463+
struct tomoyo_path2_acl *acl
1464+
= container_of(ptr, struct tomoyo_path2_acl, head);
1465+
return tomoyo_print_path2_acl(head, acl);
14781466
}
14791467
BUG(); /* This must not happen. */
14801468
return false;

security/tomoyo/common.h

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ enum tomoyo_mac_index {
7171

7272
/* Index numbers for Access Controls. */
7373
enum tomoyo_acl_entry_type_index {
74-
TOMOYO_TYPE_SINGLE_PATH_ACL,
75-
TOMOYO_TYPE_DOUBLE_PATH_ACL,
74+
TOMOYO_TYPE_PATH_ACL,
75+
TOMOYO_TYPE_PATH2_ACL,
7676
};
7777

7878
/* Index numbers for File Controls. */
@@ -87,36 +87,36 @@ enum tomoyo_acl_entry_type_index {
8787
*/
8888

8989
enum tomoyo_path_acl_index {
90-
TOMOYO_TYPE_READ_WRITE_ACL,
91-
TOMOYO_TYPE_EXECUTE_ACL,
92-
TOMOYO_TYPE_READ_ACL,
93-
TOMOYO_TYPE_WRITE_ACL,
94-
TOMOYO_TYPE_CREATE_ACL,
95-
TOMOYO_TYPE_UNLINK_ACL,
96-
TOMOYO_TYPE_MKDIR_ACL,
97-
TOMOYO_TYPE_RMDIR_ACL,
98-
TOMOYO_TYPE_MKFIFO_ACL,
99-
TOMOYO_TYPE_MKSOCK_ACL,
100-
TOMOYO_TYPE_MKBLOCK_ACL,
101-
TOMOYO_TYPE_MKCHAR_ACL,
102-
TOMOYO_TYPE_TRUNCATE_ACL,
103-
TOMOYO_TYPE_SYMLINK_ACL,
104-
TOMOYO_TYPE_REWRITE_ACL,
105-
TOMOYO_TYPE_IOCTL_ACL,
106-
TOMOYO_TYPE_CHMOD_ACL,
107-
TOMOYO_TYPE_CHOWN_ACL,
108-
TOMOYO_TYPE_CHGRP_ACL,
109-
TOMOYO_TYPE_CHROOT_ACL,
110-
TOMOYO_TYPE_MOUNT_ACL,
111-
TOMOYO_TYPE_UMOUNT_ACL,
112-
TOMOYO_MAX_SINGLE_PATH_OPERATION
90+
TOMOYO_TYPE_READ_WRITE,
91+
TOMOYO_TYPE_EXECUTE,
92+
TOMOYO_TYPE_READ,
93+
TOMOYO_TYPE_WRITE,
94+
TOMOYO_TYPE_CREATE,
95+
TOMOYO_TYPE_UNLINK,
96+
TOMOYO_TYPE_MKDIR,
97+
TOMOYO_TYPE_RMDIR,
98+
TOMOYO_TYPE_MKFIFO,
99+
TOMOYO_TYPE_MKSOCK,
100+
TOMOYO_TYPE_MKBLOCK,
101+
TOMOYO_TYPE_MKCHAR,
102+
TOMOYO_TYPE_TRUNCATE,
103+
TOMOYO_TYPE_SYMLINK,
104+
TOMOYO_TYPE_REWRITE,
105+
TOMOYO_TYPE_IOCTL,
106+
TOMOYO_TYPE_CHMOD,
107+
TOMOYO_TYPE_CHOWN,
108+
TOMOYO_TYPE_CHGRP,
109+
TOMOYO_TYPE_CHROOT,
110+
TOMOYO_TYPE_MOUNT,
111+
TOMOYO_TYPE_UMOUNT,
112+
TOMOYO_MAX_PATH_OPERATION
113113
};
114114

115115
enum tomoyo_path2_acl_index {
116-
TOMOYO_TYPE_LINK_ACL,
117-
TOMOYO_TYPE_RENAME_ACL,
118-
TOMOYO_TYPE_PIVOT_ROOT_ACL,
119-
TOMOYO_MAX_DOUBLE_PATH_OPERATION
116+
TOMOYO_TYPE_LINK,
117+
TOMOYO_TYPE_RENAME,
118+
TOMOYO_TYPE_PIVOT_ROOT,
119+
TOMOYO_MAX_PATH2_OPERATION
120120
};
121121

122122
enum tomoyo_securityfs_interface_index {
@@ -210,12 +210,11 @@ struct tomoyo_path_info_with_data {
210210
* (1) "list" which is linked to the ->acl_info_list of
211211
* "struct tomoyo_domain_info"
212212
* (2) "type" which tells type of the entry (either
213-
* "struct tomoyo_single_path_acl_record" or
214-
* "struct tomoyo_double_path_acl_record").
213+
* "struct tomoyo_path_acl" or "struct tomoyo_path2_acl").
215214
*
216215
* Packing "struct tomoyo_acl_info" allows
217-
* "struct tomoyo_single_path_acl_record" to embed "u8" + "u16" and
218-
* "struct tomoyo_double_path_acl_record" to embed "u8"
216+
* "struct tomoyo_path_acl" to embed "u8" + "u16" and
217+
* "struct tomoyo_path2_acl" to embed "u8"
219218
* without enlarging their structure size.
220219
*/
221220
struct tomoyo_acl_info {
@@ -269,7 +268,7 @@ struct tomoyo_domain_info {
269268
};
270269

271270
/*
272-
* tomoyo_single_path_acl_record is a structure which is used for holding an
271+
* tomoyo_path_acl is a structure which is used for holding an
273272
* entry with one pathname operation (e.g. open(), mkdir()).
274273
* It has following fields.
275274
*
@@ -284,16 +283,16 @@ struct tomoyo_domain_info {
284283
* "allow_chmod", "allow_chown", "allow_chgrp", "allow_chroot", "allow_mount"
285284
* and "allow_unmount".
286285
*/
287-
struct tomoyo_single_path_acl_record {
288-
struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_SINGLE_PATH_ACL */
286+
struct tomoyo_path_acl {
287+
struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH_ACL */
289288
u8 perm_high;
290289
u16 perm;
291290
/* Pointer to single pathname. */
292291
const struct tomoyo_path_info *filename;
293292
};
294293

295294
/*
296-
* tomoyo_double_path_acl_record is a structure which is used for holding an
295+
* tomoyo_path2_acl is a structure which is used for holding an
297296
* entry with two pathnames operation (i.e. link(), rename() and pivot_root()).
298297
* It has following fields.
299298
*
@@ -305,8 +304,8 @@ struct tomoyo_single_path_acl_record {
305304
* Directives held by this structure are "allow_rename", "allow_link" and
306305
* "allow_pivot_root".
307306
*/
308-
struct tomoyo_double_path_acl_record {
309-
struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_DOUBLE_PATH_ACL */
307+
struct tomoyo_path2_acl {
308+
struct tomoyo_acl_info head; /* type = TOMOYO_TYPE_PATH2_ACL */
310309
u8 perm;
311310
/* Pointer to single pathname. */
312311
const struct tomoyo_path_info *filename1;
@@ -550,13 +549,13 @@ bool tomoyo_read_no_rewrite_policy(struct tomoyo_io_buffer *head);
550549
/* Write domain policy violation warning message to console? */
551550
bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
552551
/* Convert double path operation to operation name. */
553-
const char *tomoyo_dp2keyword(const u8 operation);
552+
const char *tomoyo_path22keyword(const u8 operation);
554553
/* Get the last component of the given domainname. */
555554
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
556555
/* Get warning message. */
557556
const char *tomoyo_get_msg(const bool is_enforce);
558557
/* Convert single path operation to operation name. */
559-
const char *tomoyo_sp2keyword(const u8 operation);
558+
const char *tomoyo_path2keyword(const u8 operation);
560559
/* Create "alias" entry in exception policy. */
561560
int tomoyo_write_alias_policy(char *data, const bool is_delete);
562561
/*
@@ -638,11 +637,10 @@ int tomoyo_check_exec_perm(struct tomoyo_domain_info *domain,
638637
const struct tomoyo_path_info *filename);
639638
int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
640639
struct path *path, const int flag);
641-
int tomoyo_check_1path_perm(struct tomoyo_domain_info *domain,
642-
const u8 operation, struct path *path);
643-
int tomoyo_check_2path_perm(struct tomoyo_domain_info *domain,
644-
const u8 operation, struct path *path1,
645-
struct path *path2);
640+
int tomoyo_path_perm(struct tomoyo_domain_info *domain, const u8 operation,
641+
struct path *path);
642+
int tomoyo_path2_perm(struct tomoyo_domain_info *domain, const u8 operation,
643+
struct path *path1, struct path *path2);
646644
int tomoyo_check_rewrite_permission(struct tomoyo_domain_info *domain,
647645
struct file *filp);
648646
int tomoyo_find_next_domain(struct linux_binprm *bprm);

0 commit comments

Comments
 (0)