Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp458630pxa; Fri, 21 Aug 2020 11:36:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzBJBht0SeH7/k8D8kMOkKGqX7urIUTrMQjlO40lNUQL4ffvz0v056s+OeOLdzOPl95lSd X-Received: by 2002:a17:906:7d6:: with SMTP id m22mr3986578ejc.229.1598034976156; Fri, 21 Aug 2020 11:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598034976; cv=none; d=google.com; s=arc-20160816; b=Zf4s0ihqrlr460pgk2omAq/sgTuNOcZadEJn8JLfAGPGSMMGpm7pzZ63iJZE7PsPwC pUUPkTfijrG1nIfxWdb/KRBi87OJNgjgJH6FzSSlVjxTOd9OkyFcL8afMUXxHL6oWUaY 0oyvX8TNpwttGLWtfVCj3yadb/jdaSXaEImeFHmdZVq/V3jnV9Mdq74vF4t+vTGfkL91 oHpg18kHzjCJe8rGWJxuca33WtT6ghM+HZrnl21M50WOZEQmmkeuY39v4DsUIdyl916L vX5zy1vu7P1PtD2B/WyETyxKuM+eVAgBnmAn90QRZdL3l4a7L9rh+BOzruvZjGAvhQ1x eDcQ== 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:dkim-signature; bh=q4frqIW9I+72sr79+gm0FlxLWfHVNqfXNa3Q85/YG38=; b=NTVrhiutOHocKsTPy+WtnsuBf3rIemAMYSZCYZsUk9icGioniOzG6/Fhbji04F0xuu 3NYj5PqHM8bWCeIY3Q+O8bIRaxzlQmoTrLnkmipqUjuJKl6xOQtFIvxRxmcygjAN4wl8 bq12Sp9OoX6KlsNbQwHLWOEQFmLq0BVE4hn6DdLztcxNCmTY1EhDOp5hK7PQZr3IZRN7 6PGTkd7s44i6rDjB3DT3eHTDTwMTocZ+O6PeFeDSYdedB6xECNq50PRuE2gwpo0B+8Kj SP/X2CTGXXvS0qoo3ZIOa/oH7J2UP8+xJg4YFpzUTnffrAPUuoUQSsjZTNPARb3TYEZo YY6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=FFvdCi9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn3si1763781edb.563.2020.08.21.11.35.53; Fri, 21 Aug 2020 11:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=FFvdCi9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726728AbgHUSfV (ORCPT + 99 others); Fri, 21 Aug 2020 14:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbgHUSfL (ORCPT ); Fri, 21 Aug 2020 14:35:11 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4174EC061575 for ; Fri, 21 Aug 2020 11:35:10 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id o23so3467940ejr.1 for ; Fri, 21 Aug 2020 11:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=q4frqIW9I+72sr79+gm0FlxLWfHVNqfXNa3Q85/YG38=; b=FFvdCi9F5IYZnNSXXIYkdNN6KgOiWn2gpkkna/pVmWNnIBtYPB/REc3lR/fIaVeCW9 xcSIWYk5iEt0s3PqyD4BZtBeNRnNdMU5hgRft3ZaAVYAasCNtgX2d6rzDzZJkEmWns8Q DMouWMb6Wi3acrbp58tg1muQxWsOySA71Li1F/+ycwrhf8v2Y0nl3puJD3YvwQfnHUGb nrBMScR8wjFGLnAUtO3JiGu8kd20y0FCbHOw69GnkVA4KDSkAF+r8hp2olMacxwqoxVg jl1pnhCY2uVZkYVQNb9N1obAwGLTlc2+T6DsKYp19SXlykAO66qL+BjzJ7BOFir1WKli sEEw== 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=q4frqIW9I+72sr79+gm0FlxLWfHVNqfXNa3Q85/YG38=; b=Wd2wHrNAl1eai8mVX84YGWgqjQK/61PDS3JFHH307VIJcvxtdKPxRVqSnTY8EVWBDe OLM8MXi88imRdQ4Ey8mp5HOfMJ+wcXIQzCnf4IfowATHdm9eAvbNDHji/G1MWULSIWdN g6vVRl08jVJ4pIQ3C/+bEKE19saknAVMYKpdiUhAheOK1A8DaBu9zMU6vTSiWHusa0cl zzJNDsXYQ85kEi0z3aaVa+6311PuSzqT2ylFhr+O2kblGmAkty1UeCU05v1QGTBRjJ8J 8k87WLaIP6cqvJZ4bJoLGonO7chsjaJeg2GNY43PQUPAGocqSmvHkWcBV+NI82pmvDo9 hkww== X-Gm-Message-State: AOAM533W7yKioi/vWT8YDJ8xvJtE6fLISw+eizuTMNJEnE6MOdhuu+eD AjHavLLBB0j08EssHmTg/3MTWmQYii01wY/r+9nO X-Received: by 2002:a17:906:43c9:: with SMTP id j9mr4143785ejn.542.1598034909369; Fri, 21 Aug 2020 11:35:09 -0700 (PDT) MIME-Version: 1.0 References: <4a5019ed3cfab416aeb6549b791ac6d8cc9fb8b7.1593198710.git.rgb@redhat.com> <20200718004341.ruyre5xhlu3ps2tr@madcap2.tricolour.ca> In-Reply-To: <20200718004341.ruyre5xhlu3ps2tr@madcap2.tricolour.ca> From: Paul Moore Date: Fri, 21 Aug 2020 14:34:57 -0400 Message-ID: Subject: Re: [PATCH ghak90 V9 08/13] audit: add containerid support for user records To: Richard Guy Briggs Cc: nhorman@tuxdriver.com, linux-api@vger.kernel.org, containers@lists.linux-foundation.org, LKML , dhowells@redhat.com, Linux-Audit Mailing List , netfilter-devel@vger.kernel.org, ebiederm@xmission.com, simo@redhat.com, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, Eric Paris , mpatel@redhat.com, Serge Hallyn 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, Jul 17, 2020 at 8:44 PM Richard Guy Briggs wrote: > On 2020-07-05 11:11, Paul Moore wrote: > > On Sat, Jun 27, 2020 at 9:23 AM Richard Guy Briggs wrote: > > > > > > Add audit container identifier auxiliary record to user event standalone > > > records. > > > > > > Signed-off-by: Richard Guy Briggs > > > Acked-by: Neil Horman > > > Reviewed-by: Ondrej Mosnacek > > > --- > > > kernel/audit.c | 19 ++++++++++++------- > > > 1 file changed, 12 insertions(+), 7 deletions(-) > > > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > index 54dd2cb69402..997c34178ee8 100644 > > > --- a/kernel/audit.c > > > +++ b/kernel/audit.c > > > @@ -1507,6 +1504,14 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh) > > > audit_log_n_untrustedstring(ab, str, data_len); > > > } > > > audit_log_end(ab); > > > + rcu_read_lock(); > > > + cont = _audit_contobj_get(current); > > > + rcu_read_unlock(); > > > + audit_log_container_id(context, cont); > > > + rcu_read_lock(); > > > + _audit_contobj_put(cont); > > > + rcu_read_unlock(); > > > + audit_free_context(context); > > > > I haven't searched the entire patchset, but it seems like the pattern > > above happens a couple of times in this patchset, yes? If so would it > > make sense to wrap the above get/log/put in a helper function? > > I've redone the locking with an rcu lock around the get and a spinlock > around the put. It occurs to me that putting an rcu lock around the > whole thing and doing a get without the refcount increment would save > us the spinlock and put and be fine since we'd be fine with stale but > consistent information traversing the contobj list from this point to > report it. Problem with that is needing to use GFP_ATOMIC due to the > rcu lock. If I stick with the spinlock around the put then I can use > GFP_KERNEL and just grab the spinlock while traversing the contobj list. > > > Not a big deal either way, I'm pretty neutral on it at this point in > > the patchset but thought it might be worth mentioning in case you > > noticed the same and were on the fence. > > There is only one other place this is used, in audit_log_exit in > auditsc.c. I had noted the pattern but wasn't sure it was worth it. > Inline or not? Should we just let the compiler decide? I'm generally not a fan of explicit inlines unless it has been shown to be a real problem. -- paul moore www.paul-moore.com