From patchwork Thu Feb 2 15:54:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 9552345 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 7AD3C604E0 for ; Thu, 2 Feb 2017 15:55:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 660EB28425 for ; Thu, 2 Feb 2017 15:55:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD8C28456; Thu, 2 Feb 2017 15:55:11 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03FCB28425 for ; Thu, 2 Feb 2017 15:55:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751931AbdBBPzI (ORCPT ); Thu, 2 Feb 2017 10:55:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55462 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbdBBPy6 (ORCPT ); Thu, 2 Feb 2017 10:54:58 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 8149780F94 for ; Thu, 2 Feb 2017 15:54:58 +0000 (UTC) Received: from [IPv6:::1] (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v12FsvYT030136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 2 Feb 2017 10:54:58 -0500 To: linux-xfs From: Eric Sandeen Subject: [PATCH] xfs_metadump: ignore attr leaf with 0 entries Message-ID: <7481b076-dbc6-ddaa-4e3f-9a1bc2b94e26@redhat.com> Date: Thu, 2 Feb 2017 09:54:56 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 02 Feb 2017 15:54:58 +0000 (UTC) Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Another in the ongoing saga of attribute leaves with zero entries; in this case, if we try to metadump an inode with a zero-entries attribute leaf, the zeroing code will go off the rails and segfault at: memset(&entries[nentries], 0, first_name - (char *)&entries[nentries]); because first_name is null, and we try to memset a large (negative) number. Signed-off-by: Eric Sandeen Reviewed-by: Darrick J. Wong --- -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/db/metadump.c b/db/metadump.c index 38519f1..66952f6 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -1654,7 +1654,8 @@ process_attr_block( xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &hdr, leaf); nentries = hdr.count; - if (nentries * sizeof(xfs_attr_leaf_entry_t) + + if (nentries == 0 || + nentries * sizeof(xfs_attr_leaf_entry_t) + xfs_attr3_leaf_hdr_size(leaf) > XFS_ATTR3_RMT_BUF_SPACE(mp, bs)) { if (show_warnings)