Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp8532210ybc; Fri, 29 Nov 2019 12:12:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzkCWmpM7QgjKb4AOOwF7nJkqXfXJvtndR9MoGgxbI+oGJr1ENBvJ9vz0Cg7xhKxzZjYktA X-Received: by 2002:a50:e88a:: with SMTP id f10mr42738379edn.277.1575058331886; Fri, 29 Nov 2019 12:12:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575058331; cv=none; d=google.com; s=arc-20160816; b=EqxXdtIKYcBu5Twr71Py2d49688aIS0DZl/Z1Q0FT9/yQ5bCHm6jBlReTzC/jqMoYq roJRVo99MN5YanYlIoZJNBdMdQcGipYp4IInn6Te//SzqG0uaxfYcwtkb8nS1q/b5DwU MZjg+tFSBCHHvzXUh60pZUk9DCL2/vMBJ5lHiHIuSXJ2SKq7TiSbAZHPKbKpT+nlNqf3 mwB+ihTNC4n/y1w2MvDskq+9pKtjlMSnby/CUCubBCAsasO0/b3ZyqCYE/hSlpZeV4zp 3re+Gm+jaailWY4w1OSn9I95A1VkROz774GwDx+RbPMkUkuCqVCIKoCuAC1wpBBvg70y qaCg== 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=DvDMSJKpd/DCMvLbsXJa6FXI7w1LfpYRNLVlppSW228=; b=igpCR5knhOx+wTx/uZdD9S11qZRZ9YHlKiOhR/ispA7gd3SQlqAFxLF7Ce7bna+089 lJrndswBoUNIP/YHT0zemTLACRNSxGsDxfcWMgSRM4Jx4wE6RkwvAQTOpdQIbAutMRmp 506vrqjXTh55gaXWl2UGi9JThiCldWA75nENp/pqcJD+mG3hOGtYx/xnA93hIEEvFb6E pCh9GdF/nIgt4z49VcNwjTarWlcaYA4ILu8W5ewtLJDvylnnyU7lLusmYdv+jSpYZP5q EWqahlq+/Tp9AptcNS8yPOx2U3KDMARYHkMkyqcGmpiW1R0FiOrhDTAio3VSNSdUyJps DxjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=x9QOTCRR; 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 o20si1110957ejx.211.2019.11.29.12.11.47; Fri, 29 Nov 2019 12:12:11 -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=x9QOTCRR; 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 S1727107AbfK2UIT (ORCPT + 99 others); Fri, 29 Nov 2019 15:08:19 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:46125 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbfK2UIT (ORCPT ); Fri, 29 Nov 2019 15:08:19 -0500 Received: by mail-pg1-f194.google.com with SMTP id k1so6520344pga.13 for ; Fri, 29 Nov 2019 12:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DvDMSJKpd/DCMvLbsXJa6FXI7w1LfpYRNLVlppSW228=; b=x9QOTCRRFsFpPM5tf9H9+SF7dl2x8ogdtGQkav0LCZ0gi2gK0qMJT0rbIJFu4lIK1p Zh/Ii2/xMNQmi2umqA5Kk77RZbQusCI2BkSxYRl5qfLKJPqHjp9xk6Tn589u9KhvD8JU AZ7jnj87ZDoUyKZUyiAv4YABp/QEa0kvjrrP4= 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=DvDMSJKpd/DCMvLbsXJa6FXI7w1LfpYRNLVlppSW228=; b=rD/kZuqrEh0Wa8aiG5OmQdhC441n/tX35XeFemq/b1XnhtVnUmVh42LsRrhD7xBFM2 eEzi3QuoU2yASI5kCZOS4VDK4w3w+uAFJTUwe+R6VpyXtxaq/CeArpqOPKyglAjvbhp+ wg17a2lkhoHaZffQLTKPdN5wYyJqNMEdp1zRHcCDh5BXK4jTmsf4/4b4QsRiRB94jlAa FOxmscTGIMVnaQiHspIN33c1ahJJl4NGf++8uLmOUGZc/AqgBAgpRqwC5YzJiDTLvmzs ZUplewENKntii4KrHEzXobvFsKOKkg1Lnq9FWeRO7SDs3OJACgL2K450HLfAKZMblWv+ GJbg== X-Gm-Message-State: APjAAAW3YsPJN7Gz0HkfD7yOyvOJk0SEz8Z5Y+zqTjlTIEtuAFpBrgt7 tGDFk/oVScoNhwHbCXqVnXfeBg== X-Received: by 2002:a63:d544:: with SMTP id v4mr18283741pgi.288.1575058098939; Fri, 29 Nov 2019 12:08:18 -0800 (PST) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id y6sm23937455pfm.12.2019.11.29.12.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Nov 2019 12:08:18 -0800 (PST) Date: Fri, 29 Nov 2019 15:08:17 -0500 From: Joel Fernandes To: Amol Grover 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: <20191129200817.GB239292@google.com> References: <20191126172723.GA12759@workstation-kernel-dev> <20191127022925.GB157739@google.com> <20191127052827.GA9782@workstation-portable> <20191128150949.GA30181@workstation-portable> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191128150949.GA30181@workstation-portable> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 28, 2019 at 08:39:49PM +0530, Amol Grover wrote: > 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. Oh, no need apology. You are learning. But yeah always do a thorough job before sending patches. thanks, - Joel