Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6890293ybc; Thu, 28 Nov 2019 07:12:33 -0800 (PST) X-Google-Smtp-Source: APXvYqwfdjLzQ1OkMnsHFbMKzoKWmDWPmKc65e1z8xWOTr/clRnQdXbDr/UCX/R61Re8g6+r7HXF X-Received: by 2002:a17:906:a28d:: with SMTP id i13mr38833636ejz.154.1574953953130; Thu, 28 Nov 2019 07:12:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574953953; cv=none; d=google.com; s=arc-20160816; b=eWMsvsoUMw67U50jZtXd85MyULuO1sPE0zq/l0iXhKhKRLrYp/a7AF66njkAY8dl7p 3Bi7negfihgFs4yvdpGSpwt0LQg+r0bNTocyG5rgyZeuiWX6WhOxIYBOZ7242IbCToF/ TnI4B86QRTZH6S8E6qQIOuySKP8qHXpamEM3D1/YBYypDgWqbCneRGSIpa7Ws316uYY9 kaxJvsdjIIkhxs9P/6yQoW5u4HFTiaMHSlC64rKfDuYLykWQqjhtN1O1irxWnXFnFE6J k42591JXsQP0IXSKoAeQ4MxLm6bBTb1eBy40Ve0t7TrtoKNum0O+D3hMS6qZhZB4we1S jZCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Z2wU0E4d5s4/xK+13SW3DrjkiCtDxj7UMABJh83nudE=; b=igYy3JqaX1aSNMkIdar6al4T9UWjE9aNoQq8ehAb12kujzgfj+iKBo3rl8AbIzAsop /lH1qeQR9w0LOGqLufMtm19ul8c4FpmQHTRSvdfQ9v/Lj6flAKg68JWZK94BYjJycDg3 sgIXzBaTts52yapZMZqh4a0jOEKfXh8DKG5Z8a7ublFK7HDU9fAStgXWBADqGi0+HTU6 VB4sKFr5XhWPL1P+5rLoxv2DDb8leCrkaL58DFJNOrdQUprDbhWF/ux35qwDBUik3gbN 09ajrpYV5TaZPcAmQJ/zFq3EvdRV/oCob/924N247ctwh0pOOQ47chOCbN54uZA1CeEu kPzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c5OxcfVn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 39si12823918edz.341.2019.11.28.07.12.08; Thu, 28 Nov 2019 07:12:33 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=c5OxcfVn; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726726AbfK1PK3 (ORCPT + 99 others); Thu, 28 Nov 2019 10:10:29 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:32975 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726556AbfK1PK3 (ORCPT ); Thu, 28 Nov 2019 10:10:29 -0500 Received: by mail-pj1-f67.google.com with SMTP id r67so4258704pjb.0 for ; Thu, 28 Nov 2019 07:10:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Z2wU0E4d5s4/xK+13SW3DrjkiCtDxj7UMABJh83nudE=; b=c5OxcfVnBC5jamcSyxumsTvrFr88egXS4P+lN9zZWdpMu20m2zTLB7/E7qq0dW0BCd ScKf5xCamGQcz1nrfUmvavZYIKleOViPPnPD7AC+IvW5Uvw9nXn+8gpUb86p5QPrnpMR ixtnjJa9JEMmfJqXb9zrboDnEKM89dQncRUXaPP1mSqOuXtjP5mGOJIy/Kg/UsTEHHWk iegOzPLNe8CBS0Jb2x5yM5wQ/KEMz2j7zgdAf01PhNM63MW2M6vPVDEG/oibIorRUsX2 ek+QpNVbMhMA8UMotnlY8cEhHxGFJTR4IxYTQXw5oSIoYdpX7kc0JZxuspkGjfq2XVx5 kXng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Z2wU0E4d5s4/xK+13SW3DrjkiCtDxj7UMABJh83nudE=; b=L0sSrxzjEZU8yIOysFVs3iNcvBt7TY+qZbP7akITz4BRSPZkyEWRPTj2F1sABfd66k fmb32RiLFowQJB8C2pVz4Jr5hMP2xg6yaSEUJIIbr+nAjilO6Gic2KSs+Olkly7YcPRw cl28jbhthk2TL6qQ04EsS9Jzlh4A706ngH049awVxWJAtG6BgXrV+qf/SllqcGwgR0ug vpEAaQgyWoH+N0Y6iwYScR6Dly7hZGqQL4YzRH59tb7JIuOXZaFftZoXuiSGCnS3prM6 sfIAQgXMXItDngpA/b4VWTBPQbGFF0E2bWvkyt8Buk6cC8jWmwx3lYfBWBzdJgjrw7+x qadQ== X-Gm-Message-State: APjAAAV16p2/4SzBFhIQgCt18wX0HCj24vmvOpcasck2926hOs4Q7tFL SU4XBGvv87AL8O2CqeHT/Bk= X-Received: by 2002:a17:902:142:: with SMTP id 60mr10314206plb.38.1574953828543; Thu, 28 Nov 2019 07:10:28 -0800 (PST) Received: from workstation-portable ([139.5.253.4]) by smtp.gmail.com with ESMTPSA id h9sm8756948pfo.139.2019.11.28.07.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Nov 2019 07:10:27 -0800 (PST) Date: Thu, 28 Nov 2019 20:39:49 +0530 From: Amol Grover To: Joel Fernandes Cc: Paul Moore , Eric Paris , linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan , linux-audit@redhat.com, LKML Subject: Re: [PATCH] kernel: audit.c: Add __rcu notation to RCU pointer Message-ID: <20191128150949.GA30181@workstation-portable> References: <20191126172723.GA12759@workstation-kernel-dev> <20191127022925.GB157739@google.com> <20191127052827.GA9782@workstation-portable> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 27, 2019 at 10:25:57AM -0500, Joel Fernandes wrote: > On Wed, Nov 27, 2019 at 12:29 AM Amol Grover wrote: > > > > On Tue, Nov 26, 2019 at 09:29:25PM -0500, Joel Fernandes wrote: > > > On Tue, Nov 26, 2019 at 10:57:23PM +0530, Amol Grover wrote: > > > > add __rcu notation to RCU protected global pointer auditd_conn > > > > > > > > Fixes multiple instances of sparse error: > > > > error: incompatible types in comparison expression > > > > (different address spaces) > > > > > > > > Signed-off-by: Amol Grover > > > > --- > > > > kernel/audit.c | 6 ++++-- > > > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > > index da8dc0db5bd3..30e7fc9b8da2 100644 > > > > --- a/kernel/audit.c > > > > +++ b/kernel/audit.c > > > > @@ -102,12 +102,14 @@ struct audit_net { > > > > * This struct is RCU protected; you must either hold the RCU lock for reading > > > > * or the associated spinlock for writing. > > > > */ > > > > -static struct auditd_connection { > > > > +struct auditd_connection { > > > > struct pid *pid; > > > > u32 portid; > > > > struct net *net; > > > > struct rcu_head rcu; > > > > -} *auditd_conn = NULL; > > > > +}; > > > > +static struct auditd_connection __rcu *auditd_conn; > > > > +RCU_INIT_POINTER(auditd_conn); > > > > > > Looks like this causes a build error. Always please build test your patches > > > in the very least. And I also did not understand how RCU_INIT_POINTER can > > > even be used outside of a function. In C, executable code cannot be outside > > > functions. > > > > > > Is doing the following not sufficient to fix the sparse issue? > > > > > > thanks, > > > > > > - Joel > > > > > > ---8<----------------------- > > > > > > diff --git a/kernel/audit.c b/kernel/audit.c > > > index 49b6049b26ac..c5d4b5a2dea1 100644 > > > --- a/kernel/audit.c > > > +++ b/kernel/audit.c > > > @@ -108,8 +108,8 @@ struct auditd_connection { > > > struct net *net; > > > struct rcu_head rcu; > > > }; > > > -static struct auditd_connection __rcu *auditd_conn; > > > -RCU_INIT_POINTER(auditd_conn); > > > +static struct auditd_connection __rcu *auditd_conn = NULL; > > > > I ran a quick checkpatch and it gave me this error: > > ERROR: do not initialise statics to NULL > > > > So in order to fix it I decided to INIT the pointer (and failed) > > Well, try to understand the checkpatch error then, and do the right thing :) I read-up a few articles about this. I think I've understood the problem. I'm sending in the ammended patch now. Sorry for this. Won't happen again. Thanks Amol > > - Joel