Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp264585imm; Mon, 4 Jun 2018 17:17:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK+Nbzk78cHRSFv2PL+afBk3pxCOC776GMa0UvXzoUuFifBn7tZAhrGKK4Sh1iYPKubFORN X-Received: by 2002:a65:644a:: with SMTP id s10-v6mr18807480pgv.360.1528157847153; Mon, 04 Jun 2018 17:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528157847; cv=none; d=google.com; s=arc-20160816; b=b+hFl/NYYZB0WrGAlBdGJFKZuWEzr6Wy0dEv+vLXfTqEsbp/zPazlmVPlNt8/rcC3q p220FoPKwojA7/ZheE7f59Q9550HB4oud4fyRBlO464kV5nmsUmPw3yo/4JOhZd3ulxo iU9cjWTT4A9s7FpJI8q8U7Q+SmV+leT/Ez3JWbuZlTXb04Fl72lHTkF9b3webtUeAfeh Ri1OYpoEP8Spmyufs0NKExgorB/9Nr1OVavIDpWX0uLZq0s7nXYhmWKPnxDhfMbU8MhW 3BBXwB1WAYdyD1AjDNEOijTHeVnsi2fchwco6YSimSzLD0M6nRn7IPkepWq9mf/eMM1X Ridg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=6/Rittlr1TyeIHP+t+TSE4Dev5/G2NB9UTQB1gYPhQw=; b=BEddag0n4TK0Oc6DBG+CLsYfazHDcngoZ4vdIZ66la5XqWhmcrtgsZsrdyWt1yjz+/ 3avHMLOEL/hVMZwjK0dv+yZtrGcQrlKeTY0EzMx5bHvT+pjSaOPh4GoGq7JK5FJBPm9W Tt2eKtSs4i25kccewPo0vG+OB2XUWFZekYf5r8CxBJlrK/g6EYFPZuH6gJRlkAoAYt3T 2wuIA/Mn7MVRsxBpkfg5FZJ4GrsRU900yfXtdfbBh3yvciCgtAe4KyONECHwnvxb5UjS Pp0APVAcsfFsHZ/fUCqc6Q61cA93zPN4MME0XcDIZGaQhkMCGIijIjUklGYJEtBvNk0l b2fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=i1YvBnX4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d203-v6si19769468pfd.182.2018.06.04.17.17.11; Mon, 04 Jun 2018 17:17:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=i1YvBnX4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751297AbeFEAQq (ORCPT + 99 others); Mon, 4 Jun 2018 20:16:46 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36339 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751042AbeFEAQp (ORCPT ); Mon, 4 Jun 2018 20:16:45 -0400 Received: by mail-lf0-f68.google.com with SMTP id u4-v6so708386lff.3 for ; Mon, 04 Jun 2018 17:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=6/Rittlr1TyeIHP+t+TSE4Dev5/G2NB9UTQB1gYPhQw=; b=i1YvBnX41hX8ChBIA/bG1U2yMz34GQ04zAP88F0unmLIfGPCJpFnIF0+jSke/zrzQ1 Sq3lNgDwcYwTZjVmHa5VkfaL06heUA2Ljv5oT59/SuEJScuMBVc6iTPGgRF+YHgDevYl WNCmSs+408htBy+n8+tcBFvdZyvWW8dBNFaRTbIGNMSHQEODYPANOr7W+Ct9gBtAfSed DbF8/HNKNgCIGRUBbakELt0R/rgkXmU0veXLqCgda5+wQasDAHSQWuJeGj08mmfUd32U b19kARetwQADMLDt8ILV4mapXgmLWbp+uq/S2B/YfC4PDTDfbA1jzxWwKSS9KCTTWoxJ rmuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=6/Rittlr1TyeIHP+t+TSE4Dev5/G2NB9UTQB1gYPhQw=; b=MzAgs73p/E4nILi4c1jXcqkJBRK1Ki+SKYGX10xbRYitX+T0TDukJybik3cYApVeCM BfMOPfdP9PslDjjtuxi0y9atV4WTbnjrZcjl0H8s9pQk7kqBltib2i7Rl8NSa3+muE5l PIPYOLCxRM6p/CqpSVHf/8DgREFWzANOfNTyqkZ60WoYsfc8GOTWJPlGk7J7pMpc7mPH 7TRkneg0OQg/bKIDfSBIis9jTfceMojDdfd7NRNYgb7MnLpJn3UBm0pB1FNf5JzRFBg0 5pDj3dponGCNOFw3nayh8wsx8u8jNCGRg79fYT1KU/F/sXP57zogoybpENgm9xhzaNvM Ar7Q== X-Gm-Message-State: APt69E2S4VhQek7ZMMsGGU7Z+EprUYmZZyzG6vTecxeby1D1kkJZX1fG 5Ot0a/RULIRl1DjbozCc0jdSKLsuqbhbXwcjAghK X-Received: by 2002:a19:a892:: with SMTP id r140-v6mr174206lfe.39.1528157803628; Mon, 04 Jun 2018 17:16:43 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a19:a911:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 17:16:42 -0700 (PDT) X-Originating-IP: [108.20.156.165] In-Reply-To: <20180604205455.2325754-4-stefanb@linux.vnet.ibm.com> References: <20180604205455.2325754-1-stefanb@linux.vnet.ibm.com> <20180604205455.2325754-4-stefanb@linux.vnet.ibm.com> From: Paul Moore Date: Mon, 4 Jun 2018 20:16:42 -0400 Message-ID: Subject: Re: [PATCH v3 3/4] ima: Do not audit if CONFIG_INTEGRITY_AUDIT is not set To: Stefan Berger Cc: zohar@linux.vnet.ibm.com, linux-integrity@vger.kernel.org, linux-audit@redhat.com, sgrubb@redhat.com, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 4, 2018 at 4:54 PM, Stefan Berger wrote: > If Integrity is not auditing, IMA shouldn't audit, either. > > Signed-off-by: Stefan Berger > --- > security/integrity/ima/Kconfig | 1 + > security/integrity/ima/ima_policy.c | 6 +++++- > security/integrity/integrity.h | 15 +++++++++++++++ > 3 files changed, 21 insertions(+), 1 deletion(-) > > diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig > index 6a8f67714c83..94c2151331aa 100644 > --- a/security/integrity/ima/Kconfig > +++ b/security/integrity/ima/Kconfig > @@ -12,6 +12,7 @@ config IMA > select TCG_TIS if TCG_TPM && X86 > select TCG_CRB if TCG_TPM && ACPI > select TCG_IBMVTPM if TCG_TPM && PPC_PSERIES > + select INTEGRITY_AUDIT if AUDIT > help > The Trusted Computing Group(TCG) runtime Integrity > Measurement Architecture(IMA) maintains a list of hash > diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c > index 3fcf0935468c..bc99713dfe57 100644 > --- a/security/integrity/ima/ima_policy.c > +++ b/security/integrity/ima/ima_policy.c > @@ -628,6 +628,9 @@ static int ima_lsm_rule_init(struct ima_rule_entry *entry, > static void ima_log_string_op(struct audit_buffer *ab, char *key, char *value, > bool (*rule_operator)(kuid_t, kuid_t)) > { > + if (!ab) > + return; > + > if (rule_operator == &uid_gt) > audit_log_format(ab, "%s>", key); > else if (rule_operator == &uid_lt) > @@ -649,7 +652,8 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) > bool uid_token; > int result = 0; > > - ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_INTEGRITY_RULE); > + ab = integrity_audit_log_start(NULL, GFP_KERNEL, > + AUDIT_INTEGRITY_RULE); There was a lot of confusion here, so this is understandable, but you should pass "audit_context()"[1] as the first parameter instead of NULL. Other than that this patch looks fine. [1] In Linus' tree at the moment you would need to use current->audit_context, but the audit PR heading to Linus during this merge window will introduce the "audit_context()" function which is preferable as we may need to change things around a bit in the near future. > entry->uid = INVALID_UID; > entry->fowner = INVALID_UID; > diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h > index 0bb372eed62a..e60473b13a8d 100644 > --- a/security/integrity/integrity.h > +++ b/security/integrity/integrity.h > @@ -15,6 +15,7 @@ > #include > #include > #include > +#include > > /* iint action cache flags */ > #define IMA_MEASURE 0x00000001 > @@ -199,6 +200,13 @@ static inline void evm_load_x509(void) > void integrity_audit_msg(int audit_msgno, struct inode *inode, > const unsigned char *fname, const char *op, > const char *cause, int result, int info); > + > +static inline struct audit_buffer * > +integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type) > +{ > + return audit_log_start(ctx, gfp_mask, type); > +} > + > #else > static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, > const unsigned char *fname, > @@ -206,4 +214,11 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, > int result, int info) > { > } > + > +static inline struct audit_buffer * > +integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type) > +{ > + return NULL; > +} > + > #endif > -- > 2.13.6 -- paul moore www.paul-moore.com