From patchwork Wed Sep 21 17:52:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 9344027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7B499601C2 for ; Wed, 21 Sep 2016 17:53:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 646362A457 for ; Wed, 21 Sep 2016 17:53:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 590F92A469; Wed, 21 Sep 2016 17:53:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 994192A457 for ; Wed, 21 Sep 2016 17:53:07 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 46B237CA1; Wed, 21 Sep 2016 12:53:05 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id 777E67CA0 for ; Wed, 21 Sep 2016 12:53:03 -0500 (CDT) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay1.corp.sgi.com (Postfix) with ESMTP id 3C39B8F8040 for ; Wed, 21 Sep 2016 10:53:00 -0700 (PDT) X-ASG-Debug-ID: 1474480378-0bf57b14cd00ac0001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id 2oDIBTMG1lsfHLEE (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 21 Sep 2016 10:52:58 -0700 (PDT) X-Barracuda-Envelope-From: sandeen@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D87741CCC4B; Wed, 21 Sep 2016 17:52:57 +0000 (UTC) Received: from [IPv6:::1] (ovpn03.gateway.prod.ext.phx2.redhat.com [10.5.9.3]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8LHqub7020708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 21 Sep 2016 13:52:57 -0400 To: linux-xfs@vger.kernel.org From: Eric Sandeen Subject: [PATCH] xfs_repair: fix segfault from uninitialized tp in mv_orphanage Message-ID: X-ASG-Orig-Subj: [PATCH] xfs_repair: fix segfault from uninitialized tp in mv_orphanage Date: Wed, 21 Sep 2016 12:52:56 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 21 Sep 2016 17:52:58 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1474480378 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.25:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 1844 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 Cc: Consigliere , xfs-oss X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP After 9074815 xfs: better xfs_trans_alloc interface, mv_orphanage was passing an uninitialized *tp into libxfs_dir_lookup, because the trans_alloc() call which was present prior to the call got removed in that commit. This ultimately led to testing an uninit tp var: Conditional jump or move depends on uninitialised value(s) at 0x434D01: libxfs_trans_read_buf_map (trans.c:554) by 0x45152E: libxfs_da_read_buf (xfs_da_btree.c:2610) by 0x456ACB: xfs_dir3_block_read (xfs_dir2_block.c:136) by 0x4570A8: xfs_dir2_block_lookup_int (xfs_dir2_block.c:675) by 0x457DB7: xfs_dir2_block_lookup (xfs_dir2_block.c:623) by 0x455F54: libxfs_dir_lookup (xfs_dir2.c:399) by 0x421C46: mv_orphanage (phase6.c:1095) by 0x4222C2: check_for_orphaned_inodes (phase6.c:3108) by 0x423ABD: phase6 (phase6.c:3287) by 0x42E4B2: main (xfs_repair.c:933) and ended with a segfault as we tried to use that tp when searching for the buffer in xfs_trans_buf_item_match(): list_for_each_entry(lidp, &tp->t_items, lid_trans) { I think simply passing in NULL for this tp is sufficient to fix this; we'll just go read the buffer from disk in libxfs_trans_read_buf_map rather than trying to find it in an existing transaction. Reported-by: Consigliere Signed-off-by: Eric Sandeen diff --git a/repair/phase6.c b/repair/phase6.c index 973a5f8..5507af4 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -1092,7 +1092,7 @@ mv_orphanage( irec->ino_startnum; nres = XFS_DIRENTER_SPACE_RES(mp, fnamelen) + XFS_DIRENTER_SPACE_RES(mp, 2); - err = -libxfs_dir_lookup(tp, ino_p, &xfs_name_dotdot, + err = -libxfs_dir_lookup(NULL, ino_p, &xfs_name_dotdot, &entry_ino_num, NULL); if (err) { ASSERT(err == ENOENT);