linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
@ 2019-11-28 15:32 Amol Grover
  2019-11-30  2:07 ` Joel Fernandes
  0 siblings, 1 reply; 7+ messages in thread
From: Amol Grover @ 2019-11-28 15:32 UTC (permalink / raw)
  To: Paul Moore, Eric Paris
  Cc: linux-kernel-mentees, linux-audit, linux-kernel, Shuah Khan,
	Joel Fernandes

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 <frextrite@gmail.com>
---
v2:
- fix erroneous RCU pointer initialization

 kernel/audit.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/audit.c b/kernel/audit.c
index da8dc0db5bd3..ff7cfc61f53d 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -102,12 +102,13 @@ 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;
 static DEFINE_SPINLOCK(auditd_conn_lock);
 
 /* If audit_rate_limit is non-zero, limit the rate of sending audit records
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
  2019-11-28 15:32 [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer Amol Grover
@ 2019-11-30  2:07 ` Joel Fernandes
  2020-04-15 15:34   ` Richard Guy Briggs
  0 siblings, 1 reply; 7+ messages in thread
From: Joel Fernandes @ 2019-11-30  2:07 UTC (permalink / raw)
  To: Amol Grover
  Cc: Paul Moore, Eric Paris, linux-kernel-mentees, linux-audit,
	linux-kernel, Shuah Khan

On Thu, Nov 28, 2019 at 09:02:03PM +0530, Amol Grover wrote:
> add __rcu notation to RCU protected global pointer auditd_conn

Again, please use proper punctuation and captilization. This is unacceptable.
Please put more effort into changelog.

Otherwise the patch diff itself looks good to me, with the above nit
corrected, you could add my tag to the next revision:

Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>

thanks,

 - Joel

> 
> Fixes multiple instances of sparse error:
> error: incompatible types in comparison expression
> (different address spaces)
> 
> Signed-off-by: Amol Grover <frextrite@gmail.com>
> ---
> v2:
> - fix erroneous RCU pointer initialization
> 
>  kernel/audit.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/kernel/audit.c b/kernel/audit.c
> index da8dc0db5bd3..ff7cfc61f53d 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -102,12 +102,13 @@ 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;
>  static DEFINE_SPINLOCK(auditd_conn_lock);
>  
>  /* If audit_rate_limit is non-zero, limit the rate of sending audit records
> -- 
> 2.24.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
  2019-11-30  2:07 ` Joel Fernandes
@ 2020-04-15 15:34   ` Richard Guy Briggs
  2020-04-15 16:06     ` Paul Moore
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Guy Briggs @ 2020-04-15 15:34 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Amol Grover, linux-kernel, linux-audit, Shuah Khan, linux-kernel-mentees

On 2019-11-29 21:07, Joel Fernandes wrote:
> On Thu, Nov 28, 2019 at 09:02:03PM +0530, Amol Grover wrote:
> > add __rcu notation to RCU protected global pointer auditd_conn
> 
> Again, please use proper punctuation and captilization. This is unacceptable.
> Please put more effort into changelog.
> 
> Otherwise the patch diff itself looks good to me, with the above nit
> corrected, you could add my tag to the next revision:
> 
> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> 
> thanks,
> 
>  - Joel
> 
> > 
> > Fixes multiple instances of sparse error:
> > error: incompatible types in comparison expression
> > (different address spaces)

Amol or Joel: Is there a reproducer recipe for this?

