From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton Subject: [PATCH 1/2] locks: add missing memory barrier in break_deleg Date: Tue, 10 Jun 2014 16:14:35 -0400 Message-ID: <1402431276-14350-2-git-send-email-jlayton@poochiereds.net> References: <1402431276-14350-1-git-send-email-jlayton@poochiereds.net> Cc: bfields@fieldses.org To: linux-fsdevel@vger.kernel.org Return-path: Received: from mail-ig0-f169.google.com ([209.85.213.169]:49207 "EHLO mail-ig0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933130AbaFJUOu (ORCPT ); Tue, 10 Jun 2014 16:14:50 -0400 Received: by mail-ig0-f169.google.com with SMTP id a13so5502639igq.2 for ; Tue, 10 Jun 2014 13:14:49 -0700 (PDT) In-Reply-To: <1402431276-14350-1-git-send-email-jlayton@poochiereds.net> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: break_deleg is subject to the same potential race as break_lease. Add a memory barrier to prevent it. Signed-off-by: Jeff Layton --- include/linux/fs.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index c3f46e499dd0..22ae79650b82 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1914,6 +1914,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode) static inline int break_deleg(struct inode *inode, unsigned int mode) { + /* + * Since this check is lockless, we must ensure that any refcounts + * taken are done before checking inode->i_flock. Otherwise, we could + * end up racing with tasks trying to set a new lease on this file. + */ + smp_mb(); if (inode->i_flock) return __break_lease(inode, mode, FL_DELEG); return 0; -- 1.9.3