[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250315141209936kL2XHnj3IaE2dYcjQZlnV@zte.com.cn>
Date: Sat, 15 Mar 2025 14:12:09 +0800 (CST)
From: <xie.ludan@....com.cn>
To: <paul@...l-moore.com>
Cc: <stephen.smalley.work@...il.com>, <omosnace@...hat.com>,
<selinux@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: [PATCH linux-next] selinux: avc: use sysfs_emit() instead of scnprintf()
From: XieLudan <xie.ludan@....com.cn>
Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.
Signed-off-by: XieLudan <xie.ludan@....com.cn>
---
security/selinux/avc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index 4b4837a20225..007bd94975c0 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -164,7 +164,7 @@ int avc_get_hash_stats(char *page)
rcu_read_unlock();
- return scnprintf(page, PAGE_SIZE, "entries: %d\nbuckets used: %d/%d\n"
+ return sysfs_emit(page, "entries: %d\nbuckets used: %d/%d\n"
"longest chain: %d\n",
atomic_read(&selinux_avc.avc_cache.active_nodes),
slots_used, AVC_CACHE_SLOTS, max_chain_len);
--
2.25.1
<div class="zcontentRow"><p><span style="font-family: Arial, Helvetica, "Microsoft Yahei", sans-serif; background-color: rgb(255, 255, 255);">From: XieLudan <xie.ludan@....com.cn></span></p><p><br></p><p>Follow the advice in Documentation/filesystems/sysfs.rst:</p><p>show() should only use sysfs_emit() or sysfs_emit_at() when formatting</p><p>the value to be returned to user space.</p><p><br></p><p>Signed-off-by: XieLudan <xie.ludan@....com.cn></p><p>---</p><p> security/selinux/avc.c | 2 +-</p><p> 1 file changed, 1 insertion(+), 1 deletion(-)</p><p><br></p><p>diff --git a/security/selinux/avc.c b/security/selinux/avc.c</p><p>index 4b4837a20225..007bd94975c0 100644</p><p>--- a/security/selinux/avc.c</p><p>+++ b/security/selinux/avc.c</p><p>@@ -164,7 +164,7 @@ int avc_get_hash_stats(char *page)</p><p> </p><p> <span style="white-space:pre"> </span>rcu_read_unlock();</p><p> </p><p>-<span style="white-space:pre"> </span>return scnprintf(page, PAGE_SIZE, "entries: %d\nbuckets used: %d/%d\n"</p><p>+<span style="white-space:pre"> </span>return sysfs_emit(page, "entries: %d\nbuckets used: %d/%d\n"</p><p> <span style="white-space:pre"> </span> "longest chain: %d\n",</p><p> <span style="white-space:pre"> </span> atomic_read(&selinux_avc.avc_cache.active_nodes),</p><p> <span style="white-space:pre"> </span> slots_used, AVC_CACHE_SLOTS, max_chain_len);</p><p>-- </p><p>2.25.1</p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p><p style="font-size:14px;font-family:微软雅黑,Microsoft YaHei;"><br></p></div>
Powered by blists - more mailing lists