From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B2CAC433DF for ; Wed, 24 Jun 2020 00:07:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42D3D2078E for ; Wed, 24 Jun 2020 00:07:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore-com.20150623.gappssmtp.com header.i=@paul-moore-com.20150623.gappssmtp.com header.b="t5sN2GgB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387940AbgFXAH2 (ORCPT ); Tue, 23 Jun 2020 20:07:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387584AbgFXAH1 (ORCPT ); Tue, 23 Jun 2020 20:07:27 -0400 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC26DC061755 for ; Tue, 23 Jun 2020 17:07:25 -0700 (PDT) Received: by mail-ed1-x541.google.com with SMTP id x24so134236edi.4 for ; Tue, 23 Jun 2020 17:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wYef0IlAA5cnvfvaD0Ws/jCKLqqDtLAVNioagh3fxFo=; b=t5sN2GgB6Vwi68B+oh29pa7pkMP4cZNgHjmADZPfF23wYRyavKOWBHEcL5ZtKvnGMN D0gsG07XLLr6RcEq1i+IusZ880iwgHJVt6zNq3yfL1xQXd1ji+IkRbTaWVXaKreilrBU T0T+/jcUySEfnlKYR1xW6pRMoIn61kJtnV6YBtcIrw/Wv/G0gpeN3jTnwI3jMfCF2Pju NtzFQBPyy2jQUttqO9n6yxiqn56vAwZ1IiByNO4vuGf/qa9bqndjoQCuaWmgqj3EZKar lOOLEjpBCETVEO2uSMlfhdUrjCp0WRs89LLvFfGTiOGG15dUpV8OkiPdACmTudaFOt8J kjLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wYef0IlAA5cnvfvaD0Ws/jCKLqqDtLAVNioagh3fxFo=; b=S1xpFWF2P0nwI6Jb7nJRQluwRtFlrJyDxN9y7LJMM0ttGKHt4txbVNpe16SaaS80lL AStCUt9qCv+bIBQv6z1A1kAVoGd9o6ekRFldOV9h0SlTQbrQ0lChW69FrfxW/lOrhJfi vOM0RA6OvgXLDukkOmPvYm++HUUOLv0UNHPzMbDuDFY6eiUHDGrjrbu4PcRpmlUm/ZoI L4J6c7nNjAeV/dGTwWY7KpW7MCktCepgPYDdnx+AZvVaaWRatB5u1pVjCkVpx/gnrKEZ IyMrCx0ZNm/Bv/e500Y60hEZWu3qRbcmZsEkZZbF1Ytv+G5HEaZVpaicjx8buMm9GxPN 7jcg== X-Gm-Message-State: AOAM532f8i2ME6TcFBciqhVC0idXFnPr5X3MGyzWDKQEHXU/kEtPk7Od XEPitEwWzQjsIclVzUXmv0wZBD/gSUYX5ceRsFKB X-Google-Smtp-Source: ABdhPJxm2K+GHRjbkAJL7JkYWCiCsE49AHvZ3AgzIC+2MhsncYMq9OfsaBZK3cyOIwmZUZDbN96x/rMx2egaXaIUw38= X-Received: by 2002:aa7:de08:: with SMTP id h8mr23618936edv.164.1592957244179; Tue, 23 Jun 2020 17:07:24 -0700 (PDT) MIME-Version: 1.0 References: <20200618211012.2823-1-nramas@linux.microsoft.com> In-Reply-To: <20200618211012.2823-1-nramas@linux.microsoft.com> From: Paul Moore Date: Tue, 23 Jun 2020 20:07:13 -0400 Message-ID: Subject: Re: [PATCH v3 1/2] integrity: Add errno field in audit message To: Lakshmi Ramasubramanian Cc: zohar@linux.ibm.com, sgrubb@redhat.com, rgb@redhat.com, linux-integrity@vger.kernel.org, linux-audit@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 Thu, Jun 18, 2020 at 5:10 PM Lakshmi Ramasubramanian wrote: > > Error code is not included in the audit messages logged by > the integrity subsystem. > > Define a new function integrity_audit_message() that takes error code > in the "errno" parameter. Add "errno" field in the audit messages logged > by the integrity subsystem and set the value passed in the "errno" > parameter. > > [ 6.303048] audit: type=1804 audit(1592506281.627:2): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel op=measuring_key cause=ENOMEM comm="swapper/0" name=".builtin_trusted_keys" res=0 errno=-12 > > [ 7.987647] audit: type=1802 audit(1592506283.312:9): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=policy_update cause=completed comm="systemd" res=1 errno=0 > > [ 8.019432] audit: type=1804 audit(1592506283.344:10): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=measuring_kexec_cmdline cause=hashing_error comm="systemd" name="kexec-cmdline" res=0 errno=-22 > > Signed-off-by: Lakshmi Ramasubramanian > Suggested-by: Steve Grubb > Suggested-by: Mimi Zohar > --- > security/integrity/integrity.h | 13 +++++++++++++ > security/integrity/integrity_audit.c | 11 ++++++++++- > 2 files changed, 23 insertions(+), 1 deletion(-) The audit record changes look good to me. Acked-by: Paul Moore > diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h > index 16c1894c29bb..413c803c5208 100644 > --- a/security/integrity/integrity.h > +++ b/security/integrity/integrity.h > @@ -239,6 +239,11 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, > const unsigned char *fname, const char *op, > const char *cause, int result, int info); > > +void integrity_audit_message(int audit_msgno, struct inode *inode, > + const unsigned char *fname, const char *op, > + const char *cause, int result, int info, > + int errno); > + > static inline struct audit_buffer * > integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type) > { > @@ -253,6 +258,14 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, > { > } > > +static inline void integrity_audit_message(int audit_msgno, > + struct inode *inode, > + const unsigned char *fname, > + const char *op, const char *cause, > + int result, int info, int errno) > +{ > +} > + > static inline struct audit_buffer * > integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type) > { > diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c > index 5109173839cc..f25e7df099c8 100644 > --- a/security/integrity/integrity_audit.c > +++ b/security/integrity/integrity_audit.c > @@ -28,6 +28,15 @@ __setup("integrity_audit=", integrity_audit_setup); > void integrity_audit_msg(int audit_msgno, struct inode *inode, > const unsigned char *fname, const char *op, > const char *cause, int result, int audit_info) > +{ > + integrity_audit_message(audit_msgno, inode, fname, op, cause, > + result, audit_info, 0); > +} > + > +void integrity_audit_message(int audit_msgno, struct inode *inode, > + const unsigned char *fname, const char *op, > + const char *cause, int result, int audit_info, > + int errno) > { > struct audit_buffer *ab; > char name[TASK_COMM_LEN]; > @@ -53,6 +62,6 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, > audit_log_untrustedstring(ab, inode->i_sb->s_id); > audit_log_format(ab, " ino=%lu", inode->i_ino); > } > - audit_log_format(ab, " res=%d", !result); > + audit_log_format(ab, " res=%d errno=%d", !result, errno); > audit_log_end(ab); > } > -- > 2.27.0 > -- paul moore www.paul-moore.com From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C019C433E0 for ; Wed, 24 Jun 2020 00:07:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D07A20C09 for ; Wed, 24 Jun 2020 00:07:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K4JXjdcP" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D07A20C09 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=paul-moore.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-audit-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592957271; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nY/E0NCGKIoCIBBNeMGl6mJQQ50oM0x+qWxb9BjAZh0=; b=K4JXjdcPbUq/1RVj7eIUQ+5SOv3PwxTY7BpOw3vJe1BbXP5IWey6NrSgff/IkuK57jmsJ2 O8rxuODt8IQOYjK5gQvtltm7vLEskKqsaQB7jxA5CAS1tz9eBqygB9fBxhEAeZ+cjz4hEX 82Ini9UnPxrPcHQWdxgipZvLBOk0eEM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-R1ixE7CzPJqdfc13-rsdQA-1; Tue, 23 Jun 2020 20:07:43 -0400 X-MC-Unique: R1ixE7CzPJqdfc13-rsdQA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2029800D5C; Wed, 24 Jun 2020 00:07:39 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12E347166A; Wed, 24 Jun 2020 00:07:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B0E6833CF; Wed, 24 Jun 2020 00:07:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 05O07YPv014574 for ; Tue, 23 Jun 2020 20:07:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id B17EF10D14E1; Wed, 24 Jun 2020 00:07:34 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AD0A710D14D0 for ; Wed, 24 Jun 2020 00:07:31 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76DCF858EE2 for ; Wed, 24 Jun 2020 00:07:31 +0000 (UTC) Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-Yg0esgCZMLipUc2lx5ngDg-1; Tue, 23 Jun 2020 20:07:25 -0400 X-MC-Unique: Yg0esgCZMLipUc2lx5ngDg-1 Received: by mail-ed1-f65.google.com with SMTP id z17so122039edr.9 for ; Tue, 23 Jun 2020 17:07:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wYef0IlAA5cnvfvaD0Ws/jCKLqqDtLAVNioagh3fxFo=; b=nrBxRZv6gkDlNjkqXRXAW1y285eG6Bwro8eJcSuP5rRMymBbiu3vv774jWierNzZNm OOrFC/tiQOhzx4ze/FTjT1oHJxugNrhl4nowZPHtMWJWFcXHmcZOBIRhW0YdS8Of8l5I p6ZxtaNvLfv68jD/NUwRwdWA5g0zrvOTDIyLnaLsKCzueq0zJztIAGs8BtGpzHa95QuK MutEk1Tzh6ZtvbBIfdzll4vjFSmQzUhf3ZTSHTABwgJPJcr4RSvx/OULbv1bMy3SbZJI GB/yzLE7a1u8hJ8QTT9G17SvQS1Qua9jXpF+9Hhnxz1+lat8N/54l+r8SJpTMBwiOG9Y T4/g== X-Gm-Message-State: AOAM530opgWplgRti3mmmlzoYDVt11FMN2PtmFxWhW+6gcFzWTLf9/Wl f2NMq6Cs/tsKKkw6pZVR6OUnZck/bnoVCwODz9O6 X-Google-Smtp-Source: ABdhPJxm2K+GHRjbkAJL7JkYWCiCsE49AHvZ3AgzIC+2MhsncYMq9OfsaBZK3cyOIwmZUZDbN96x/rMx2egaXaIUw38= X-Received: by 2002:aa7:de08:: with SMTP id h8mr23618936edv.164.1592957244179; Tue, 23 Jun 2020 17:07:24 -0700 (PDT) MIME-Version: 1.0 References: <20200618211012.2823-1-nramas@linux.microsoft.com> In-Reply-To: <20200618211012.2823-1-nramas@linux.microsoft.com> From: Paul Moore Date: Tue, 23 Jun 2020 20:07:13 -0400 Message-ID: Subject: Re: [PATCH v3 1/2] integrity: Add errno field in audit message To: Lakshmi Ramasubramanian X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: linux-audit@redhat.com Cc: rgb@redhat.com, linux-kernel@vger.kernel.org, zohar@linux.ibm.com, linux-audit@redhat.com, linux-integrity@vger.kernel.org X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Thu, Jun 18, 2020 at 5:10 PM Lakshmi Ramasubramanian wrote: > > Error code is not included in the audit messages logged by > the integrity subsystem. > > Define a new function integrity_audit_message() that takes error code > in the "errno" parameter. Add "errno" field in the audit messages logged > by the integrity subsystem and set the value passed in the "errno" > parameter. > > [ 6.303048] audit: type=1804 audit(1592506281.627:2): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel op=measuring_key cause=ENOMEM comm="swapper/0" name=".builtin_trusted_keys" res=0 errno=-12 > > [ 7.987647] audit: type=1802 audit(1592506283.312:9): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=policy_update cause=completed comm="systemd" res=1 errno=0 > > [ 8.019432] audit: type=1804 audit(1592506283.344:10): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=measuring_kexec_cmdline cause=hashing_error comm="systemd" name="kexec-cmdline" res=0 errno=-22 > > Signed-off-by: Lakshmi Ramasubramanian > Suggested-by: Steve Grubb > Suggested-by: Mimi Zohar > --- > security/integrity/integrity.h | 13 +++++++++++++ > security/integrity/integrity_audit.c | 11 ++++++++++- > 2 files changed, 23 insertions(+), 1 deletion(-) The audit record changes look good to me. Acked-by: Paul Moore > diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h > index 16c1894c29bb..413c803c5208 100644 > --- a/security/integrity/integrity.h > +++ b/security/integrity/integrity.h > @@ -239,6 +239,11 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, > const unsigned char *fname, const char *op, > const char *cause, int result, int info); > > +void integrity_audit_message(int audit_msgno, struct inode *inode, > + const unsigned char *fname, const char *op, > + const char *cause, int result, int info, > + int errno); > + > static inline struct audit_buffer * > integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type) > { > @@ -253,6 +258,14 @@ static inline void integrity_audit_msg(int audit_msgno, struct inode *inode, > { > } > > +static inline void integrity_audit_message(int audit_msgno, > + struct inode *inode, > + const unsigned char *fname, > + const char *op, const char *cause, > + int result, int info, int errno) > +{ > +} > + > static inline struct audit_buffer * > integrity_audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, int type) > { > diff --git a/security/integrity/integrity_audit.c b/security/integrity/integrity_audit.c > index 5109173839cc..f25e7df099c8 100644 > --- a/security/integrity/integrity_audit.c > +++ b/security/integrity/integrity_audit.c > @@ -28,6 +28,15 @@ __setup("integrity_audit=", integrity_audit_setup); > void integrity_audit_msg(int audit_msgno, struct inode *inode, > const unsigned char *fname, const char *op, > const char *cause, int result, int audit_info) > +{ > + integrity_audit_message(audit_msgno, inode, fname, op, cause, > + result, audit_info, 0); > +} > + > +void integrity_audit_message(int audit_msgno, struct inode *inode, > + const unsigned char *fname, const char *op, > + const char *cause, int result, int audit_info, > + int errno) > { > struct audit_buffer *ab; > char name[TASK_COMM_LEN]; > @@ -53,6 +62,6 @@ void integrity_audit_msg(int audit_msgno, struct inode *inode, > audit_log_untrustedstring(ab, inode->i_sb->s_id); > audit_log_format(ab, " ino=%lu", inode->i_ino); > } > - audit_log_format(ab, " res=%d", !result); > + audit_log_format(ab, " res=%d errno=%d", !result, errno); > audit_log_end(ab); > } > -- > 2.27.0 > -- paul moore www.paul-moore.com -- Linux-audit mailing list Linux-audit@redhat.com https://www.redhat.com/mailman/listinfo/linux-audit