Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1747622ybl; Sat, 11 Jan 2020 02:01:39 -0800 (PST) X-Google-Smtp-Source: APXvYqyIj/ZxdGX5Pi112T3xCGEHotWssrnBU8Cb2fQoKJUHTEA8ysy7aFcnO9LIBkPeUbymBrJz X-Received: by 2002:aca:500f:: with SMTP id e15mr6087628oib.172.1578736899180; Sat, 11 Jan 2020 02:01:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578736899; cv=none; d=google.com; s=arc-20160816; b=cuobvRGG79y98lJ92+/Y+V7GNL2bpGkhUYQHTM2S9SV9iQSUerobsOJnYbnsP2s2UZ TUY+bbMHDRwwJ24WgNHQLrPvsp+Ya/gk4MSd37a/zBK/rO2Tn5FQ4pIYdGEf7AsX8SVF 1oLZYSWKyx+8z3AynAbSPloIWL/fqxVqMaOyXLjenu4SKzV8wP9zL53HKl2ON3gCaith MGDD7p7C16vtf+MDc6alKV5qi79n+J3m/YmH/XN+v+zE1+jOYunKlQ3m9WloMkqia/6H l3LrQ1JKtOoaPIuTX4OEEByvkJz5O4RAqmDEq5iJjLtId2lqjZ8fXCAT0J4LblShectX X2MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0nWTKmpzvx8S/JmjYTZwvSgAYFTtqq01I9ElCCo5zps=; b=S3ZZUrdHKuXV+GYUXMxTqNgutrcPImSUsAYjhYngyDquQlp4N+bB4oS8/eDwebCe7i AnZABNPrnOQ7TiWe9eJ/KTP5B9DjMzahpo1Z2vTxnoA/T+CT4fno+YhWPQelVF+15lIJ rzaOK8AccrI296IxltDGF3BA3XlCadVN5+RxseqNh7wtJfrXXaSSvGdZuTrDe5Up+d8o pLokLVaH3wYIQMgtNZNZXh1lWNvmeB1g54BazgvI1MWG3abVaNODZ68zW3GpRQpzXQuL xwwiBMcuztfH8s/aRwEEyBzc2wb/bVmcxWsgNR53ngZrtU/Euzbr/PSOpTSJFVaDdvOO LemA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FANfavlq; 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 f194si2898318oig.243.2020.01.11.02.01.28; Sat, 11 Jan 2020 02:01:39 -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=@kernel.org header.s=default header.b=FANfavlq; 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 S1728828AbgAKKA3 (ORCPT + 99 others); Sat, 11 Jan 2020 05:00:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:56590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729185AbgAKKA0 (ORCPT ); Sat, 11 Jan 2020 05:00:26 -0500 Received: from localhost (unknown [62.119.166.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C58662082E; Sat, 11 Jan 2020 10:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578736825; bh=ymVgdOoEAFWU4jK0LXVfQteJ4Fzw/vFX8zfX+147bdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FANfavlqjckXgxNpukAy2A0NiAXaE38M6uNG8EQC+Rl269HicBV9p9sWVVvhl43My 2xuTfLBrbXVth1pI13MUTlYcWRL/WJmaOI2oiP3UTGAHQZVjHE1RQ6XZWqrEDkaWfm fDKwjAfJAVDS3OcmqRQ/BcE9sHVUVTv3S+ilI3pE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+c732f8644185de340492@syzkaller.appspotmail.com, Brian Foster , "Darrick J. Wong" , Sasha Levin Subject: [PATCH 4.9 15/91] xfs: fix mount failure crash on invalid iclog memory access Date: Sat, 11 Jan 2020 10:49:08 +0100 Message-Id: <20200111094848.660860249@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200111094844.748507863@linuxfoundation.org> References: <20200111094844.748507863@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Brian Foster [ Upstream commit 798a9cada4694ca8d970259f216cec47e675bfd5 ] syzbot (via KASAN) reports a use-after-free in the error path of xlog_alloc_log(). Specifically, the iclog freeing loop doesn't handle the case of a fully initialized ->l_iclog linked list. Instead, it assumes that the list is partially constructed and NULL terminated. This bug manifested because there was no possible error scenario after iclog list setup when the original code was added. Subsequent code and associated error conditions were added some time later, while the original error handling code was never updated. Fix up the error loop to terminate either on a NULL iclog or reaching the end of the list. Reported-by: syzbot+c732f8644185de340492@syzkaller.appspotmail.com Signed-off-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Sasha Levin --- fs/xfs/xfs_log.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 33c9a3aae948..7bfcd09d446b 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c @@ -1540,6 +1540,8 @@ xlog_alloc_log( if (iclog->ic_bp) xfs_buf_free(iclog->ic_bp); kmem_free(iclog); + if (prev_iclog == log->l_iclog) + break; } spinlock_destroy(&log->l_icloglock); xfs_buf_free(log->l_xbuf); -- 2.20.1