Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5658732ybc; Wed, 27 Nov 2019 07:29:51 -0800 (PST) X-Google-Smtp-Source: APXvYqw3/hw5CK96WDYsDhg//uWMFPhE7j9HHvn69em5+MZn12BM8ejth4KEnRLgsUu46bJ6np71 X-Received: by 2002:aa7:d147:: with SMTP id r7mr32866525edo.198.1574868591801; Wed, 27 Nov 2019 07:29:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574868591; cv=none; d=google.com; s=arc-20160816; b=s4MPIt5C61D9LS4W+1zfRn5KRaPxJAOTRPq6ytmOGtib5np0LftpF8gLiQOfUTrSmX WRqsrDStdSSr/26htIOtl7reE9LY2mx9w0Apuz9QIYP0yuo91d4Ob0pDJwS3GwP9Cctq exUmojAGPidraaBYJBrMElIbUxMJKuECZVKUK6cJE/sUt9DpTesodQidvTYVhUMLfLdI 9anwzZ8tRWzWc3wFh/n3aJw4/ZmRGslp4AMupf+BKOzlgpZSwQYvfblaQ0xjZLzGIrHN jAYkZmiQfxmkqGzSESnq+ml5qEewkhifSuvRLrJlTum65yaC/uhkTwvVDPOiXWuXCeBY K95w== 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=m8XASQ33ScpPMW9Lk7i08lqftHVIhhUvhoQmKMQABbc=; b=WWO7BNPNqdRQSZOE/rBSIML41HE7t6QFxUWXNP2z8Vs3HUeb0Ju1pRpqtPp6t9KXwi r3VsQFNPZva1+VpBJbY//dDEqXi/TU6IMH7iBw6LMV+BAuf0BTYyPrpOcKCxoDyZ2vam mPXjpktKfEy9laKzE0GHWvaFmdy4q9hKuPFafD1a46HzjuTop09MaIfdBPVAFpt/Opvf RsQnjQdyw0P23lLTDCIxfbqi1jcE5lVFQGJh+i7KtGDDFJNGZ8fH1r+pAxJykUqfkcpH OFQXAucJ1bNWZlL/Dq6E3PqMYtKoAqLbhiymxjuznicj5dNXfl9mzsB7X+Ag8uUz9jKN yiEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=pnkn80E8; 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 r15si439220edw.296.2019.11.27.07.29.28; Wed, 27 Nov 2019 07:29:51 -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=@joelfernandes.org header.s=google header.b=pnkn80E8; 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 S1727072AbfK0P0K (ORCPT + 99 others); Wed, 27 Nov 2019 10:26:10 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:36603 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbfK0P0J (ORCPT ); Wed, 27 Nov 2019 10:26:09 -0500 Received: by mail-qk1-f193.google.com with SMTP id v19so191609qkv.3 for ; Wed, 27 Nov 2019 07:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=m8XASQ33ScpPMW9Lk7i08lqftHVIhhUvhoQmKMQABbc=; b=pnkn80E8scR8OP9K1ql6Itvkl8+SnCbu+Dqzoa7buKcqDvIJ6fvN5RXHrEvAbbuP/B Z3xNb8VsfHx+ctarmuV2zL9XA52orUWS1O5afOFFBp+k6vFL5pVCuY2NFjUVhMtRjvIQ VdZUDb0gXj1V85KUfEtxHsPp/0+24jOlIUDfs= 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=m8XASQ33ScpPMW9Lk7i08lqftHVIhhUvhoQmKMQABbc=; b=tHoF8saDQ21Ab/YWD0BTYQBRKWploEyHrhl56UPC9MKmzbH67rU/Vl7649lwJONYBG U+IZ4ndRXLa5s/lEUzCvyXse9Q7szABnJbf/c0JGIFzYwBjWzWVJL/4xHWhLM8zIgJu5 eeQiIIstD5HNcZ/RRczkyPNE+z4khO20i/4Zq3w9H08uFx30H5g2ZyFDPj9svcBqgika 2LuZ65YEWYT55OKOk5LzK4sBgFNws2AkGqwTg6csDMVtF51ViYFLPBxuX1A+ZT9IeFbg 0jH4rARYyKBXYupxhuav53h0S08AtkLuQkquyJ//KzbK4FQwGX9rjjQ+vf3ICyY2wC1Q ukMg== X-Gm-Message-State: APjAAAUX+hUv6W3BghT2mV780X2f59Y1RBtz3Kwdgzk/id1jqyrDjfBZ lm2EtkArxw7dwKHx+3A4JPwf80ZhnX/tLdZ/lkEY/w== X-Received: by 2002:ae9:c219:: with SMTP id j25mr4939170qkg.470.1574868368530; Wed, 27 Nov 2019 07:26:08 -0800 (PST) MIME-Version: 1.0 References: <20191126172723.GA12759@workstation-kernel-dev> <20191127022925.GB157739@google.com> <20191127052827.GA9782@workstation-portable> In-Reply-To: <20191127052827.GA9782@workstation-portable> From: Joel Fernandes Date: Wed, 27 Nov 2019 10:25:57 -0500 Message-ID: Subject: Re: [PATCH] kernel: audit.c: Add __rcu notation to RCU pointer To: Amol Grover Cc: Paul Moore , Eric Paris , linux-kernel-mentees@lists.linuxfoundation.org, Shuah Khan , linux-audit@redhat.com, LKML 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 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 :) - Joel