* [PATCH security-next] selinux: use sysfs_emit() to instead of scnprintf()
@ 2022-12-05 11:32 ye.xingchen
2022-12-06 20:26 ` Paul Moore
0 siblings, 1 reply; 3+ messages in thread
From: ye.xingchen @ 2022-12-05 11:32 UTC (permalink / raw)
To: paul; +Cc: stephen.smalley.work, eparis, selinux, linux-kernel
From: ye xingchen <ye.xingchen@zte.com.cn>
Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.
Signed-off-by: ye xingchen <ye.xingchen@zte.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 9a43af0ebd7d..517fe3454aec 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -174,7 +174,7 @@ int avc_get_hash_stats(struct selinux_avc *avc, 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(&avc->avc_cache.active_nodes),
slots_used, AVC_CACHE_SLOTS, max_chain_len);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH security-next] selinux: use sysfs_emit() to instead of scnprintf()
2022-12-05 11:32 [PATCH security-next] selinux: use sysfs_emit() to instead of scnprintf() ye.xingchen
@ 2022-12-06 20:26 ` Paul Moore
2022-12-06 22:49 ` Paul Moore
0 siblings, 1 reply; 3+ messages in thread
From: Paul Moore @ 2022-12-06 20:26 UTC (permalink / raw)
To: ye.xingchen; +Cc: stephen.smalley.work, eparis, selinux, linux-kernel
On Mon, Dec 5, 2022 at 6:32 AM <ye.xingchen@zte.com.cn> wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
>
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> ---
> security/selinux/avc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
SELinux uses securityfs, not sysfs, for entries under /sys/fs/selinux.
> diff --git a/security/selinux/avc.c b/security/selinux/avc.c
> index 9a43af0ebd7d..517fe3454aec 100644
> --- a/security/selinux/avc.c
> +++ b/security/selinux/avc.c
> @@ -174,7 +174,7 @@ int avc_get_hash_stats(struct selinux_avc *avc, 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(&avc->avc_cache.active_nodes),
> slots_used, AVC_CACHE_SLOTS, max_chain_len);
> --
> 2.25.1
--
paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH security-next] selinux: use sysfs_emit() to instead of scnprintf()
2022-12-06 20:26 ` Paul Moore
@ 2022-12-06 22:49 ` Paul Moore
0 siblings, 0 replies; 3+ messages in thread
From: Paul Moore @ 2022-12-06 22:49 UTC (permalink / raw)
To: ye.xingchen; +Cc: stephen.smalley.work, eparis, selinux, linux-kernel
On Tue, Dec 6, 2022 at 3:26 PM Paul Moore <paul@paul-moore.com> wrote:
>
> On Mon, Dec 5, 2022 at 6:32 AM <ye.xingchen@zte.com.cn> wrote:
> > From: ye xingchen <ye.xingchen@zte.com.cn>
> >
> > Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> > should only use sysfs_emit() or sysfs_emit_at() when formatting the
> > value to be returned to user space.
> >
> > Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> > ---
> > security/selinux/avc.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
>
> SELinux uses securityfs, not sysfs, for entries under /sys/fs/selinux.
Sorry, a little mental mistake in the above, SELinux uses *selinuxfs*
and not sysfs.
Thanks to the little birdie that pointed this out :)
--
paul-moore.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-06 22:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-05 11:32 [PATCH security-next] selinux: use sysfs_emit() to instead of scnprintf() ye.xingchen
2022-12-06 20:26 ` Paul Moore
2022-12-06 22:49 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox