From patchwork Wed Feb 13 10:23:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Kleine-Budde X-Patchwork-Id: 220110 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4C9B02C0095 for ; Wed, 13 Feb 2013 21:25:05 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U5ZVJ-00019M-9q; Wed, 13 Feb 2013 10:23:53 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1U5ZUz-00014N-Tf for linux-mtd@lists.infradead.org; Wed, 13 Feb 2013 10:23:34 +0000 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:21e:67ff:fe11:9c5c]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1U5ZUo-0000mH-9a; Wed, 13 Feb 2013 11:23:22 +0100 Received: from mkl by dude.hi.pengutronix.de with local (Exim 4.80) (envelope-from ) id 1U5ZUl-00033b-Ua; Wed, 13 Feb 2013 11:23:19 +0100 From: Marc Kleine-Budde To: linux-mtd@lists.infradead.org Subject: [PATCH RFC 1/5] UBIFS: xattr: protect ui_size and data_len by ui_mutex Date: Wed, 13 Feb 2013 11:23:14 +0100 Message-Id: <1360750998-15191-2-git-send-email-mkl@pengutronix.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1360750998-15191-1-git-send-email-mkl@pengutronix.de> References: <1360750998-15191-1-git-send-email-mkl@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:21e:67ff:fe11:9c5c X-SA-Exim-Mail-From: mkl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mtd@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130213_052334_130890_AD46C50B X-CRM114-Status: GOOD ( 11.63 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: artem.bityutskiy@linux.intel.com, linux-security-module@vger.kernel.org, Marc Kleine-Budde , linux-kernel@vger.kernel.org, kernel@pengutronix.de X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch moves the modification of ui->ui_size and ui->data_len in the create_xattr() and change_xattr() functions, so that they are protected by the ui_mutex as stated in the documenation of the the struct ubifs_inode. Signed-off-by: Marc Kleine-Budde --- fs/ubifs/xattr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c index 0f7139b..1395307 100644 --- a/fs/ubifs/xattr.c +++ b/fs/ubifs/xattr.c @@ -143,10 +143,10 @@ static int create_xattr(struct ubifs_info *c, struct inode *host, err = -ENOMEM; goto out_free; } - inode->i_size = ui->ui_size = size; - ui->data_len = size; mutex_lock(&host_ui->ui_mutex); + inode->i_size = ui->ui_size = size; + ui->data_len = size; host->i_ctime = ubifs_current_time(host); host_ui->xattr_cnt += 1; host_ui->xattr_size += CALC_DENT_SIZE(nm->len); @@ -208,10 +208,10 @@ static int change_xattr(struct ubifs_info *c, struct inode *host, err = -ENOMEM; goto out_free; } - inode->i_size = ui->ui_size = size; - ui->data_len = size; mutex_lock(&host_ui->ui_mutex); + inode->i_size = ui->ui_size = size; + ui->data_len = size; host->i_ctime = ubifs_current_time(host); host_ui->xattr_size -= CALC_XATTR_BYTES(ui->data_len); host_ui->xattr_size += CALC_XATTR_BYTES(size);