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 = { From patchwork Thu May 5 13:23:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Weiyang X-Patchwork-Id: 12839549 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 C8042C43217 for ; Thu, 5 May 2022 13:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379296AbiEEN2m (ORCPT ); Thu, 5 May 2022 09:28:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356785AbiEEN2i (ORCPT ); Thu, 5 May 2022 09:28:38 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA0635677B; Thu, 5 May 2022 06:24:56 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KvDtw45L9zhYv3; Thu, 5 May 2022 21:24:24 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) 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 2/3] evm: Append line feed to /sys/kernel/security/evm Date: Thu, 5 May 2022 21:23:00 +0800 Message-ID: <20220505132301.124832-3-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/evm output. It is little weird, so append LF to it. Example: / # cat /sys/kernel/security/evm 0/ # Signed-off-by: Wang Weiyang --- security/integrity/evm/evm_secfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c index 8a9db7dfca7e..6a46b62aabd4 100644 --- a/security/integrity/evm/evm_secfs.c +++ b/security/integrity/evm/evm_secfs.c @@ -45,7 +45,7 @@ static ssize_t evm_read_key(struct file *filp, char __user *buf, if (*ppos != 0) return 0; - sprintf(temp, "%d", (evm_initialized & ~EVM_SETUP_COMPLETE)); + sprintf(temp, "%d\n", (evm_initialized & ~EVM_SETUP_COMPLETE)); rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp)); return rc; From patchwork Thu May 5 13:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Weiyang X-Patchwork-Id: 12839550 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 B0B6BC4321E for ; Thu, 5 May 2022 13:25:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379310AbiEEN2n (ORCPT ); Thu, 5 May 2022 09:28:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377265AbiEEN2i (ORCPT ); Thu, 5 May 2022 09:28:38 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDCE95677D; Thu, 5 May 2022 06:24:56 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KvDtw5FdMzhYv6; Thu, 5 May 2022 21:24:24 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500023.china.huawei.com (7.185.36.83) 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:55 +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 3/3] ima: Append line feed to ima/binary_runtime_measurements Date: Thu, 5 May 2022 21:23:01 +0800 Message-ID: <20220505132301.124832-4-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 binary_runtime_measurements output. It is little weird, so append LF to it. Example: / # cat /sys/kernel/security/ima/binary_runtime_measurements ...imaboot_aggregate/ # Signed-off-by: Wang Weiyang --- security/integrity/ima/ima_fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c index cd1683dad3bf..0a2f9cb25b20 100644 --- a/security/integrity/ima/ima_fs.c +++ b/security/integrity/ima/ima_fs.c @@ -183,6 +183,7 @@ int ima_measurements_show(struct seq_file *m, void *v) show = IMA_SHOW_BINARY_OLD_STRING_FMT; field->field_show(m, show, &e->template_data[i]); } + seq_puts(m, "\n"); return 0; }