Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4071146imu; Sat, 24 Nov 2018 17:50:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/U0YHaLMbvxFJVPGYg8YEoLkyMzf01h27fVWbftqBQdYuNoamjeuz9PtaJS9x8PXOfYWfX/ X-Received: by 2002:a62:5486:: with SMTP id i128mr13882185pfb.215.1543110647340; Sat, 24 Nov 2018 17:50:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543110647; cv=none; d=google.com; s=arc-20160816; b=AfVDFEhy1Aq+mLr7M9dmvuJDzvy7erz0uIiGs815/KKFnMrWVOItLWuso28kkFyMtP uJEd+YOA2CAut1vnw3oo8cD6AYqXs7DyzNS0DWGhPUGFQItNb0rhhhaccT+eDx24AnIo XbGgVMUx7RQ/1EsPMNBVQ+DZ4WcN1zr9BgkquKv6na4hT2zHko75E/VyM+6wdnuOK5Rv c3sF7GdPcL+z6JRGQtWAhJAQ79IOa16gt7RBzkN+O+CHkScodPQrIaP3oeZn+2keljrJ leqS8ucUaw4jL8C5JleMrn3ItezIm5ZdGY8o5YNSjuWHVSVyJuCMc+wyJnHf0yYSkCDF 7awA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=RX0NJVp6kJM8Ft+0zMt/FQ39NY+3juAFTpU724pd67g=; b=z97zPOgzOKdPoNUNEeJFzR3yc8M7DmnHHPx5YKYZeUtC02wrOpq4BbdiHDaw8fr8GU AT/STj2juuvB2l6d5So5P4m2O76K/O5wtp0DueiiwPqJaGlkn9n3tt2kOWORm5RxT53n WoVnSNFh+3w3WCnhbBUIdF0/qCy7ty8XSpjWwEN/bhvlQkpWqJHp0oMwCPNxJhlU/YQt kkz6iDWCReHKBqqdyXsBH4ysBqQUX92kE50NQNuaGlio+/n5GYd9tMyGGNXlAdTpUg9s DR/UpxDny5v+SjmZnUVr+7PKwE66+gWt0nW1IiyQgIPUjNSfZ9IfQkDhbQr8PPL2fVns M1Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=MwfWY1Em; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l66si2822218pfl.258.2018.11.24.17.50.31; Sat, 24 Nov 2018 17:50:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=MwfWY1Em; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbeKYMjp (ORCPT + 99 others); Sun, 25 Nov 2018 07:39:45 -0500 Received: from m12-16.163.com ([220.181.12.16]:36554 "EHLO m12-16.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726722AbeKYMjp (ORCPT ); Sun, 25 Nov 2018 07:39:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=RX0NJVp6kJM8Ft+0zM t/FQ39NY+3juAFTpU724pd67g=; b=MwfWY1EmL5RXre0lTgnqHzPZf2QknSO/hw WggY8AvFWFnOdq3vorfW+AwimhY8iIO/1xOt9due6CjB2IkrDep0OYeJqxECQgjf DERBbECAJBBQ7qGyH3GeCVGxzsc0ZdFT5nkAibPTe+gfQ56iz5qpF+KlA551s6uJ UNZt3xnfc= Received: from bp.localdomain (unknown [106.120.213.96]) by smtp12 (Coremail) with SMTP id EMCowAA3A1Gc__lbW3bNBg--.31965S3; Sun, 25 Nov 2018 09:49:23 +0800 (CST) From: Pan Bian To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH] freevxfs: set bp to NULL after dropping its reference in loop Date: Sun, 25 Nov 2018 09:49:17 +0800 Message-Id: <1543110557-126460-1-git-send-email-bianpan2016@163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: EMCowAA3A1Gc__lbW3bNBg--.31965S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrKr1UGr4ftw4kurWkKr4kWFg_yoWfGFXEka 1xJrW8C3yFvr17ta18JFWYqr9IqayrZrn7A342q39Iyry3ta98t3sFvr9xGr1UWrW7WrZ0 k3sFqr1FqryxGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8AcTPUUUUU== X-Originating-IP: [106.120.213.96] X-CM-SenderInfo: held01tdqsiiqw6rljoofrz/xtbBUQMKclaD0TL+IAAAsC Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The function vxfs_bmap_indir calls brelse(bh) in the loop and tries to start the next iteration. However, if it happens to break the loop, brelse(bp) will be called again. Resulting in a potential double free bug. This patch assigns NULL to bh after dropping its reference in the loop body. Signed-off-by: Pan Bian --- fs/freevxfs/vxfs_bmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/freevxfs/vxfs_bmap.c b/fs/freevxfs/vxfs_bmap.c index 1fd41cf..136e5d1 100644 --- a/fs/freevxfs/vxfs_bmap.c +++ b/fs/freevxfs/vxfs_bmap.c @@ -150,6 +150,7 @@ vxfs_bmap_indir(struct inode *ip, long indir, int size, long block) if (block < off) { brelse(bp); + bp = NULL; continue; } @@ -186,6 +187,7 @@ vxfs_bmap_indir(struct inode *ip, long indir, int size, long block) BUG(); } brelse(bp); + bp = NULL; } fail: -- 2.7.4