From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ondrej Mosnacek Subject: [RFC PATCH ghak10 3/3] ntp: Audit valid attempts to adjust the clock Date: Fri, 15 Jun 2018 14:45:23 +0200 Message-ID: <20180615124523.5474-3-omosnace@redhat.com> References: <20180615124523.5474-1-omosnace@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B88A2016ABD for ; Fri, 15 Jun 2018 12:45:35 +0000 (UTC) Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5DB9B8764A for ; Fri, 15 Jun 2018 12:45:35 +0000 (UTC) Received: by mail-wm0-f72.google.com with SMTP id h18-v6so1223270wmb.8 for ; Fri, 15 Jun 2018 05:45:35 -0700 (PDT) In-Reply-To: <20180615124523.5474-1-omosnace@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com To: linux-audit@redhat.com Cc: Richard Guy Briggs List-Id: linux-audit@redhat.com (Intentionally not sending to the timekeeping/ntp maintainers just yet, let's settle on the record contents/format first.) Signed-off-by: Ondrej Mosnacek --- kernel/time/ntp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c index a09ded765f6c..78a01df0dbdb 100644 --- a/kernel/time/ntp.c +++ b/kernel/time/ntp.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "ntp_internal.h" #include "timekeeping_internal.h" @@ -722,6 +723,16 @@ int __do_adjtimex(struct timex *txc, struct timespec64 *ts, s32 *time_tai) { int result; + /* Only log audit event if the clock was changed/attempted to be changed. + * Based on the logic inside timekeeping_validate_timex(). + * NOTE: We need to log the event before any of the fields get + * overwritten by the output values (the function will not fail, so it + * is OK). */ + if ( ( (txc->modes & ADJ_ADJTIME) && !(txc->modes & ADJ_OFFSET_READONLY)) + || (!(txc->modes & ADJ_ADJTIME) && txc->modes) + || (txc->modes & ADJ_SETOFFSET)) + audit_adjtime(txc); + if (txc->modes & ADJ_ADJTIME) { long save_adjust = time_adjust; -- 2.17.1