Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp878518pxk; Thu, 17 Sep 2020 20:07:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytLSHX3heOxPjPz67Ujtl60zVmeKTc2NVQ9MQfiyspRlAxDmQmMa8P42TLxPbyuRCLQwqx X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr35796605edy.79.1600398451727; Thu, 17 Sep 2020 20:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600398451; cv=none; d=google.com; s=arc-20160816; b=ep/yNGSSrZp+zTRoCzLyxqzCwvA/Z2CZ2rbXWtcforOtp7tu33nQDaOGyPkWTL8bk4 BNRS6O/kOmniBMfo7BeUvQthHTuw3za1FPazmRH/lPEcGOmveleP1hxLJLgh+hlrgrAW D/U8WhWrXPz/092ErmxTn4pcznVDxVNgws9KJJyShYjeY4txOFrrkr6JDBzNKuBtDpce j+NRn8cNYqCgWykoIokw0sBHTUkKc/LOdYQvL83QL5nsRIogdIb83zRbajsoEiHkS6HZ erpKXxk4/oX7dxydt4G4P6jFY6B1sRqBSXf+lm2e2l766+3eXNfD3380NuJoM5C699Ib eOtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2VPgvY4v+l0UWz8wO/NHp7QTLmUsfQHzd0FtL2HIt+U=; b=JlC3n1Bv4t8+HXGsHNYJOOlUKg1aa9LEYpPSyj6OyhldLjGWsoqBnJi/Tkuy2s54io G/Fy7W1jFHfoByj5FSu4X97/hLE37r14+ulXsU6YQUEl1ycI6qzAH7QxA9ndO3ne7rq/ EbMACwfahSQHBFy81hcKT98nltEN4TawdZIVQvu3uC6iUGZ1kBf2B5Kq9LDlUJmLAcU9 W1OrfHUF86BFbXMAX9Z4Ibb49zgHqYCLyLdcn7y8jYGNIuSD7BQ44m4Toeoi3zJj/h9T W83pun3sEp6UYd+OeWSbVo2CuEKqigKPEyTZYGmu883pzzlLUeDTsrbIQ9iK+v7kyp1z i/Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S2X2HGwO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g11si1070172edy.476.2020.09.17.20.07.08; Thu, 17 Sep 2020 20:07:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=S2X2HGwO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730599AbgIRDEo (ORCPT + 99 others); Thu, 17 Sep 2020 23:04:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:52352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727364AbgIRCEm (ORCPT ); Thu, 17 Sep 2020 22:04:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C55123741; Fri, 18 Sep 2020 02:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394681; bh=6h79j8puL8SLvyo0lXEikZ6F+2drafI4FcFwqp8XkYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S2X2HGwOBK4ld9QFwqt4W6tjlM2L8hNmHnijgIu5cosUCGMTwSUeCo+brNAWbafUa zJ7Iyag7edODvgAWveOFDvKK8T+K+AH9yhdkHVmXjfkQPpALP5vuVQGNXpDyfGZuc6 UiY3Zt0pxMUcvNz9UKLcnPBH17wBxtPSJQStoTr4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Darrick J. Wong" , Dave Chinner , Sasha Levin , xfs@oss.sgi.com Subject: [PATCH AUTOSEL 5.4 171/330] xfs: don't ever return a stale pointer from __xfs_dir3_free_read Date: Thu, 17 Sep 2020 21:58:31 -0400 Message-Id: <20200918020110.2063155-171-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Darrick J. Wong" [ Upstream commit 1cb5deb5bc095c070c09a4540c45f9c9ba24be43 ] If we decide that a directory free block is corrupt, we must take care not to leak a buffer pointer to the caller. After xfs_trans_brelse returns, the buffer can be freed or reused, which means that we have to set *bpp back to NULL. Callers are supposed to notice the nonzero return value and not use the buffer pointer, but we should code more defensively, even if all current callers handle this situation correctly. Fixes: de14c5f541e7 ("xfs: verify free block header fields") Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Sasha Levin --- fs/xfs/libxfs/xfs_dir2_node.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 705c4f5627582..99d5b2ed67f2e 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c @@ -210,6 +210,7 @@ __xfs_dir3_free_read( if (fa) { xfs_verifier_error(*bpp, -EFSCORRUPTED, fa); xfs_trans_brelse(tp, *bpp); + *bpp = NULL; return -EFSCORRUPTED; } -- 2.25.1