From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA59234AAE4; Mon, 18 Aug 2025 14:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755526375; cv=none; b=fNXd6IynqOfawVeUeMNEjv/MN+C2qQEmSvrNPG/7X3hNmENPjKbBkGi3NmVVBjPw/Fh82Y1DqbfROVTf8t5EzkixWYOmt42RWKgJKegclR4ck0zwK0KfI/sXYjTJI00J1KQDT4jUY+sA4sJo4Hgowny48rtOnsOjNNt31CDmwVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755526375; c=relaxed/simple; bh=mCdXCQJc2t7D9SrNW4BBikES6zDJO/z1kTHZ0CTT+qw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q4HokUNGf6u7Nir3QnSnFwKC5PGWs5hGszUCJiT2hfoU56HsdJp9i+uUOImAoMYSLYLV75ihGacHauT670Mf63LbuXW3ATlLXTFey90L/agFLLB9BK0ncFc7Qc/Y9T6E7j2DRV+RKlqxY/KsWvFLFF4iCScAdH0KzvKMAc/KmbI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kYQYDEVf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kYQYDEVf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CCCBC4CEF1; Mon, 18 Aug 2025 14:12:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755526375; bh=mCdXCQJc2t7D9SrNW4BBikES6zDJO/z1kTHZ0CTT+qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kYQYDEVfwl8CEyYb605JM/dk4rpmWT+03mkPrqlvvqeJ9M+kWB/hoZRehghXn7jJZ W7qZs0F44PKDkT86fiKi4NZWrq017+rxsgCGjhx3uZtSbuNSv65GifYdQmWHaWju9K mrnMqVOmv6K/hI2LtnnGYfd5mt085bKLMVLC6u3Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+c2ea94ae47cd7e3881ec@syzkaller.appspotmail.com, Lizhi Xu , Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Andrew Morton Subject: [PATCH 6.16 537/570] ocfs2: reset folio to NULL when get folio fails Date: Mon, 18 Aug 2025 14:48:44 +0200 Message-ID: <20250818124526.571521822@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818124505.781598737@linuxfoundation.org> References: <20250818124505.781598737@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lizhi Xu commit 2ae826799932ff89409f56636ad3c25578fe7cf5 upstream. The reproducer uses FAULT_INJECTION to make memory allocation fail, which causes __filemap_get_folio() to fail, when initializing w_folios[i] in ocfs2_grab_folios_for_write(), it only returns an error code and the value of w_folios[i] is the error code, which causes ocfs2_unlock_and_free_folios() to recycle the invalid w_folios[i] when releasing folios. Link: https://lkml.kernel.org/r/20250616013140.3602219-1-lizhi.xu@windriver.com Reported-by: syzbot+c2ea94ae47cd7e3881ec@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=c2ea94ae47cd7e3881ec Signed-off-by: Lizhi Xu Reviewed-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/aops.c | 1 + 1 file changed, 1 insertion(+) --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -1071,6 +1071,7 @@ static int ocfs2_grab_folios_for_write(s if (IS_ERR(wc->w_folios[i])) { ret = PTR_ERR(wc->w_folios[i]); mlog_errno(ret); + wc->w_folios[i] = NULL; goto out; } }