Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1391595ybh; Thu, 16 Jul 2020 10:45:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPgEOTvkZgnXsm0L5iaJ8jjyr3pN4RQMV770xE8EbZlPsrkVJyID5j5x2GgTqfJ5cPiD3a X-Received: by 2002:a17:906:fad4:: with SMTP id lu20mr3396773ejb.1.1594921550610; Thu, 16 Jul 2020 10:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594921550; cv=none; d=google.com; s=arc-20160816; b=ZbQlEdR162B59O8T64AB65E5piccR5VGRXAMVOKEZOEEZU3YDrWkpBeXqFvohvg7ym JxDtiEzmM6p9EB6VGdjtdAeUJ5KiPA1qzbUWPKln7sXC1nKB0H7noMBx1LaMhmRiC42B kUugZQRWufvUU4ryhDNPUsqoa6Z6+Tobc+1o9LSiiyQPOz3EsF7N2x88keAEYA8V3Qa1 q0mgYnfBYTlyuUcjYBRvUfGAEwgCGXKu7wsoM7EeHbhKQshs8EOTSJEm+1y2LPNC7aMq Z4M8iAiVIKzZzchsD7AxFriByq3DOzDyaW39hHd8UPGTKhLXzIf96C8mU9GPuvYSxhDL baxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=uMfFSH8BKWRMGn0Ob/aAF/poLIpxKXFWWoJsEWCn7j0=; b=kOTbPQvCcRD+6QSJCdCEMGm3YrRtRclorYOzhTBi1jAVhPiMTAXTsmQqkWtgkO/acB HbV9Fjqg8XMiWHs1aTdtwpNJjG3+z/Y92b/AMzirHXMtaHPuhAe/7YhBZKlc3ZqljRO3 aGXNbG34uRv15RU2dT5FfGHZgilq3MyiXlJvwOidrMNSNysIjBFsQC0nfZ79OoPuBTx9 +TX39kOp9ZZO5Colo9xXigjmcAR7db0lEblEu7UNkoy+tVGIzpjBDrint3HbI0hhySv8 2az3E1OS/+Vl2VvZlOqONM9lF4e0H77VN3xjO7vB3Yo3QzKjQ/3KMx4psGZ6bonaj7Ql yN7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=dIjUJK4P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v6si3446787ejw.169.2020.07.16.10.45.28; Thu, 16 Jul 2020 10:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=dIjUJK4P; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729541AbgGPRo0 (ORCPT + 99 others); Thu, 16 Jul 2020 13:44:26 -0400 Received: from linux.microsoft.com ([13.77.154.182]:54476 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729415AbgGPRoE (ORCPT ); Thu, 16 Jul 2020 13:44:04 -0400 Received: from localhost.localdomain (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id 467EC20B490C; Thu, 16 Jul 2020 10:44:03 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 467EC20B490C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1594921443; bh=uMfFSH8BKWRMGn0Ob/aAF/poLIpxKXFWWoJsEWCn7j0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dIjUJK4PMD8yUDiTmHnKezBpnWOWLdnvWlPcbEvwaoPlheDB5Lf9uoT4UVTIYS99Z OjjKf6ICdE+C85mxymMBAUdhtHOjpH7pT3MGOY0ZWys/t8ptW5+pVuN5opJfIwi9lk DPQY3JzF3Hqqjzhu9/jJfCzlvUvmnidkYXGySyMU= From: Lakshmi Ramasubramanian To: zohar@linux.ibm.com, stephen.smalley.work@gmail.com, casey@schaufler-ca.com Cc: jmorris@namei.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] IMA: Define an IMA hook to measure LSM data Date: Thu, 16 Jul 2020 10:43:48 -0700 Message-Id: <20200716174351.20128-3-nramas@linux.microsoft.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200716174351.20128-1-nramas@linux.microsoft.com> References: <20200716174351.20128-1-nramas@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org IMA subsystem needs to define an IMA hook that the security modules can call to measure critical data of the security modules. Define a new IMA hook, namely ima_lsm_state(), that the security modules can call to measure data. Signed-off-by: Lakshmi Ramasubramanian --- include/linux/ima.h | 4 ++++ security/integrity/ima/ima_main.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/ima.h b/include/linux/ima.h index 9164e1534ec9..7e2686f4953a 100644 --- a/include/linux/ima.h +++ b/include/linux/ima.h @@ -26,6 +26,7 @@ extern int ima_post_read_file(struct file *file, void *buf, loff_t size, extern void ima_post_path_mknod(struct dentry *dentry); extern int ima_file_hash(struct file *file, char *buf, size_t buf_size); extern void ima_kexec_cmdline(const void *buf, int size); +extern void ima_lsm_state(const char *lsm_event_name, const void *buf, int size); #ifdef CONFIG_IMA_KEXEC extern void ima_add_kexec_buffer(struct kimage *image); @@ -104,6 +105,9 @@ static inline int ima_file_hash(struct file *file, char *buf, size_t buf_size) } static inline void ima_kexec_cmdline(const void *buf, int size) {} + +static inline void ima_lsm_state(const char *lsm_event_name, + const void *buf, int size) {} #endif /* CONFIG_IMA */ #ifndef CONFIG_IMA_KEXEC diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 8351b2fd48e0..04d9a1d35300 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -835,6 +835,23 @@ void ima_kexec_cmdline(const void *buf, int size) KEXEC_CMDLINE, 0, NULL); } +/** + * ima_lsm_state - measure LSM specific state + * @lsm_event_name: LSM event + * @buf: pointer to buffer containing LSM specific state + * @size: Number of bytes in buf + * + * Buffers can only be measured, not appraised. + */ +void ima_lsm_state(const char *lsm_event_name, const void *buf, int size) +{ + if (!lsm_event_name || !buf || !size) + return; + + process_buffer_measurement(buf, size, lsm_event_name, + LSM_STATE, 0, NULL); +} + static int __init init_ima(void) { int error; -- 2.27.0