Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp49501img; Wed, 27 Mar 2019 16:40:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqylHQZDKGoIy+dLSPQkgcOlcZ9ELIJnHOpNxFlp+lVTF8422nbLlgdVY6A1YZVSBZ6UkJSp X-Received: by 2002:a17:902:e912:: with SMTP id cs18mr39970411plb.130.1553730001191; Wed, 27 Mar 2019 16:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553730001; cv=none; d=google.com; s=arc-20160816; b=r1fwttNRVIxcL2EqzGguH58tCPMoJvu4OhKd5iAFPaEKV80H3WyiUAjnH/5XznAjrg nuKZWkHJt1e0IkW3EaG6jwrj7DO97SB9aCFqctVEuoaX2Tpg+EeH6uj3PCLSmev0oS4M +PSWDwwHAsQ8AWiudVWeNu6pHYUog0xuxy4RbMjVQ68Nvchp1FzfmXWbxZjk0JZRM+IY 8CDBtOxnO6gjpTsW1MPkyqEN6v0woZv4FGC1rjZMehgiRgT0MGI+UzN/uZecYcs26ZkM 2mzAnL4kb7UyKJYvRVJXa6dKV9r1YaOZmx3DGPls3fUUy8eBQ6KAfKaLL72bi8Box/dj PK2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=wX8Xvl3rBBodlfhiM4nkwa4A/jqwbKr3isGHKLjkIbo=; b=N9a5xf7QGJ1DaA6MkWaYikNmdNzzUbrl6J4YtYzF+MuOHeIGYPmvBXx4R+MGLxJFlQ 5CVy7r1e+fmtoD1oDypBj+NhuIiPaYzEx8B9NtnQ/oC+3KqpuXRP+12LYZGGE0dluduk ZAdv9sUe4+p/5JHwDIYOLtQ+AFPNJykt0jloVcRf0i4fBiulZIYVBSziYKc+C4GqpDl0 /rxSowBeVjldIjdFf3GdZZsSLuvZ7c067UwBj5Br6tM2JKKJfjFL7gNkUtp9n1mD563F UIHlsQj8GSVpwpQ9IedF7qprRvPo8cdIoxFMwpFt0QZcVfgk17ZaRqwq74s9xYuCKSCX HfdQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si9191382pfa.268.2019.03.27.16.39.44; Wed, 27 Mar 2019 16:40:01 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728506AbfC0XhT (ORCPT + 99 others); Wed, 27 Mar 2019 19:37:19 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:51901 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725601AbfC0XhT (ORCPT ); Wed, 27 Mar 2019 19:37:19 -0400 Received: from p5492e2fc.dip0.t-ipconnect.de ([84.146.226.252] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1h9I6b-0004fr-1k; Thu, 28 Mar 2019 00:37:13 +0100 Date: Thu, 28 Mar 2019 00:37:12 +0100 (CET) From: Thomas Gleixner To: Ondrej Mosnacek cc: linux-audit@redhat.com, Paul Moore , Richard Guy Briggs , Steve Grubb , Miroslav Lichvar , John Stultz , Stephen Boyd , linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH ghak10 v6 1/2] timekeeping: Audit clock adjustments In-Reply-To: <20190307123254.348-2-omosnace@redhat.com> Message-ID: References: <20190307123254.348-1-omosnace@redhat.com> <20190307123254.348-2-omosnace@redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 7 Mar 2019, Ondrej Mosnacek wrote: > --- a/kernel/auditsc.c > +++ b/kernel/auditsc.c > @@ -2512,6 +2512,14 @@ void __audit_fanotify(unsigned int response) > AUDIT_FANOTIFY, "resp=%u", response); > } > > +/* We need to allocate with GFP_ATOMIC here, since these two functions will be > + * called while holding the timekeeping lock: */ Audit is no justification for doing ATOMIC allocations just because it's convenient in the middle of code which blocks every concurrent reader. Please find a place outside of the timekeeper lock to do that audit logging. Either that or allocate your buffer upfront in a preemptible section and commit after the critical section. /* * Aside of that please use proper multiline comment style and not this * horrible other one. */ > +void __audit_tk_injoffset(struct timespec64 offset) > +{ > + audit_log(audit_context(), GFP_ATOMIC, AUDIT_TIME_INJOFFSET, > + "sec=%lli nsec=%li", (long long)offset.tv_sec, offset.tv_nsec); > +} > + > @@ -1250,6 +1251,9 @@ out: > /* signal hrtimers about time change */ > clock_was_set(); > > + if (!ret) > + audit_tk_injoffset(ts_delta); This one does not need GFP_ATOMIC at all. > + > return ret; > } > EXPORT_SYMBOL(do_settimeofday64); > @@ -2322,6 +2326,8 @@ int do_adjtimex(struct timex *txc) > ret = timekeeping_inject_offset(&delta); > if (ret) > return ret; > + > + audit_tk_injoffset(delta); > } > > ktime_get_real_ts64(&ts); This can be done at the end of do_adjtimex() quite nicely in preemptible context. Thanks, tglx