From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 4DDB57F37 for ; Wed, 18 Mar 2015 18:22:16 -0500 (CDT) Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by relay1.corp.sgi.com (Postfix) with ESMTP id 112BA8F8054 for ; Wed, 18 Mar 2015 16:22:13 -0700 (PDT) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) by cuda.sgi.com with ESMTP id btiGBnimONo4VAIk (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 18 Mar 2015 16:22:11 -0700 (PDT) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t2INMAL1032647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 18 Mar 2015 23:22:10 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t2INM9ZT019143 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 18 Mar 2015 23:22:09 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t2INM94A020239 for ; Wed, 18 Mar 2015 23:22:09 GMT Date: Wed, 18 Mar 2015 16:21:59 -0700 From: "Darrick J. Wong" Subject: [PATCH] libxfs: don't write uninitialized heap contents into new directory blocks Message-ID: <20150318232159.GA24608@birch.djwong.org> MIME-Version: 1.0 Content-Disposition: inline List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: xfs@oss.sgi.com When we're initializing a new directory block, zero the buffer contents to avoid writing random heap contents (and crc thereof) to disk. This eliminates a few valgrind complaints in xfs_repair. Signed-off-by: Darrick J. Wong --- libxfs/xfs_da_btree.c | 1 + libxfs/xfs_dir2_data.c | 1 + libxfs/xfs_dir2_leaf.c | 1 + libxfs/xfs_dir2_node.c | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index b731b54..bc73cbc 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -562,6 +562,7 @@ xfs_da3_root_split( if (error) return error; node = bp->b_addr; + memset(bp->b_addr, 0, bp->b_bcount); oldroot = blk1->bp->b_addr; if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) || oldroot->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC)) { diff --git a/libxfs/xfs_dir2_data.c b/libxfs/xfs_dir2_data.c index dc9df4d..79c2fc2 100644 --- a/libxfs/xfs_dir2_data.c +++ b/libxfs/xfs_dir2_data.c @@ -559,6 +559,7 @@ xfs_dir3_data_init( XFS_DATA_FORK); if (error) return error; + memset(bp->b_addr, 0, bp->b_bcount); bp->b_ops = &xfs_dir3_data_buf_ops; xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_DATA_BUF); diff --git a/libxfs/xfs_dir2_leaf.c b/libxfs/xfs_dir2_leaf.c index 8e0cbc9..6eb03fc 100644 --- a/libxfs/xfs_dir2_leaf.c +++ b/libxfs/xfs_dir2_leaf.c @@ -382,6 +382,7 @@ xfs_dir3_leaf_get_buf( if (error) return error; + memset(bp->b_addr, 0, bp->b_bcount); xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic); xfs_dir3_leaf_log_header(tp, bp); if (magic == XFS_DIR2_LEAF1_MAGIC) diff --git a/libxfs/xfs_dir2_node.c b/libxfs/xfs_dir2_node.c index 3737e4e..3e2f04d 100644 --- a/libxfs/xfs_dir2_node.c +++ b/libxfs/xfs_dir2_node.c @@ -247,7 +247,7 @@ xfs_dir3_free_get_buf( * Initialize the new block to be empty, and remember * its first slot as our empty slot. */ - memset(bp->b_addr, 0, sizeof(struct xfs_dir3_free_hdr)); + memset(bp->b_addr, 0, bp->b_bcount); memset(&hdr, 0, sizeof(hdr)); if (xfs_sb_version_hascrc(&mp->m_sb)) { _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs