[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220505132301.124832-2-wangweiyang2@huawei.com>
Date: Thu, 5 May 2022 21:22:59 +0800
From: Wang Weiyang <wangweiyang2@...wei.com>
To: <zohar@...ux.ibm.com>, <dmitry.kasatkin@...il.com>,
<jmorris@...ei.org>, <serge@...lyn.com>
CC: <linux-security-module@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-integrity@...r.kernel.org>,
<wangweiyang2@...wei.com>
Subject: [PATCH 1/3] securityfs: Append line feed to /sys/kernel/security/lsm
There is no LF in /sys/kerne/security/lsm output. It is a little weird,
so append LF to it.
Example:
/ # cat /sys/kernel/security/lsm
capability,selinux/ #
Signed-off-by: Wang Weiyang <wangweiyang2@...wei.com>
---
security/inode.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/security/inode.c b/security/inode.c
index 6c326939750d..bfd5550fa129 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -318,8 +318,20 @@ static struct dentry *lsm_dentry;
static ssize_t lsm_read(struct file *filp, char __user *buf, size_t count,
loff_t *ppos)
{
- return simple_read_from_buffer(buf, count, ppos, lsm_names,
- strlen(lsm_names));
+ char *tmp;
+ ssize_t len = strlen(lsm_names);
+ ssize_t rc;
+
+ tmp = kmalloc(len + 2, GFP_KERNEL);
+ if (!tmp)
+ return -ENOMEM;
+
+ scnprintf(tmp, len + 2, "%s\n", lsm_names);
+ rc = simple_read_from_buffer(buf, count, ppos, tmp, strlen(tmp));
+
+ kfree(tmp);
+
+ return rc;
}
static const struct file_operations lsm_ops = {
--
2.17.1
Powered by blists - more mailing lists