From patchwork Wed Feb 13 10:23:15 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: 220113 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 7E7AE2C007C for ; Wed, 13 Feb 2013 21:25:49 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U5ZVM-0001AA-TZ; Wed, 13 Feb 2013 10:23:56 +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 1U5ZV0-00014R-Pi for linux-mtd@lists.infradead.org; Wed, 13 Feb 2013 10:23:36 +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-0000mI-S0; 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-00033g-V3; Wed, 13 Feb 2013 11:23:19 +0100 From: Marc Kleine-Budde To: linux-mtd@lists.infradead.org Subject: [PATCH RFC 2/5] UBIFS: fix couple bugs in UBIFS extended attribute length calculation Date: Wed, 13 Feb 2013 11:23:15 +0100 Message-Id: <1360750998-15191-3-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_052335_174029_9EAD80B8 X-CRM114-Status: GOOD ( 13.05 ) 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: Subodh Nijsure , artem.bityutskiy@linux.intel.com, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Marc Kleine-Budde , 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 From: Subodh Nijsure Signed-off-by: Subodh Nijsure Signed-off-by: Marc Kleine-Budde --- fs/ubifs/journal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index afaad07..6981d7d 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -572,7 +572,12 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, aligned_dlen = ALIGN(dlen, 8); aligned_ilen = ALIGN(ilen, 8); - len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ; + /* + * Make sure to account for dir_ui+data_len in length + * calculation in case there is extended attribute. + */ + len = aligned_dlen + aligned_ilen + + UBIFS_INO_NODE_SZ + dir_ui->data_len; dent = kmalloc(len, GFP_NOFS); if (!dent) return -ENOMEM; @@ -649,7 +654,8 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, ino_key_init(c, &ino_key, dir->i_ino); ino_offs += aligned_ilen; - err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ); + err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, + UBIFS_INO_NODE_SZ + dir_ui->data_len); if (err) goto out_ro;