• R/O
  • HTTP
  • SSH
  • HTTPS

tomoyo-test1: Commit

This is a test repository.


Commit MetaInfo

Révisionf702e1107601230eec707739038a89018ea3468d (tree)
l'heure2021-12-15 20:13:55
AuteurTetsuo Handa <penguin-kernel@I-lo...>
CommiterTetsuo Handa

Message de Log

tomoyo: use hwight16() in tomoyo_domain_quota_is_ok()

hwight16() is much faster. While we are at it, no need to include
"perm =" part into data_race() macro, for perm is a local variable
that cannot be accessed by other threads.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>

Change Summary

Modification

--- a/security/tomoyo/util.c
+++ b/security/tomoyo/util.c
@@ -1056,7 +1056,6 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
10561056 list_for_each_entry_rcu(ptr, &domain->acl_info_list, list,
10571057 srcu_read_lock_held(&tomoyo_ss)) {
10581058 u16 perm;
1059- u8 i;
10601059
10611060 if (ptr->is_deleted)
10621061 continue;
@@ -1067,23 +1066,23 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
10671066 */
10681067 switch (ptr->type) {
10691068 case TOMOYO_TYPE_PATH_ACL:
1070- data_race(perm = container_of(ptr, struct tomoyo_path_acl, head)->perm);
1069+ perm = data_race(container_of(ptr, struct tomoyo_path_acl, head)->perm);
10711070 break;
10721071 case TOMOYO_TYPE_PATH2_ACL:
1073- data_race(perm = container_of(ptr, struct tomoyo_path2_acl, head)->perm);
1072+ perm = data_race(container_of(ptr, struct tomoyo_path2_acl, head)->perm);
10741073 break;
10751074 case TOMOYO_TYPE_PATH_NUMBER_ACL:
1076- data_race(perm = container_of(ptr, struct tomoyo_path_number_acl, head)
1075+ perm = data_race(container_of(ptr, struct tomoyo_path_number_acl, head)
10771076 ->perm);
10781077 break;
10791078 case TOMOYO_TYPE_MKDEV_ACL:
1080- data_race(perm = container_of(ptr, struct tomoyo_mkdev_acl, head)->perm);
1079+ perm = data_race(container_of(ptr, struct tomoyo_mkdev_acl, head)->perm);
10811080 break;
10821081 case TOMOYO_TYPE_INET_ACL:
1083- data_race(perm = container_of(ptr, struct tomoyo_inet_acl, head)->perm);
1082+ perm = data_race(container_of(ptr, struct tomoyo_inet_acl, head)->perm);
10841083 break;
10851084 case TOMOYO_TYPE_UNIX_ACL:
1086- data_race(perm = container_of(ptr, struct tomoyo_unix_acl, head)->perm);
1085+ perm = data_race(container_of(ptr, struct tomoyo_unix_acl, head)->perm);
10871086 break;
10881087 case TOMOYO_TYPE_MANUAL_TASK_ACL:
10891088 perm = 0;
@@ -1091,9 +1090,7 @@ bool tomoyo_domain_quota_is_ok(struct tomoyo_request_info *r)
10911090 default:
10921091 perm = 1;
10931092 }
1094- for (i = 0; i < 16; i++)
1095- if (perm & (1 << i))
1096- count++;
1093+ count += hweight16(perm);
10971094 }
10981095 if (count < tomoyo_profile(domain->ns, domain->profile)->
10991096 pref[TOMOYO_PREF_MAX_LEARNING_ENTRY])
Afficher sur ancien navigateur de dépôt.