> > Signed-off-by: Amol Grover <frextrite@gmail.com>
> > ---
> > v2:
> > - fix erroneous RCU pointer initialization
> > 
> >  kernel/audit.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/kernel/audit.c b/kernel/audit.c
> > index da8dc0db5bd3..ff7cfc61f53d 100644
> > --- a/kernel/audit.c
> > +++ b/kernel/audit.c
> > @@ -102,12 +102,13 @@ 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;
> >  static DEFINE_SPINLOCK(auditd_conn_lock);
> >  
> >  /* If audit_rate_limit is non-zero, limit the rate of sending audit records
> > -- 
> > 2.24.0

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
  2020-04-15 15:34   ` Richard Guy Briggs
@ 2020-04-15 16:06     ` Paul Moore
  2020-04-15 16:15       ` Richard Guy Briggs
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Moore @ 2020-04-15 16:06 UTC (permalink / raw)
  To: Richard Guy Briggs
  Cc: Joel Fernandes, Shuah Khan, linux-audit, linux-kernel-mentees,
	linux-kernel, Amol Grover

On Wed, Apr 15, 2020 at 11:34 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> On 2019-11-29 21:07, Joel Fernandes wrote:
> > On Thu, Nov 28, 2019 at 09:02:03PM +0530, Amol Grover wrote:
> > > add __rcu notation to RCU protected global pointer auditd_conn
> >
> > Again, please use proper punctuation and captilization. This is unacceptable.
> > Please put more effort into changelog.
> >
> > Otherwise the patch diff itself looks good to me, with the above nit
> > corrected, you could add my tag to the next revision:
> >
> > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> >
> > thanks,
> >
> >  - Joel
> >
> > >
> > > Fixes multiple instances of sparse error:
> > > error: incompatible types in comparison expression
> > > (different address spaces)
>
> Amol or Joel: Is there a reproducer recipe for this?

The commit which was merged has a slightly better description which may help.

  commit cb5172d96d16df72db8b55146b0ec00bfd97f079
  Author: Amol Grover <frextrite@gmail.com>
  Date:   Mon Dec 2 00:03:48 2019 +0530

   audit: Add __rcu annotation to RCU pointer

   Add __rcu annotation to RCU-protected global pointer auditd_conn.

   auditd_conn is an RCU-protected global pointer,i.e., accessed
   via RCU methods rcu_dereference() and rcu_assign_pointer(),
   hence it must be annotated with __rcu for sparse to report
   warnings/errors correctly.

   Fix multiple instances of the sparse error:
   error: incompatible types in comparison expression
   (different address spaces)

   Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
   Signed-off-by: Amol Grover <frextrite@gmail.com>
   [PM: tweak subject line]
   Signed-off-by: Paul Moore <paul@paul-moore.com>

-- 
paul moore
www.paul-moore.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
  2020-04-15 16:06     ` Paul Moore
@ 2020-04-15 16:15       ` Richard Guy Briggs
  2020-04-15 16:53         ` Ondrej Mosnacek
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Guy Briggs @ 2020-04-15 16:15 UTC (permalink / raw)
  To: Paul Moore
  Cc: Joel Fernandes, Shuah Khan, linux-audit, linux-kernel-mentees,
	linux-kernel, Amol Grover

On 2020-04-15 12:06, Paul Moore wrote:
> On Wed, Apr 15, 2020 at 11:34 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> > On 2019-11-29 21:07, Joel Fernandes wrote:
> > > On Thu, Nov 28, 2019 at 09:02:03PM +0530, Amol Grover wrote:
> > > > add __rcu notation to RCU protected global pointer auditd_conn
> > >
> > > Again, please use proper punctuation and captilization. This is unacceptable.
> > > Please put more effort into changelog.
> > >
> > > Otherwise the patch diff itself looks good to me, with the above nit
> > > corrected, you could add my tag to the next revision:
> > >
> > > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> > >
> > > thanks,
> > >
> > >  - Joel
> > >
> > > >
> > > > Fixes multiple instances of sparse error:
> > > > error: incompatible types in comparison expression
> > > > (different address spaces)
> >
> > Amol or Joel: Is there a reproducer recipe for this?
> 
> The commit which was merged has a slightly better description which may help.

I've already seen this.  Perhaps I should have replied to this message
instead to make that evident.  What really needed was Amol's original
message sent to this list, but it was Joel who included this list in his
reply (all 3 versions).

I'm looking for the specific setup and commands that produced this error.

>   commit cb5172d96d16df72db8b55146b0ec00bfd97f079
>   Author: Amol Grover <frextrite@gmail.com>
>   Date:   Mon Dec 2 00:03:48 2019 +0530
> 
>    audit: Add __rcu annotation to RCU pointer
> 
>    Add __rcu annotation to RCU-protected global pointer auditd_conn.
> 
>    auditd_conn is an RCU-protected global pointer,i.e., accessed
>    via RCU methods rcu_dereference() and rcu_assign_pointer(),
>    hence it must be annotated with __rcu for sparse to report
>    warnings/errors correctly.
> 
>    Fix multiple instances of the sparse error:
>    error: incompatible types in comparison expression
>    (different address spaces)
> 
>    Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
>    Signed-off-by: Amol Grover <frextrite@gmail.com>
>    [PM: tweak subject line]
>    Signed-off-by: Paul Moore <paul@paul-moore.com>
> 
> -- 
> paul moore
> www.paul-moore.com
> 

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
  2020-04-15 16:15       ` Richard Guy Briggs
@ 2020-04-15 16:53         ` Ondrej Mosnacek
  2020-04-15 19:27           ` Richard Guy Briggs
  0 siblings, 1 reply; 7+ messages in thread
From: Ondrej Mosnacek @ 2020-04-15 16:53 UTC (permalink / raw)
  To: Richard Guy Briggs
  Cc: Paul Moore, Amol Grover, Linux kernel mailing list,
	Linux-Audit Mailing List, Shuah Khan, Joel Fernandes,
	linux-kernel-mentees

On Wed, Apr 15, 2020 at 6:15 PM Richard Guy Briggs <rgb@redhat.com> wrote:
> On 2020-04-15 12:06, Paul Moore wrote:
> > On Wed, Apr 15, 2020 at 11:34 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> > > On 2019-11-29 21:07, Joel Fernandes wrote:
> > > > On Thu, Nov 28, 2019 at 09:02:03PM +0530, Amol Grover wrote:
> > > > > add __rcu notation to RCU protected global pointer auditd_conn
> > > >
> > > > Again, please use proper punctuation and captilization. This is unacceptable.
> > > > Please put more effort into changelog.
> > > >
> > > > Otherwise the patch diff itself looks good to me, with the above nit
> > > > corrected, you could add my tag to the next revision:
> > > >
> > > > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> > > >
> > > > thanks,
> > > >
> > > >  - Joel
> > > >
> > > > >
> > > > > Fixes multiple instances of sparse error:
> > > > > error: incompatible types in comparison expression
> > > > > (different address spaces)
> > >
> > > Amol or Joel: Is there a reproducer recipe for this?
> >
> > The commit which was merged has a slightly better description which may help.
>
> I've already seen this.  Perhaps I should have replied to this message
> instead to make that evident.  What really needed was Amol's original
> message sent to this list, but it was Joel who included this list in his
> reply (all 3 versions).
>
> I'm looking for the specific setup and commands that produced this error.

You can run make with "C=1", which will run sparse on all files that
are rebuilt during that make run. For example, if I fully build the
kernel and then revert commit
cb5172d96d16df72db8b55146b0ec00bfd97f079, I get:

$ make [...] C=1
[...]
  CHECK   [...]/kernel/audit.c
[...]/kernel/audit.c:218:14: error: incompatible types in comparison
expression (different address spaces):
[...]/kernel/audit.c:218:14:    struct auditd_connection [noderef] <asn:4> *
[...]/kernel/audit.c:218:14:    struct auditd_connection *
(...and a lot more errors like this + 2 different warnings)

And when I un-revert it again, I get only the 2 warnings.

-- 
Ondrej Mosnacek <omosnace at redhat dot com>
Software Engineer, Security Technologies
Red Hat, Inc.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer
  2020-04-15 16:53         ` Ondrej Mosnacek
@ 2020-04-15 19:27           ` Richard Guy Briggs
  0 siblings, 0 replies; 7+ messages in thread
From: Richard Guy Briggs @ 2020-04-15 19:27 UTC (permalink / raw)
  To: Ondrej Mosnacek
  Cc: Paul Moore, Amol Grover, Linux kernel mailing list,
	Linux-Audit Mailing List, Shuah Khan, Joel Fernandes,
	linux-kernel-mentees

On 2020-04-15 18:53, Ondrej Mosnacek wrote:
> On Wed, Apr 15, 2020 at 6:15 PM Richard Guy Briggs <rgb@redhat.com> wrote:
> > On 2020-04-15 12:06, Paul Moore wrote:
> > > On Wed, Apr 15, 2020 at 11:34 AM Richard Guy Briggs <rgb@redhat.com> wrote:
> > > > On 2019-11-29 21:07, Joel Fernandes wrote:
> > > > > On Thu, Nov 28, 2019 at 09:02:03PM +0530, Amol Grover wrote:
> > > > > > add __rcu notation to RCU protected global pointer auditd_conn
> > > > >
> > > > > Again, please use proper punctuation and captilization. This is unacceptable.
> > > > > Please put more effort into changelog.
> > > > >
> > > > > Otherwise the patch diff itself looks good to me, with the above nit
> > > > > corrected, you could add my tag to the next revision:
> > > > >
> > > > > Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
> > > > >
> > > > > thanks,
> > > > >
> > > > >  - Joel
> > > > >
> > > > > >
> > > > > > Fixes multiple instances of sparse error:
> > > > > > error: incompatible types in comparison expression
> > > > > > (different address spaces)
> > > >
> > > > Amol or Joel: Is there a reproducer recipe for this?
> > >
> > > The commit which was merged has a slightly better description which may help.
> >
> > I've already seen this.  Perhaps I should have replied to this message
> > instead to make that evident.  What really needed was Amol's original
> > message sent to this list, but it was Joel who included this list in his
> > reply (all 3 versions).
> >
> > I'm looking for the specific setup and commands that produced this error.
> 
> You can run make with "C=1", which will run sparse on all files that
> are rebuilt during that make run. For example, if I fully build the
> kernel and then revert commit
> cb5172d96d16df72db8b55146b0ec00bfd97f079, I get:
> 
> $ make [...] C=1
> [...]
>   CHECK   [...]/kernel/audit.c
> [...]/kernel/audit.c:218:14: error: incompatible types in comparison
> expression (different address spaces):
> [...]/kernel/audit.c:218:14:    struct auditd_connection [noderef] <asn:4> *
> [...]/kernel/audit.c:218:14:    struct auditd_connection *
> (...and a lot more errors like this + 2 different warnings)
> 
> And when I un-revert it again, I get only the 2 warnings.

Perfect, thanks Ondrej.

> Ondrej Mosnacek <omosnace at redhat dot com>

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-15 19:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-28 15:32 [PATCH v2] kernel: audit.c: Add __rcu notation to RCU pointer Amol Grover
2019-11-30  2:07 ` Joel Fernandes
2020-04-15 15:34   ` Richard Guy Briggs
2020-04-15 16:06     ` Paul Moore
2020-04-15 16:15       ` Richard Guy Briggs
2020-04-15 16:53         ` Ondrej Mosnacek
2020-04-15 19:27           ` Richard Guy Briggs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).