From: David Howells <dhowells@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: dhowells@redhat.com, linux-fsdevel@vger.kernel.org,
linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH 7/8] afs: Mark afs_net::ws_cell as __rcu and set using rcu functions
Date: Wed, 23 May 2018 13:17:25 +0100 [thread overview]
Message-ID: <152707784586.27887.18287659934370022329.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <152707780120.27887.10118775145086304138.stgit@warthog.procyon.org.uk>
The afs_net::ws_cell member is sometimes used under RCU conditions from
within an seq-readlock. It isn't, however, marked __rcu and it isn't set
using the proper RCU barrier-imposing functions.
Fix this by annotating it with __rcu and using appropriate barriers to
make sure accesses are correctly ordered.
Without this, the code can produce the following warning:
>> fs/afs/proc.c:151:24: sparse: incompatible types in comparison expression (different address spaces)
Fixes: f044c8847bb6 ("afs: Lay the groundwork for supporting network namespaces")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: David Howells <dhowells@redhat.com>
---
fs/afs/cell.c | 8 ++++----
fs/afs/internal.h | 2 +-
fs/afs/proc.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/afs/cell.c b/fs/afs/cell.c
index fdf4c36cff79..80fd127239ce 100644
--- a/fs/afs/cell.c
+++ b/fs/afs/cell.c
@@ -341,8 +341,8 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)
/* install the new cell */
write_seqlock(&net->cells_lock);
- old_root = net->ws_cell;
- net->ws_cell = new_root;
+ old_root = rcu_access_pointer(net->ws_cell);
+ rcu_assign_pointer(net->ws_cell, new_root);
write_sequnlock(&net->cells_lock);
afs_put_cell(net, old_root);
@@ -755,8 +755,8 @@ void afs_cell_purge(struct afs_net *net)
_enter("");
write_seqlock(&net->cells_lock);
- ws = net->ws_cell;
- net->ws_cell = NULL;
+ ws = rcu_access_pointer(net->ws_cell);
+ RCU_INIT_POINTER(net->ws_cell, NULL);
write_sequnlock(&net->cells_lock);
afs_put_cell(net, ws);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index f8086ec95e24..5d922ad148a8 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -231,7 +231,7 @@ struct afs_net {
/* Cell database */
struct rb_root cells;
- struct afs_cell *ws_cell;
+ struct afs_cell __rcu *ws_cell;
struct work_struct cells_manager;
struct timer_list cells_timer;
atomic_t cells_outstanding;
diff --git a/fs/afs/proc.c b/fs/afs/proc.c
index b45ee7576aa8..362f281b1b16 100644
--- a/fs/afs/proc.c
+++ b/fs/afs/proc.c
@@ -173,7 +173,7 @@ static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
if (*_pos > 0)
return 0;
- if (!net->ws_cell)
+ if (!rcu_access_pointer(net->ws_cell))
return 0;
rcu_read_lock();
next prev parent reply other threads:[~2018-05-23 12:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 12:16 [PATCH 0/8] afs: Network-namespacing David Howells
2018-05-23 12:16 ` [PATCH 1/8] afs: Move /proc management functions to the end of the file David Howells
2018-05-23 12:16 ` [PATCH 2/8] afs: Rearrange fs/afs/proc.c by moving fops and open functions down David Howells
2018-05-23 12:17 ` [PATCH 3/8] afs: Rearrange fs/afs/proc.c to move the show routines up David Howells
2018-05-23 12:17 ` [PATCH 4/8] afs: Rearrange fs/afs/proc.c to remove remaining predeclarations David Howells
2018-05-23 12:17 ` [PATCH 5/8] proc: Add a way to make network proc files writable David Howells
2018-05-23 12:17 ` [PATCH 6/8] afs: Fix a Sparse warning in xdr_decode_AFSFetchStatus() David Howells
2018-05-23 12:17 ` David Howells [this message]
2018-05-23 12:17 ` [PATCH 8/8] afs: Implement network namespacing David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=152707784586.27887.18287659934370022329.stgit@warthog.procyon.org.uk \
--to=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).