Skip to content

Commit e2bf690

Browse files
Tetsuo Handaxjamesmorris
authored andcommitted
TOMOYO: Rename symbols.
Use shorter name in order to make it easier to fit 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 8e56868 commit e2bf690

8 files changed

Lines changed: 199 additions & 240 deletions

File tree

‎security/tomoyo/common.c‎

Lines changed: 100 additions & 126 deletions
Large diffs are not rendered by default.

‎security/tomoyo/common.h‎

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,10 @@ struct tomoyo_path_info {
310310
};
311311

312312
/*
313-
* tomoyo_name_entry is a structure which is used for linking
313+
* tomoyo_name is a structure which is used for linking
314314
* "struct tomoyo_path_info" into tomoyo_name_list .
315315
*/
316-
struct tomoyo_name_entry {
316+
struct tomoyo_name {
317317
struct list_head list;
318318
atomic_t users;
319319
struct tomoyo_path_info entry;
@@ -572,42 +572,42 @@ struct tomoyo_io_buffer {
572572
};
573573

574574
/*
575-
* tomoyo_globally_readable_file_entry is a structure which is used for holding
575+
* tomoyo_readable_file is a structure which is used for holding
576576
* "allow_read" entries.
577577
* It has following fields.
578578
*
579579
* (1) "head" is "struct tomoyo_acl_head".
580580
* (2) "filename" is a pathname which is allowed to open(O_RDONLY).
581581
*/
582-
struct tomoyo_globally_readable_file_entry {
582+
struct tomoyo_readable_file {
583583
struct tomoyo_acl_head head;
584584
const struct tomoyo_path_info *filename;
585585
};
586586

587587
/*
588-
* tomoyo_pattern_entry is a structure which is used for holding
588+
* tomoyo_no_pattern is a structure which is used for holding
589589
* "file_pattern" entries.
590590
* It has following fields.
591591
*
592592
* (1) "head" is "struct tomoyo_acl_head".
593593
* (2) "pattern" is a pathname pattern which is used for converting pathnames
594594
* to pathname patterns during learning mode.
595595
*/
596-
struct tomoyo_pattern_entry {
596+
struct tomoyo_no_pattern {
597597
struct tomoyo_acl_head head;
598598
const struct tomoyo_path_info *pattern;
599599
};
600600

601601
/*
602-
* tomoyo_no_rewrite_entry is a structure which is used for holding
602+
* tomoyo_no_rewrite is a structure which is used for holding
603603
* "deny_rewrite" entries.
604604
* It has following fields.
605605
*
606606
* (1) "head" is "struct tomoyo_acl_head".
607607
* (2) "pattern" is a pathname which is by default not permitted to modify
608608
* already existing content.
609609
*/
610-
struct tomoyo_no_rewrite_entry {
610+
struct tomoyo_no_rewrite {
611611
struct tomoyo_acl_head head;
612612
const struct tomoyo_path_info *pattern;
613613
};
@@ -636,22 +636,22 @@ struct tomoyo_transition_control {
636636
};
637637

638638
/*
639-
* tomoyo_aggregator_entry is a structure which is used for holding
639+
* tomoyo_aggregator is a structure which is used for holding
640640
* "aggregator" entries.
641641
* It has following fields.
642642
*
643643
* (1) "head" is "struct tomoyo_acl_head".
644644
* (2) "original_name" which is originally requested name.
645645
* (3) "aggregated_name" which is name to rewrite.
646646
*/
647-
struct tomoyo_aggregator_entry {
647+
struct tomoyo_aggregator {
648648
struct tomoyo_acl_head head;
649649
const struct tomoyo_path_info *original_name;
650650
const struct tomoyo_path_info *aggregated_name;
651651
};
652652

653653
/*
654-
* tomoyo_policy_manager_entry is a structure which is used for holding list of
654+
* tomoyo_manager is a structure which is used for holding list of
655655
* domainnames or programs which are permitted to modify configuration via
656656
* /sys/kernel/security/tomoyo/ interface.
657657
* It has following fields.
@@ -661,7 +661,7 @@ struct tomoyo_aggregator_entry {
661661
* otherwise.
662662
* (3) "manager" is a domainname or a program's pathname.
663663
*/
664-
struct tomoyo_policy_manager_entry {
664+
struct tomoyo_manager {
665665
struct tomoyo_acl_head head;
666666
bool is_domain; /* True if manager is a domainname. */
667667
/* A path to program or a domainname. */
@@ -749,8 +749,6 @@ bool tomoyo_parse_number_union(char *data, struct tomoyo_number_union *num);
749749
bool tomoyo_tokenize(char *buffer, char *w[], size_t size);
750750
/* Write domain policy violation warning message to console? */
751751
bool tomoyo_verbose_mode(const struct tomoyo_domain_info *domain);
752-
/* Get the last component of the given domainname. */
753-
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain);
754752
/* Fill "struct tomoyo_request_info". */
755753
int tomoyo_init_request_info(struct tomoyo_request_info *r,
756754
struct tomoyo_domain_info *domain,
@@ -759,7 +757,7 @@ int tomoyo_init_request_info(struct tomoyo_request_info *r,
759757
int tomoyo_mount_permission(char *dev_name, struct path *path, char *type,
760758
unsigned long flags, void *data_page);
761759
/* Create "aggregator" entry in exception policy. */
762-
int tomoyo_write_aggregator_policy(char *data, const bool is_delete);
760+
int tomoyo_write_aggregator(char *data, const bool is_delete);
763761
int tomoyo_write_transition_control(char *data, const bool is_delete,
764762
const u8 type);
765763
/*
@@ -769,27 +767,26 @@ int tomoyo_write_transition_control(char *data, const bool is_delete,
769767
* "allow_truncate", "allow_symlink", "allow_rewrite", "allow_rename" and
770768
* "allow_link" entry in domain policy.
771769
*/
772-
int tomoyo_write_file_policy(char *data, struct tomoyo_domain_info *domain,
773-
const bool is_delete);
770+
int tomoyo_write_file(char *data, struct tomoyo_domain_info *domain,
771+
const bool is_delete);
774772
/* Create "allow_read" entry in exception policy. */
775-
int tomoyo_write_globally_readable_policy(char *data, const bool is_delete);
773+
int tomoyo_write_globally_readable(char *data, const bool is_delete);
776774
/* Create "allow_mount" entry in domain policy. */
777-
int tomoyo_write_mount_policy(char *data, struct tomoyo_domain_info *domain,
778-
const bool is_delete);
775+
int tomoyo_write_mount(char *data, struct tomoyo_domain_info *domain,
776+
const bool is_delete);
779777
/* Create "deny_rewrite" entry in exception policy. */
780-
int tomoyo_write_no_rewrite_policy(char *data, const bool is_delete);
778+
int tomoyo_write_no_rewrite(char *data, const bool is_delete);
781779
/* Create "file_pattern" entry in exception policy. */
782-
int tomoyo_write_pattern_policy(char *data, const bool is_delete);
780+
int tomoyo_write_pattern(char *data, const bool is_delete);
783781
/* Create "path_group"/"number_group" entry in exception policy. */
784782
int tomoyo_write_group(char *data, const bool is_delete, const u8 type);
785783
int tomoyo_supervisor(struct tomoyo_request_info *r, const char *fmt, ...)
786784
__attribute__ ((format(printf, 2, 3)));
787785
/* Find a domain by the given name. */
788786
struct tomoyo_domain_info *tomoyo_find_domain(const char *domainname);
789787
/* Find or create a domain by the given name. */
790-
struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
791-
domainname,
792-
const u8 profile);
788+
struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
789+
const u8 profile);
793790
struct tomoyo_profile *tomoyo_profile(const u8 profile);
794791
/*
795792
* Allocate memory for "struct tomoyo_path_group"/"struct tomoyo_number_group".
@@ -820,7 +817,7 @@ char *tomoyo_realpath_nofollow(const char *pathname);
820817
*/
821818
char *tomoyo_realpath_from_path(struct path *path);
822819
/* Get patterned pathname. */
823-
const char *tomoyo_file_pattern(const struct tomoyo_path_info *filename);
820+
const char *tomoyo_pattern(const struct tomoyo_path_info *filename);
824821

825822
/* Check memory quota. */
826823
bool tomoyo_memory_ok(void *ptr);
@@ -882,7 +879,6 @@ int tomoyo_update_policy(struct tomoyo_acl_head *new_entry, const int size,
882879
void tomoyo_check_acl(struct tomoyo_request_info *r,
883880
bool (*check_entry) (const struct tomoyo_request_info *,
884881
const struct tomoyo_acl_info *));
885-
const char *tomoyo_last_word(const char *name);
886882

887883
/********** External variable definitions. **********/
888884

@@ -959,8 +955,8 @@ static inline bool tomoyo_invalid(const unsigned char c)
959955
static inline void tomoyo_put_name(const struct tomoyo_path_info *name)
960956
{
961957
if (name) {
962-
struct tomoyo_name_entry *ptr =
963-
container_of(name, struct tomoyo_name_entry, entry);
958+
struct tomoyo_name *ptr =
959+
container_of(name, typeof(*ptr), entry);
964960
atomic_dec(&ptr->users);
965961
}
966962
}

‎security/tomoyo/domain.c‎

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -134,26 +134,22 @@ struct list_head tomoyo_policy_list[TOMOYO_MAX_POLICY];
134134
struct list_head tomoyo_group_list[TOMOYO_MAX_GROUP];
135135

136136
/**
137-
* tomoyo_get_last_name - Get last component of a domainname.
137+
* tomoyo_last_word - Get last component of a domainname.
138138
*
139-
* @domain: Pointer to "struct tomoyo_domain_info".
139+
* @domainname: Domainname to check.
140140
*
141-
* Returns the last component of the domainname.
141+
* Returns the last word of @domainname.
142142
*/
143-
const char *tomoyo_get_last_name(const struct tomoyo_domain_info *domain)
143+
static const char *tomoyo_last_word(const char *name)
144144
{
145-
const char *cp0 = domain->domainname->name;
146-
const char *cp1 = strrchr(cp0, ' ');
147-
148-
if (cp1)
149-
return cp1 + 1;
150-
return cp0;
145+
const char *cp = strrchr(name, ' ');
146+
if (cp)
147+
return cp + 1;
148+
return name;
151149
}
152150

153-
static bool tomoyo_same_transition_control_entry(const struct tomoyo_acl_head *
154-
a,
155-
const struct tomoyo_acl_head *
156-
b)
151+
static bool tomoyo_same_transition_control(const struct tomoyo_acl_head *a,
152+
const struct tomoyo_acl_head *b)
157153
{
158154
const struct tomoyo_transition_control *p1 = container_of(a,
159155
typeof(*p1),
@@ -203,7 +199,7 @@ static int tomoyo_update_transition_control_entry(const char *domainname,
203199
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
204200
&tomoyo_policy_list
205201
[TOMOYO_ID_TRANSITION_CONTROL],
206-
tomoyo_same_transition_control_entry);
202+
tomoyo_same_transition_control);
207203
out:
208204
tomoyo_put_name(e.domainname);
209205
tomoyo_put_name(e.program);
@@ -292,19 +288,17 @@ static u8 tomoyo_transition_type(const struct tomoyo_path_info *domainname,
292288
return type;
293289
}
294290

295-
static bool tomoyo_same_aggregator_entry(const struct tomoyo_acl_head *a,
296-
const struct tomoyo_acl_head *b)
291+
static bool tomoyo_same_aggregator(const struct tomoyo_acl_head *a,
292+
const struct tomoyo_acl_head *b)
297293
{
298-
const struct tomoyo_aggregator_entry *p1 = container_of(a, typeof(*p1),
299-
head);
300-
const struct tomoyo_aggregator_entry *p2 = container_of(b, typeof(*p2),
301-
head);
294+
const struct tomoyo_aggregator *p1 = container_of(a, typeof(*p1), head);
295+
const struct tomoyo_aggregator *p2 = container_of(b, typeof(*p2), head);
302296
return p1->original_name == p2->original_name &&
303297
p1->aggregated_name == p2->aggregated_name;
304298
}
305299

306300
/**
307-
* tomoyo_update_aggregator_entry - Update "struct tomoyo_aggregator_entry" list.
301+
* tomoyo_update_aggregator_entry - Update "struct tomoyo_aggregator" list.
308302
*
309303
* @original_name: The original program's name.
310304
* @aggregated_name: The program name to use.
@@ -318,7 +312,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
318312
const char *aggregated_name,
319313
const bool is_delete)
320314
{
321-
struct tomoyo_aggregator_entry e = { };
315+
struct tomoyo_aggregator e = { };
322316
int error = is_delete ? -ENOENT : -ENOMEM;
323317

324318
if (!tomoyo_correct_path(original_name) ||
@@ -331,15 +325,15 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
331325
goto out;
332326
error = tomoyo_update_policy(&e.head, sizeof(e), is_delete,
333327
&tomoyo_policy_list[TOMOYO_ID_AGGREGATOR],
334-
tomoyo_same_aggregator_entry);
328+
tomoyo_same_aggregator);
335329
out:
336330
tomoyo_put_name(e.original_name);
337331
tomoyo_put_name(e.aggregated_name);
338332
return error;
339333
}
340334

341335
/**
342-
* tomoyo_write_aggregator_policy - Write "struct tomoyo_aggregator_entry" list.
336+
* tomoyo_write_aggregator - Write "struct tomoyo_aggregator" list.
343337
*
344338
* @data: String to parse.
345339
* @is_delete: True if it is a delete request.
@@ -348,7 +342,7 @@ static int tomoyo_update_aggregator_entry(const char *original_name,
348342
*
349343
* Caller holds tomoyo_read_lock().
350344
*/
351-
int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
345+
int tomoyo_write_aggregator(char *data, const bool is_delete)
352346
{
353347
char *cp = strchr(data, ' ');
354348

@@ -359,7 +353,7 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
359353
}
360354

361355
/**
362-
* tomoyo_find_or_assign_new_domain - Create a domain.
356+
* tomoyo_assign_domain - Create a domain.
363357
*
364358
* @domainname: The name of domain.
365359
* @profile: Profile number to assign if the domain was newly created.
@@ -368,9 +362,8 @@ int tomoyo_write_aggregator_policy(char *data, const bool is_delete)
368362
*
369363
* Caller holds tomoyo_read_lock().
370364
*/
371-
struct tomoyo_domain_info *tomoyo_find_or_assign_new_domain(const char *
372-
domainname,
373-
const u8 profile)
365+
struct tomoyo_domain_info *tomoyo_assign_domain(const char *domainname,
366+
const u8 profile)
374367
{
375368
struct tomoyo_domain_info *entry;
376369
struct tomoyo_domain_info *domain = NULL;
@@ -430,10 +423,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
430423
int retval = -ENOMEM;
431424
bool need_kfree = false;
432425
struct tomoyo_path_info rn = { }; /* real name */
433-
struct tomoyo_path_info ln; /* last name */
434426

435-
ln.name = tomoyo_get_last_name(old_domain);
436-
tomoyo_fill_path_info(&ln);
437427
mode = tomoyo_init_request_info(&r, NULL, TOMOYO_MAC_FILE_EXECUTE);
438428
is_enforce = (mode == TOMOYO_CONFIG_ENFORCING);
439429
if (!tmp)
@@ -454,7 +444,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
454444

455445
/* Check 'aggregator' directive. */
456446
{
457-
struct tomoyo_aggregator_entry *ptr;
447+
struct tomoyo_aggregator *ptr;
458448
list_for_each_entry_rcu(ptr, &tomoyo_policy_list
459449
[TOMOYO_ID_AGGREGATOR], head.list) {
460450
if (ptr->head.is_deleted ||
@@ -517,7 +507,7 @@ int tomoyo_find_next_domain(struct linux_binprm *bprm)
517507
if (error < 0)
518508
goto done;
519509
}
520-
domain = tomoyo_find_or_assign_new_domain(tmp, old_domain->profile);
510+
domain = tomoyo_assign_domain(tmp, old_domain->profile);
521511
done:
522512
if (domain)
523513
goto out;

0 commit comments

Comments
 (0)