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 52DD0C433F5 for ; Tue, 25 Jan 2022 03:11:40 +0000 (UTC) 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-dBi5olmiOdGeU2A86IP_Sg-1; Mon, 24 Jan 2022 22:11:35 -0500 X-MC-Unique: dBi5olmiOdGeU2A86IP_Sg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF020363A4; Tue, 25 Jan 2022 03:11:31 +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 7E0764697C; Tue, 25 Jan 2022 03:11:30 +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 35C904CA93; Tue, 25 Jan 2022 03:11:28 +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 20P3BPXS009806 for ; Mon, 24 Jan 2022 22:11:25 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5BF53112131E; Tue, 25 Jan 2022 03:11:25 +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 57A581121314 for ; Tue, 25 Jan 2022 03:11:22 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5DB1785A5B5 for ; Tue, 25 Jan 2022 03:11:22 +0000 (UTC) Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-r7mXoEF-OUOMy9-v19o4KA-1; Mon, 24 Jan 2022 22:11:20 -0500 X-MC-Unique: r7mXoEF-OUOMy9-v19o4KA-1 Received: by mail-ej1-f51.google.com with SMTP id k25so26834463ejp.5 for ; Mon, 24 Jan 2022 19:11:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2AFG2DUyDeCfkIqChHR0IlI4dgkOgt1GPRxT8riTKhI=; b=cNPeYbu7wO3t44iB1W1/Yb2ebwY1oAyrBtUrpuYpllrEKTc6psMdX8yR6UcSgHSDhX tTJo1V3EeroIsowu9D8qT37qZTKSavvh/XBX/XYIcQbia+8T4JGz7zy1ZCoJ8ksanKPv 3QcdadPMcow2dn/tlCyXJ166ddZnwnjVgravzc/FudtZEj5a0YolJdT+j+S7QaZFqmAi Zf2lVTIaopQP+2pFT4mgzjYxxqfiSzhQb+tu87GC0XM+I70uH4HstdBEc7e5gmS57pzr j8NTrpfEJqhcD4Yzx8gi769JojB65D+ZOuM77IigX343chM6IKR0BvVXCzfBEd2GKgtU AcJg== X-Gm-Message-State: AOAM533pChsOHn/hFEl4Ppug5+BsSzI7KjlSKSz+jL1GEMw64v7bW3kZ RbZp2+Fmb4swZif8WaeQqf5wavKhomMeQx+U1R84 X-Google-Smtp-Source: ABdhPJzIzG0TNz6LXP+mFHx05N5qeny1jfTfQLIFZyIWyIwcPcwkaT9BangWtnTsXzGB+E1R7eSJ69QHWG45mFbYubs= X-Received: by 2002:a17:906:c14f:: with SMTP id dp15mr14636588ejc.327.1643080278859; Mon, 24 Jan 2022 19:11:18 -0800 (PST) MIME-Version: 1.0 References: <9bd09a6b4433094803195a037ff59301a24eafc9.1642774100.git.rgb@redhat.com> In-Reply-To: <9bd09a6b4433094803195a037ff59301a24eafc9.1642774100.git.rgb@redhat.com> From: Paul Moore Date: Mon, 24 Jan 2022 22:11:08 -0500 Message-ID: Subject: Re: [PATCH v2] audit: log AUDIT_TIME_* records only from rules To: Richard Guy Briggs X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 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.12 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-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: 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 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit