Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3168004lqo; Wed, 15 May 2024 01:29:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJr64vu40iLzZU852DcbBQp9PwBLaibfT9FMWn709u1UFUoSMKLL2eVZsce/CxSHrznIQdaw8HF36FQYoLYbBP97s58wiKGkDL5rxP9A== X-Google-Smtp-Source: AGHT+IEIRekaKrNTxKCZIpF3UK1ctW9Ep0xJXBQRRFySR/21KIkJkZRwmLfBZ5YX8+RUVz5VKyJR X-Received: by 2002:a05:6102:32c9:b0:47c:329f:4df6 with SMTP id ada2fe7eead31-48077e1b769mr15290047137.17.1715761751561; Wed, 15 May 2024 01:29:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715761751; cv=pass; d=google.com; s=arc-20160816; b=Xp2u9vWgKTSbPW+aFs+2wPUMAvqU3t45MgOLr1m9MZkoiWE+yQ1wQWUJGFx0lQqsT1 +84vTx0vSlyLM/M9MznaPvWeh8DnMHk4H3hSB+CGc51ArJN+XibP//046xkGk+A+uxwq anyUObpVRr4ThATTj8o2OhOPC6OxR0d0/JU+YfR7Sn5GS2YomLGaluBq2TqPXAGPpFlr ZKnjNipqJHu9fh+jsA5MkcEJKX5pxBhKXXD0/xcGpOMMP8yY4IiSblOhUaA6zIxT5iXf aYL8ZcaZa0VpBbc+DkOIdoy5rNHxUcdct+4+oba3hEzH23vhufkv2UZ/CNHVkhu+vtyK 2aAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=HYBLWkWoaQKiEAZWraoUP+5u1JtAI4hFJMaHd418eeU=; fh=eYnzAmjrJ+LtpeahVQN7NYPGOUGOPOH1SWeHe1pq7JQ=; b=ceTgnP8HRMKZ3Y9CCaY2p/0v9JKv5A0iTmDu++aoSxLx9RtNN+Ff/+BxtxdPYtoE7V FnWwTUFyuE8I1Kdcv0G8hwvDVhFImuyUooaY4ql+Mg3ID56upOY9sefR7fCuF686WzOb Bh29r36rqDdWuZ3DmOFD+Jyk5AWRHRyqivOr5FXrEdLS2mATmffOdREMmFgHY5RX0gtO ibTKY2VFWoBLAK3mpOyFoNiPokEb1J4PZ5syPe6VFI2YUpD7UTFOTQebACj0CkU/cSv1 umIDEYNQsiyvSi8v8vQmyQk5LDFijR4je9SSbSrhn6OIT8LUwqVI2GVDMSZt4S/h0oHO c2hw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=clt3jbDv; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-179655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43df56d4326si137292331cf.685.2024.05.15.01.29.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 01:29:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=clt3jbDv; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-179655-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179655-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 280CA1C20C9A for ; Wed, 15 May 2024 08:29:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B7F04F88C; Wed, 15 May 2024 08:29:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="clt3jbDv" Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (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 053BD4F1F8 for ; Wed, 15 May 2024 08:29:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715761745; cv=none; b=q0LAr8b9rTZOt/k3/8kFCAEj0gIfUTFe/UUQ83bHbZXHzBaMPiAnATfW3X4xhw8pofkAedkmKdZQo9ZkOiogwP9ZEeKmpRTcis9txEVixp31pZ6IV3/99UmQBopttGZ87SnRdO09+/Lb5pZ/MiOMN7lszDFltC1CuDPnAY2R3Qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715761745; c=relaxed/simple; bh=GRy5EBqyOSgFzYOwDEtJf45D7LNOsyCxMbOV7SdxB6Y=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Gl780MawD+ifxUo60ni3fuxpZBXCqnLvGL8hHMOb6zcCVXjBMpZaMe15TeGzI/ozNH6o5U5owNH2IEXiJKIJIkiTZi082Eh0MOmQpjx9R0x85S4lH2Gi27GpVJPNEJJMOtzuUzX77IeYO9YPOuXGcxPn5Xyn1DZLaJjF+Uyw0jw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=clt3jbDv; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715761741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=HYBLWkWoaQKiEAZWraoUP+5u1JtAI4hFJMaHd418eeU=; b=clt3jbDvFUaWWMfNqOMYMVmorC+WrbeA5JAsXYDcp0eCJUBCmxzJPxNZFcjdir7H+MShfw gRWIgpXRYsQ64b5sOMEiHaoxe5sdwOidcKL6/b5oUZTGW2auvJZPfwRYLFvueDIM+zV9UH raMjX8rno7YscEUmcPRwQrif1Zk8/hg= From: "Luis Henriques (SUSE)" To: Theodore Ts'o , Andreas Dilger , Zhang Yi , Harshad Shirwadkar Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, "Luis Henriques (SUSE)" Subject: [PATCH v2] ext4: fix infinite loop when replaying fast_commit Date: Wed, 15 May 2024 09:28:57 +0100 Message-ID: <20240515082857.32730-1-luis.henriques@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT When doing fast_commit replay an infinite loop may occur due to an uninitialized extent_status struct. ext4_ext_determine_insert_hole() does not detect the replay and calls ext4_es_find_extent_range(), which will return immediately without initializing the 'es' variable. Because 'es' contains garbage, an integer overflow may happen causing an infinite loop in this function, easily reproducible using fstest generic/039. This commit fixes this issue by unconditionally initializing the structure in function ext4_es_find_extent_range(). Thanks to Zhang Yi, for figuring out the real problem! Fixes: 8016e29f4362 ("ext4: fast commit recovery path") Signed-off-by: Luis Henriques (SUSE) --- fs/ext4/extents_status.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 4a00e2f019d9..3a53dbb85e15 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c @@ -310,6 +310,8 @@ void ext4_es_find_extent_range(struct inode *inode, ext4_lblk_t lblk, ext4_lblk_t end, struct extent_status *es) { + es->es_lblk = es->es_len = es->es_pblk = 0; + if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY) return;