From: Ondrej Mosnacek <omosnace@redhat.com>
To: linux-audit@redhat.com
Cc: Richard Guy Briggs <rgb@redhat.com>
Subject: [RFC PATCH ghak10 3/3] ntp: Audit valid attempts to adjust the clock
Date: Fri, 15 Jun 2018 14:45:23 +0200 [thread overview]
Message-ID: <20180615124523.5474-3-omosnace@redhat.com> (raw)
In-Reply-To: <20180615124523.5474-1-omosnace@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 <omosnace@redhat.com>
---
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 <linux/module.h>
#include <linux/rtc.h>
#include <linux/math64.h>
+#include <linux/audit.h>
#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
next prev parent reply other threads:[~2018-06-15 12:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 12:45 [RFC PATCH ghak10 1/3] audit: Add AUDIT_TIME_ADJUSTED record type Ondrej Mosnacek
2018-06-15 12:45 ` [RFC PATCH ghak10 2/3] audit: Add the audit_adjtime() function Ondrej Mosnacek
2018-06-18 18:39 ` Steve Grubb
2018-06-19 8:57 ` Ondrej Mosnacek
2018-06-19 20:52 ` Steve Grubb
2018-06-19 21:08 ` Lenny Bruzenak
2018-06-21 11:28 ` Ondrej Mosnacek
2018-06-15 12:45 ` Ondrej Mosnacek [this message]
2018-06-16 16:44 ` [RFC PATCH ghak10 3/3] ntp: Audit valid attempts to adjust the clock Richard Guy Briggs
2018-06-18 7:35 ` Ondrej Mosnacek
2018-06-18 15:14 ` Richard Guy Briggs
2018-06-19 8:30 ` Ondrej Mosnacek
2018-06-19 16:22 ` Richard Guy Briggs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180615124523.5474-3-omosnace@redhat.com \
--to=omosnace@redhat.com \
--cc=linux-audit@redhat.com \
--cc=rgb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox