From patchwork Thu May 5 13:22:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Weiyang X-Patchwork-Id: 12839547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 575D9C433EF for ; Thu, 5 May 2022 13:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377309AbiEEN2k (ORCPT ); Thu, 5 May 2022 09:28:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232859AbiEEN2h (ORCPT ); Thu, 5 May 2022 09:28:37 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BF4244A0A; Thu, 5 May 2022 06:24:56 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KvDtw2tg9zhYty; Thu, 5 May 2022 21:24:24 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 21:24:54 +0800 Received: from ubuntu1804.huawei.com (10.67.174.152) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 5 May 2022 21:24:54 +0800 From: Wang Weiyang To: , , , CC: , , , Subject: [PATCH 1/3] securityfs: Append line feed to /sys/kernel/security/lsm Date: Thu, 5 May 2022 21:22:59 +0800 Message-ID: <20220505132301.124832-2-wangweiyang2@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220505132301.124832-1-wangweiyang2@huawei.com> References: <20220505132301.124832-1-wangweiyang2@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.174.152] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected Precedence: bulk List-ID: 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 --- 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 = {