From patchwork Tue Oct 10 16:47:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Foster X-Patchwork-Id: 9996709 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 D13FD603B5 for ; Tue, 10 Oct 2017 16:48:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3A2A286C1 for ; Tue, 10 Oct 2017 16:48:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8C55286C6; Tue, 10 Oct 2017 16:48:03 +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 688D7286C1 for ; Tue, 10 Oct 2017 16:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932434AbdJJQsA (ORCPT ); Tue, 10 Oct 2017 12:48:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55092 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932431AbdJJQr6 (ORCPT ); Tue, 10 Oct 2017 12:47:58 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80A081299 for ; Tue, 10 Oct 2017 16:47:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80A081299 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=bfoster@redhat.com Received: from bfoster.bfoster (dhcp-41-20.bos.redhat.com [10.18.41.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F4BA17C2D for ; Tue, 10 Oct 2017 16:47:58 +0000 (UTC) Received: by bfoster.bfoster (Postfix, from userid 1000) id 04BEF120156; Tue, 10 Oct 2017 12:47:56 -0400 (EDT) From: Brian Foster To: linux-xfs@vger.kernel.org Subject: [PATCH 1/2] xfs: assert that xattr inactivation never reaches a hole Date: Tue, 10 Oct 2017 12:47:55 -0400 Message-Id: <20171010164756.28390-2-bfoster@redhat.com> In-Reply-To: <20171010164756.28390-1-bfoster@redhat.com> References: <20171010164756.28390-1-bfoster@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 10 Oct 2017 16:47: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 The child buffer read in xfs_attr3_node_inactive() should never reach a hole in the attr fork. If this occurs, it is likely due to a bug. Prior to commit cd87d867 ("xfs: don't crash on unexpected holes in dir/attr btrees"), this would result in a crash. Now that the crash has been fixed, this is a silent failure. Add an assert in this codepath to detect this particular condition. Note that the right fix here may be to pass -1 to xfs_da3_node_read() such that a hole returns an error. This is a cautious first step in that direction. Signed-off-by: Brian Foster --- fs/xfs/xfs_attr_inactive.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index ebd66b1..6b4f5c6 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c @@ -255,6 +255,7 @@ xfs_attr3_node_inactive( XFS_ATTR_FORK); if (error) return error; + ASSERT(child_bp); if (child_bp) { /* save for re-read later */ child_blkno = XFS_BUF_ADDR(child_bp);