lockd: use locks_inode_context helper

[ Upstream commit 98b41ffe0afdfeaa1439a5d6bd2db4a94277e31b ]

lockd currently doesn't access i_flctx safely. This requires a
smp_load_acquire, as the pointer is set via cmpxchg (a release
operation).

Cc: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: Anna Schumaker <anna@kernel.org>
Cc: Chuck Lever <chuck.lever@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Jeff Layton
2022-11-16 09:19:43 -05:00
committed by Greg Kroah-Hartman
parent 70ffaa7896
commit 32c59062f8

View File

@@ -207,7 +207,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
{ {
struct inode *inode = nlmsvc_file_inode(file); struct inode *inode = nlmsvc_file_inode(file);
struct file_lock *fl; struct file_lock *fl;
struct file_lock_context *flctx = inode->i_flctx; struct file_lock_context *flctx = locks_inode_context(inode);
struct nlm_host *lockhost; struct nlm_host *lockhost;
if (!flctx || list_empty_careful(&flctx->flc_posix)) if (!flctx || list_empty_careful(&flctx->flc_posix))
@@ -262,7 +262,7 @@ nlm_file_inuse(struct nlm_file *file)
{ {
struct inode *inode = nlmsvc_file_inode(file); struct inode *inode = nlmsvc_file_inode(file);
struct file_lock *fl; struct file_lock *fl;
struct file_lock_context *flctx = inode->i_flctx; struct file_lock_context *flctx = locks_inode_context(inode);
if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares) if (file->f_count || !list_empty(&file->f_blocks) || file->f_shares)
return 1; return 1;