Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1018791imc; Mon, 11 Mar 2019 04:50:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZs/Eb7itJqGwzfV0zDbXW1Dw6Cgb5+sDD3JxfOMBqSewKHSg+qkBciPWJiVFDrAzqyFo/ X-Received: by 2002:a17:902:8bc7:: with SMTP id r7mr9996795plo.163.1552305002324; Mon, 11 Mar 2019 04:50:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552305002; cv=none; d=google.com; s=arc-20160816; b=qX7jibSlHUmN834KpcYKHbPzyjcgDOfgMkrKhCImqjtvqGgozeEq9B2aucRXo7MdZ8 HYUyElghGul4GUXjpH4Amaf4RixzFmhrFqW1YtZXF5JmNwcxyOmo9LU3D+cTfVc3Tenu UNBS5IAv/dSfpd3e4oAFtbefNGwYZGAsZ3c9Mz6FIHCEATDvv6m5IOTD6ajaZwO7/Wbk nfSvqMuekXqH4dptS9gtvsUQKViOM0SfnTnncJq4yBmETpkA+4zdngKjV/Xpsg3Kczmk lrhQ7Ii9IjEZ/iZ7v5Fxw9utZ74X6U/JaPqu/RqNQPL8Yr5pQz6LPjBfzKVSHT5Y8f8R v3IA== 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; bh=/4Op3nXMYu7DUp/Bemmj1TQd/62FjfWVJ/UMTXhICbQ=; b=D78IJUplxYL3pHS2nzk9DehClaFKW3JwBIpAoOc8pbOCyWJ2hVKpZqGFUE2/ZzTWBW 4uNBQ/PzbMoJ+gcLlQTYW+0HOVPp8e31gjbVfFm8HSd/WX8L8o6p1lS5N4SK9TYaRdXG k1i43KVVxS7mkkGhazoso/oycm5xmasZ3m9bNF6jkJ064Yx8ugfPnrnKznXWhTo6BQo1 q/KJv9cWUvDqcHc15DOF2Qe/Ih3YVi+nj8wSjZSSkNqkXwerqxi5ZYaRJ8Hm8aAickEb KoQJerQNeHYd4pkNNibG7gktFoM/PPU1iJxdCE8PlCElb1vLQsuZoD1T6DCIAJlJ5mVI nEVw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si4980887plt.326.2019.03.11.04.49.46; Mon, 11 Mar 2019 04:50:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727410AbfCKLsR (ORCPT + 99 others); Mon, 11 Mar 2019 07:48:17 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:34148 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726914AbfCKLsR (ORCPT ); Mon, 11 Mar 2019 07:48:17 -0400 Received: by mail-ot1-f65.google.com with SMTP id r19so133609otn.1 for ; Mon, 11 Mar 2019 04:48:16 -0700 (PDT) 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=/4Op3nXMYu7DUp/Bemmj1TQd/62FjfWVJ/UMTXhICbQ=; b=DUWMmRwV3BsBqt2XYvl9dcMZCMGbEit3QBG0d7zNN7jDSbOkbLuBhYiPIy9qMlM0nK wFChr+mJceSC5M92DSTm7UgzNmhMOIRXVuZ5kR/K/pYT0vXb7A2KNm4PfxCnaJrBw8zi 7iXaYk2U9Uh9U2vEds5UtFrqA2LTXibMZSQqq7JKng8zfh4cT/M9obOoEJv7GTbXrrL8 rpxzcgq3fT4Nhiq7nBR4N5hHhSiHep8V2gDo7GUlIpS0GYnjFJhurAexlQFBzJ4zGiL9 5eGiOYxoeO9drircsGenaybBMkJboEBt6YXHCU4GTGZyO4x45XM2MUlVwNVBLm/5MQci g7jA== X-Gm-Message-State: APjAAAXFaAVQJS0n+wdEMuE3D7k4RZyuN7UmSak8bwB1GceixJW/pcuK aLJ+Dsl05OeGev/V6RB4JFUoreAhXTXwBxYmeeAB4jVlEV0= X-Received: by 2002:a9d:4e10:: with SMTP id p16mr21395675otf.65.1552304895993; Mon, 11 Mar 2019 04:48:15 -0700 (PDT) MIME-Version: 1.0 References: <20190307123254.348-1-omosnace@redhat.com> <20190308202555.dj75sfdxxxnckygq@madcap2.tricolour.ca> In-Reply-To: <20190308202555.dj75sfdxxxnckygq@madcap2.tricolour.ca> From: Ondrej Mosnacek Date: Mon, 11 Mar 2019 12:48:05 +0100 Message-ID: Subject: Re: [RFC PATCH ghak10 v6 0/2] audit: Log changes that can affect the system clock To: Richard Guy Briggs Cc: Linux-Audit Mailing List , Paul Moore , Steve Grubb , Miroslav Lichvar , John Stultz , Thomas Gleixner , Stephen Boyd , Linux kernel mailing list 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 Fri, Mar 8, 2019 at 9:26 PM Richard Guy Briggs wrote: > On 2019-03-07 13:32, Ondrej Mosnacek wrote: > > This patchset implements auditing of (syscall-triggered) changes that > > can modify or indirectly affect the system clock. Some of these > > changes can already be detected by simply logging relevant syscalls, > > but this has some disadvantages: > > a) It is usually not possible to find out from the syscall records > > the amount by which the time was shifted. > > b) Syscalls like adjtimex(2) or clock_adjtime(2) can be used also > > for read-only operations, which might flood the audit log with > > false positives. (Note that these patches don't solve this > > problem yet due to the limitations of current record filtering > > capabilities.) > > > > The main motivation is to provide better reliability of timestamps > > on the system as mandated by the FPT_STM.1 security functional > > requirement from Common Criteria. This requirement apparently demands > > that it is possible to reconstruct from audit trail the old and new > > values of the time when it is adjusted (see [1]). > > > > The current version of the patchset logs the following changes: > > - direct setting of system time to a given value > > - direct injection of timekeeping offset > > - adjustment of timekeeping's TAI offset > > - NTP value adjustments: > > - time_offset > > - time_freq > > - time_status > > - time_adjust > > - tick_usec > > > > Changes to the following NTP values are not logged, as they are not > > important for security: > > - time_maxerror > > - time_esterror > > - time_constant > > > > Audit kernel GitHub issue: https://github.com/linux-audit/audit-kernel/issues/10 > > Audit kernel RFE page: https://github.com/linux-audit/audit-kernel/wiki/RFE-More-detailed-auditing-of-changes-to-system-clock > > > > Testing: Passed audit-testuite; functional tests TBD > > Reviewed-by: Richard Guy Briggs > > How do you plan to test this in the audit-testsuite? My plan is to add a new subtest which will use a short C program that calls the relevant syscalls (they are listed in patch 1/2) directly and will check if they produce the expected records. I outlined some specific things to be tested in the RFE page. > > > Changes in v6: > > - Reorganized the patches to group changes by record type, not > > kernel subsytem, as suggested in earlier discussions > > - Added checks to ignore no-change events (new value == old value) > > - Added TIME_INJOFFSET logging also to do_settimeofday64() to cover > > syscalls such as settimeofday(2), stime(2), clock_settime(2) > > - Created an RFE page on audit-kernel GitHub > > TODO: > > - tests for audit-testsuite > > > > v5: https://www.redhat.com/archives/linux-audit/2018-August/msg00039.html > > Changes in v5: > > - Dropped logging of some less important changes and update commit messages > > - No longer mark the patchset as RFC > > > > v4: https://www.redhat.com/archives/linux-audit/2018-August/msg00023.html > > Changes in v4: > > - Squashed first two patches into one > > - Renamed ADJNTPVAL's "type" field to "op" to align with audit record > > conventions > > - Minor commit message editing > > - Cc timekeeping/NTP people for feedback > > > > v3: https://www.redhat.com/archives/linux-audit/2018-July/msg00001.html > > Changes in v3: > > - Switched to separate records for each variable > > - Both old and new value is now reported for each change > > - Injecting offset is reported via a separate record (since this > > offset consists of two values and is added directly to the clock, > > i.e. it doesn't make sense to log old and new value) > > - Added example records produced by chronyd -q (see the commit message > > of the last patch) > > > > v2: https://www.redhat.com/archives/linux-audit/2018-June/msg00114.html > > Changes in v2: > > - The audit_adjtime() function has been modified to only log those > > fields that contain values that are actually used, resulting in more > > compact records. > > - The audit_adjtime() call has been moved to do_adjtimex() in > > timekeeping.c > > - Added an additional patch (for review) that simplifies the detection > > if the syscall is read-only. > > > > v1: https://www.redhat.com/archives/linux-audit/2018-June/msg00095.html > > > > [1] https://www.niap-ccevs.org/MMO/PP/pp_ca_v2.1.pdf -- section 5.1, > > table 4 > > > > Ondrej Mosnacek (2): > > timekeeping: Audit clock adjustments > > ntp: Audit NTP parameters adjustment > > > > include/linux/audit.h | 29 +++++++++++++++++++++++++++++ > > include/uapi/linux/audit.h | 2 ++ > > kernel/auditsc.c | 15 +++++++++++++++ > > kernel/time/ntp.c | 38 ++++++++++++++++++++++++++++++-------- > > kernel/time/timekeeping.c | 6 ++++++ > > 5 files changed, 82 insertions(+), 8 deletions(-) > > > > -- > > 2.20.1 > > > > - 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 -- Ondrej Mosnacek Associate Software Engineer, Security Technologies Red Hat, Inc.