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 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87800C433EF for ; Tue, 25 Jan 2022 21:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643147310; 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=aW44MGjPCZARNcaHiSu7ZlTVSpHHs2+Km1iAop7GW2g=; b=VHVLNmj+Rxdy/xCGEUl+kmmQH6AzV8aCsbV+1YXz2XJAZZl88iRu4KAXhx8OTtYKHa2IN+ 95HdwaYVE+3VitUx9f0GJcywF9xpBvqfh26eFv+L1u1cj0hoHYmn4UTD/whjSg0nLInqVs 8jjOIa62WMQxntmUJE57iy4lbPCx1uk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-563-hbYCmOikMt2X3uonlwuOJA-1; Tue, 25 Jan 2022 16:48:26 -0500 X-MC-Unique: hbYCmOikMt2X3uonlwuOJA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D8341091DA2; Tue, 25 Jan 2022 21:48:22 +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 D87394E2B6; Tue, 25 Jan 2022 21:48:21 +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 D8A454BB7C; Tue, 25 Jan 2022 21:48:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20PLmHff031119 for ; Tue, 25 Jan 2022 16:48:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id CC246610A6; Tue, 25 Jan 2022 21:48:17 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.22.48.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3A284610AE; Tue, 25 Jan 2022 21:47:56 +0000 (UTC) Date: Tue, 25 Jan 2022 16:47:54 -0500 From: Richard Guy Briggs To: Paul Moore Subject: Re: [PATCH v2] audit: log AUDIT_TIME_* records only from rules Message-ID: <20220125214754.GA1708086@madcap2.tricolour.ca> References: <9bd09a6b4433094803195a037ff59301a24eafc9.1642774100.git.rgb@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: linux-audit@redhat.com Cc: Eric Paris , Linux-Audit Mailing List 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.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 2022-01-24 22:11, Paul Moore wrote: > On Fri, Jan 21, 2022 at 11:17 AM Richard Guy Briggs wrote: > > > > AUDIT_TIME_* events are generated when there are syscall rules present that are > > not related to time keeping. This will produce noisy log entries that could > > flood the logs and hide events we really care about. > > > > Rather than immediately produce the AUDIT_TIME_* records, store the data in the > > context and log it at syscall exit time respecting the filter rules. > > > > Please see https://bugzilla.redhat.com/show_bug.cgi?id=1991919 > > > > Fixes: 7e8eda734d30 ("ntp: Audit NTP parameters adjustment") > > Fixes: 2d87a0674bd6 ("timekeeping: Audit clock adjustments") > > Signed-off-by: Richard Guy Briggs > > --- > > Changelog: > > v2: > > - rename __audit_ntp_log_ to audit_log_ntp > > - pre-check ntp before storing > > - move tk out of the context union and move ntp logging to the bottom of audit_show_special() > > - restructure logging of ntp to use ab and allocate more only if more > > - add Fixes lines > > > > kernel/audit.h | 2 ++ > > kernel/auditsc.c | 77 +++++++++++++++++++++++++++++++++++------------- > > 2 files changed, 59 insertions(+), 20 deletions(-) > > > > diff --git a/kernel/audit.h b/kernel/audit.h > > index c4498090a5bd..11789249d838 100644 > > --- a/kernel/audit.h > > +++ b/kernel/audit.h > > @@ -201,8 +201,10 @@ struct audit_context { > > struct { > > char *name; > > } module; > > + struct audit_ntp_data ntp_data; > > }; > > int fds[2]; > > + struct timespec64 tk_injoffset; > > struct audit_proctitle proctitle; > > }; > > Why do we need to keep tk_injoffset outside of the audit_context > union? I think we could do something like this, which would be an > improvement IMO: I did three implementations. The first put ntp_data outside which was the quickest and simplest patch, but I really didn't like the wastage in audit_context. The second did as you suggest below in the union, but having the type overwritten by the other AUDIT_TIME_* didn't sit well with me, but since we have to check all the values anyways, we don't really lose anything. This means restructuring the loop a bit but that should work. Both types will need to be written to the context->type. I'll code that up... > struct audit_context { > /* ... */ > union { > /* ... */ > struct { > struct audit_ntp_data ntp_data; > struct timespec64 tk_injoffset; > } time; > }; > /* ... */ > } > > void __audit_tk_injoffset(offset) > { > struct audit_context *ctx = audit_context(); > memcpy(&ctx->time->tk_injoffset, offset, sizeof(offset)); > } > > void audit_log_time(ctx) > { > /* ... */ > > offset = ctx->time->tk_injoffset; > if (offset->tv_sec != 0 || offset->tv_nsec != 0) { > ab = audit_log_start(ctx, GFP_KERNEL, AUDIT_TIME_INJOFFSET); > /* ... */ > audit_log_end(ab); > } > > ntp = ctx->time->ntp_data; > for (i = 0; i < AUDIT_NTP_NVALS; i++) { > if (ntp->vals[i].newval != ntp->vals[i].oldval ) { > /* ... log the ntp/time param changes ... */ > } > } > > /* ... */ > } > > void show_special(...) > { > /* ... */ > case AUDIT_TIME_INJOFFSET: > case AUDIT_TIME_ADJNTPVAL: > audit_log_time(context); > break; > /* ... */ > } > > -- > paul moore > paul-moore.com > - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit