Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp124392ybt; Tue, 23 Jun 2020 17:08:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxygp4tFaiX6HsvkhJRs+EKbo01Nt7O70H9GXhGhdrxWHeaRsrg9fdXaFV3gnDEQ6FtxyQv X-Received: by 2002:a17:906:9257:: with SMTP id c23mr22088602ejx.86.1592957289057; Tue, 23 Jun 2020 17:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592957289; cv=none; d=google.com; s=arc-20160816; b=tIJlMJDxT3TIxu2uoNzvc4Y6axb80zv+H+hD59wKoTujR/ubqI7JyOK0a8R1DxbByY P0bCc2Jt7TPKwMUGXU0QLYeI9UxPrQtXJ0SxKZuDETPWM+XK5P4xsIhilmUzvEFJ2Dml 1EUHPOUgGIWsSepQOGccJbD4fsGTX6sW6I0LszAOkjyJJae+ma9N0yKqk5tI62FzjoQd S8IcROj7398QqqOp5RCeCDFzBmT2p+JlNJUGB18jxlpA3uNV5XkrOJX4qGcWxlX7YyfR 7X0VxwQ41upkaSBy5KwOkx6L0ZbRjt9Pil2L9KYJ5jKwdF944vMLurWlY2iOd6Jay1Wj VoNw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=wYef0IlAA5cnvfvaD0Ws/jCKLqqDtLAVNioagh3fxFo=; b=gZ2dZeBBhLxWTyAV1ow8BoUbWHQZGyk2y8oUUkDormee2Y9wFACFZ9h8nracFPB39j SL746Re7y8RaqT7ZjQ156EGw6oJue9RuvxfPY6eLgmnLwIam9DCU4UAv882ERs8NwPJp Ogl81UIH5yCu/gC6z6sSRoN8xwgE/lWi502L3ugtgZP5CU/0Jbr+2G33nk40sRESAtZW j22kUFIZw5iBOn5wmmUM2uajuD4RDVMciR2V+6kbp9k0sOQEq+TDeL0X4pfNvNhf/hlh xiQwqU7AU0acumjl/Y7auyGlcyLob1xkQ6u4VB4XjqXSm5MS9W5yOrkDN8/GmBh3ZXIz nPjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=t5sN2GgB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id by7si7343096edb.540.2020.06.23.17.07.45; Tue, 23 Jun 2020 17:08:09 -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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=t5sN2GgB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387922AbgFXAH1 (ORCPT + 99 others); Tue, 23 Jun 2020 20:07:27 -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-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