From: Canfeng Guo <guocanfeng@uniontech.com>
To: paul@paul-moore.com
Cc: stephen.smalley.work@gmail.com, omosnace@redhat.com,
selinux@vger.kernel.org, linux-kernel@vger.kernel.org,
Canfeng Guo <guocanfeng@uniontech.com>
Subject: [RPC] Topic: Issues and Testing Regarding SELinx AVC Cache Modification
Date: Mon, 15 Jul 2024 09:43:37 +0800 [thread overview]
Message-ID: <20240715014337.11625-1-guocanfeng@uniontech.com> (raw)
When calling avc_insert to add nodes to the avc cache, they are inserted into
the head of the hash chain. Similarly, avc_calim_node removes nodes from
the head of the same chain. so, SElinux will delete the latest added cache
infromation.
I question whether the deletion logic proposed in the patch is more appropriate
than the current implementation, or whether alternative mechanisms such as
LRU caching are beneficial.
In my testing environment, I applied the above patch when avc_cache.solt and
cache_threshold were both set to 512 by default. I only have over 280 nodes
in my cache, and the longest observation length of the AVC cache linked list
is only 7 entries. Considering this small size, the cost of traversing the
list is minimal, and such modifications may not incur additional costs.
However, I don't know how to design a test case to verify its cost.
And I cannot prove that this patch is beneficial.
I attempted to simulate a more demanding scenario by increasing the cache_threshold
to 2048 in order to establish a longer linked list of AVC caches, but
I was unable to generate more than 2048 AVC records, possibly due to the need
for a highly complex environment with numerous different SID interactions.
Therefore, I have two questions:
The necessity of modification:
Considering its potential impact on the cache performance of SELinx AVC,
is it worth investing effort into this modification?, i think that in most cases,
this modification is not necessart.
Verification method:
If making such modifications is reasonable, how can I effectively
measure its impact on system performance?
Signed-off-by: Canfeng Guo <guocanfeng@uniontech.com>
---
security/selinux/avc.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index 32eb67fb3e42..9999028660c9 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -477,6 +477,9 @@ static inline int avc_reclaim_node(void)
rcu_read_lock();
hlist_for_each_entry(node, head, list) {
+ while(node->next){
+ node = node->next;
+ }
avc_node_delete(node);
avc_cache_stats_incr(reclaims);
ecx++;
--
2.20.1
next reply other threads:[~2024-07-15 1:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-15 1:43 Canfeng Guo [this message]
2024-07-15 13:46 ` Stephen Smalley
2024-07-15 13:48 ` Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240715014337.11625-1-guocanfeng@uniontech.com \
--to=guocanfeng@uniontech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®