Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932429AbaJaTih (ORCPT ); Fri, 31 Oct 2014 15:38:37 -0400 Received: from skprod2.natinst.com ([130.164.80.23]:52340 "EHLO ni.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755588AbaJaTig (ORCPT ); Fri, 31 Oct 2014 15:38:36 -0400 From: Ben Shelton To: linux-mtd@lists.infradead.org Cc: dedekind1@gmail.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, Subodh Nijsure , Marc Kleine-Budde , Ben Shelton Subject: [PATCH 1/4] UBIFS: fix a couple bugs in UBIFS xattr length calculation Date: Fri, 31 Oct 2014 13:50:28 -0500 Message-Id: <1414781431-2911-2-git-send-email-ben.shelton@ni.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1414781431-2911-1-git-send-email-ben.shelton@ni.com> References: <1414781431-2911-1-git-send-email-ben.shelton@ni.com> X-MIMETrack: Itemize by SMTP Server on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 10/31/2014 01:51:09 PM, Serialize by Router on US-AUS-MGWOut2/AUS/H/NIC(Release 8.5.3FP6|November 21, 2013) at 10/31/2014 01:51:09 PM, Serialize complete at 10/31/2014 01:51:09 PM X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.12.52,1.0.28,0.0.0000 definitions=2014-10-31_08:2014-10-31,2014-10-31,1970-01-01 signatures=0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Subodh Nijsure Signed-off-by: Subodh Nijsure Signed-off-by: Marc Kleine-Budde Signed-off-by: Ben Shelton Acked-by: Brad Mouring Acked-by: Gratian Crisan --- fs/ubifs/journal.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index fb166e2..7d90f13 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -571,7 +571,13 @@ 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 the length calculation + * in case there is an extended attribute. + */ + len = aligned_dlen + aligned_ilen + + UBIFS_INO_NODE_SZ + dir_ui->data_len; dent = kmalloc(len, GFP_NOFS); if (!dent) return -ENOMEM; @@ -648,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; -- 2.1.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/