linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] posix_acl: de-union a_refcount and a_rcu
@ 2016-07-11 15:01 Andreas Gruenbacher
  2016-07-11 16:50 ` Linus Torvalds
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Gruenbacher @ 2016-07-11 15:01 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: Jeff Layton, Alexander Viro, Thorsten Leemhuis, linux-fsdevel,
	Andreas Gruenbacher

From: Jeff Layton <jlayton@redhat.com>

Currently the two are unioned together, but I don't think that's safe.

It looks like get_cached_acl could race with the last put in
posix_acl_release. get_cached_acl calls atomic_inc_not_zero on
a_refcount, but that field could have already been clobbered by
call_rcu, and may no longer be zero. Fix this by de-unioning the two
fields.

Fixes: b8a7a3a66747 (v4.7-rc1, posix_acl: Inode acl caching fixes)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 include/linux/posix_acl.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 5b5a80c..c818772 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -43,10 +43,8 @@ struct posix_acl_entry {
 };
 
 struct posix_acl {
-	union {
-		atomic_t		a_refcount;
-		struct rcu_head		a_rcu;
-	};
+	atomic_t		a_refcount;
+	struct rcu_head		a_rcu;
 	unsigned int		a_count;
 	struct posix_acl_entry	a_entries[0];
 };
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] posix_acl: de-union a_refcount and a_rcu
@ 2016-07-05 23:55 Jeff Layton
  2016-07-07 14:11 ` David Howells
  0 siblings, 1 reply; 7+ messages in thread
From: Jeff Layton @ 2016-07-05 23:55 UTC (permalink / raw)
  To: Al Viro, Andreas Gruenbacher; +Cc: linux-fsdevel

Currently the two are unioned together, but I don't think that's safe.

It looks like get_cached_acl could race with the last put in
posix_acl_release. get_cached_acl calls atomic_inc_not_zero on
a_refcount, but that field could have already been clobbered by
call_rcu, and may no longer be zero. Fix this by de-unioning the two
fields.

Fixes: b8a7a3a66747 (posix_acl: Inode acl caching fixes)
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 include/linux/posix_acl.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 5b5a80cc5926..c818772d9f9d 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -43,10 +43,8 @@ struct posix_acl_entry {
 };
 
 struct posix_acl {
-	union {
-		atomic_t		a_refcount;
-		struct rcu_head		a_rcu;
-	};
+	atomic_t		a_refcount;
+	struct rcu_head		a_rcu;
 	unsigned int		a_count;
 	struct posix_acl_entry	a_entries[0];
 };
-- 
2.5.5


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

end of thread, other threads:[~2016-07-11 17:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-11 15:01 [PATCH] posix_acl: de-union a_refcount and a_rcu Andreas Gruenbacher
2016-07-11 16:50 ` Linus Torvalds
2016-07-11 17:08   ` Jeff Layton
2016-07-11 17:49   ` Al Viro
  -- strict thread matches above, loose matches on Subject: below --
2016-07-05 23:55 Jeff Layton
2016-07-07 14:11 ` David Howells
2016-07-07 14:20   ` Jeff Layton

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).