From patchwork Fri Apr 3 21:46:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Saeed X-Patchwork-Id: 6160531 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B08829F1BE for ; Sat, 4 Apr 2015 01:06:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D657F203AC for ; Sat, 4 Apr 2015 01:06:39 +0000 (UTC) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B4221202C8 for ; Sat, 4 Apr 2015 01:06:38 +0000 (UTC) Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t3415lLL001822 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 4 Apr 2015 01:05:48 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t3415jC6023921 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 4 Apr 2015 01:05:45 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1YeCWv-00083R-FT; Fri, 03 Apr 2015 18:05:45 -0700 Received: from dhcp-5op3-5op4-west-130-35-70-94.usdhcp.oraclecorp.com ([130.35.70.94]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1YeCWI-00082N-4x for ocfs2-devel@oss.oracle.com; Fri, 03 Apr 2015 18:05:06 -0700 Received: by dhcp-5op3-5op4-west-130-35-70-94.usdhcp.oraclecorp.com (Postfix, from userid 1733) id 759B0807C4; Fri, 3 Apr 2015 14:46:21 -0700 (PDT) From: Tariq Saeed To: ocfs2-devel@oss.oracle.com Date: Fri, 3 Apr 2015 14:46:20 -0700 Message-Id: <1428097580-25352-2-git-send-email-tariq.x.saeed@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1428097580-25352-1-git-send-email-tariq.x.saeed@oracle.com> References: <1428097580-25352-1-git-send-email-tariq.x.saeed@oracle.com> Cc: mfasheh@suse.de Subject: [Ocfs2-devel] [PATCH 2/2] ocfs2_iop_set/get_acl() are also called from the VFS so we must take inode lock X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Orabug: 20189959 This bug in mainline code is pointed out by Mark Fasheh. When ocfs2_iop_set_acl and ocfs2_iop_ge_acl are entered from VFS layer, inode lock is not held. This seems to be regression from older kernels. The patch is to fix that. Signed-off-by: Tariq Saeed --- fs/ocfs2/acl.c | 28 +++++++++++++++++++++------- 1 files changed, 21 insertions(+), 7 deletions(-) diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index 7e8282d..d7b5542 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c @@ -286,7 +286,19 @@ int ocfs2_set_acl(handle_t *handle, int ocfs2_iop_set_acl(struct inode *inode, struct posix_acl *acl, int type) { - return ocfs2_set_acl(NULL, inode, NULL, type, acl, NULL, NULL); + struct buffer_head *bh = NULL; + int status = 0; + + status = ocfs2_inode_lock(inode, &bh, 1); + if (status < 0) { + if (status != -ENOENT) + mlog_errno(status); + return status; + } + status = ocfs2_set_acl(NULL, inode, bh, type, acl, NULL, NULL); + ocfs2_inode_unlock(inode, 1); + brelse(bh); + return status; } struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) @@ -294,19 +306,21 @@ struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) struct ocfs2_super *osb; struct buffer_head *di_bh = NULL; struct posix_acl *acl; - int ret = -EAGAIN; + int ret; osb = OCFS2_SB(inode->i_sb); if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) return NULL; - - ret = ocfs2_read_inode_block(inode, &di_bh); - if (ret < 0) - return ERR_PTR(ret); + ret = ocfs2_inode_lock(inode, &di_bh, 0); + if (ret < 0) { + mlog_errno(ret); + acl = ERR_PTR(ret); + return acl; + } acl = ocfs2_get_acl_nolock(inode, type, di_bh); + ocfs2_inode_unlock(inode, 0); brelse(di_bh); - return acl; }