From: Wang Weiyang <wangweiyang2@huawei.com>
To: <zohar@linux.ibm.com>, <dmitry.kasatkin@gmail.com>,
<jmorris@namei.org>, <serge@hallyn.com>
Cc: <linux-security-module@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-integrity@vger.kernel.org>,
<wangweiyang2@huawei.com>
Subject: [PATCH 1/3] securityfs: Append line feed to /sys/kernel/security/lsm
Date: Thu, 5 May 2022 21:22:59 +0800 [thread overview]
Message-ID: <20220505132301.124832-2-wangweiyang2@huawei.com> (raw)
In-Reply-To: <20220505132301.124832-1-wangweiyang2@huawei.com>
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@huawei.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
next prev parent reply other threads:[~2022-05-05 13:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-05 13:22 [PATCH 0/3] Append line feed to files in securityfs Wang Weiyang
2022-05-05 13:22 ` Wang Weiyang [this message]
2022-05-05 16:29 ` [PATCH 1/3] securityfs: Append line feed to /sys/kernel/security/lsm Casey Schaufler
2022-05-05 13:23 ` [PATCH 2/3] evm: Append line feed to /sys/kernel/security/evm Wang Weiyang
2022-05-05 13:23 ` [PATCH 3/3] ima: Append line feed to ima/binary_runtime_measurements Wang Weiyang
2022-05-06 11:16 ` Mimi Zohar
2022-05-06 12:31 ` wangweiyang
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=20220505132301.124832-2-wangweiyang2@huawei.com \
--to=wangweiyang2@huawei.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=jmorris@namei.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=serge@hallyn.com \
--cc=zohar@linux.ibm.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