Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp100528lqe; Fri, 5 Apr 2024 14:08:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU6QxOKcOBywlQBUnkh83vHNyEA+5kRlRbQZezSKmCai5nGcNlgy6zbwqtwIct5FdlhgUnkEdn69pdUgBwcZbNlyMw9OgSrbdfYSdTbfw== X-Google-Smtp-Source: AGHT+IGqJdn++wMsN76AFvKWWCook2m8mzYmM4LF2yUYP3OWyKBCY+8bQ7niPPkofG7OFdAvgyDu X-Received: by 2002:a05:622a:178f:b0:434:5e7e:9538 with SMTP id s15-20020a05622a178f00b004345e7e9538mr2316574qtk.16.1712351317102; Fri, 05 Apr 2024 14:08:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712351317; cv=pass; d=google.com; s=arc-20160816; b=fuzCs+JMRrTukimHpK/HMPw31FiaRQbRyJSmTNjNPQqM8WmCRLiaVXNNxZ4IMnfPGS mj+5pC9nGLVcW5YG1DlbRED5rPE07Nk50EEMQluJz+iWkRHMuVHjn24nqDfe8QuH2Q7H vLI/M5KzAey71BNLX4GMUGURI9OstGkA7Mj6sbl3OCoMzymeCL3KGVvwe+C/DmB+SXgA DOFNEQYxvhbA3B6MUY3VFy2mUR1Bzl4qsBLcKyl37jf/hSfapycur5RL6s2fPUmFfvCZ LsUUXnCM06jJSBJYOcCYxuHXGuZekzlPeRlVBTv/SNT8Wk/I9fPYbZpdTx/rc+Vp/PF/ Cp1g== 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=ankcvjCnWYEl74QlyFijcb2pcN+AU5nXfIOxKz9HVUs=; fh=HQg+pNZ3NdNctraiJlzPpXcj6Q2q2DTHRL7qbqZXm1g=; b=v7hexVmD7mBEPbwXpLxWINTztono4PzDsVjiAhKatbUidMeO/nVQW3aHidJuAM5d3r 51+2FYt87F31SNlWBsYDsqFy0sKroYicURQo9PydAm8HmWDSKmNxhrIIwmooi3W9yeKr OMehxGBpomjgWWKhGn52skqfemA/7BNJIRLCehQBBryJ+vJ/tFUiHlSEl8pR5yEtN8BJ S+CHxpEwQ4gwFNKWbEjTor3b6xuEXUd9fzJUudzlvPMZCtsXVWYgNgiv8twew82n/c3y AiVbt7DqZbn/Zt61pmLQ7VhBEQytGbYCaK8feg37oPSiwv5T7KBjxbxYBOzT2o/jZCGh MjZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=hpiQA8ev; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-ext4+bounces-1907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t5-20020ac85885000000b0043466fef512si1296192qta.218.2024.04.05.14.08.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 14:08:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b=hpiQA8ev; arc=pass (i=1 spf=pass spfdomain=yandex.ru dkim=pass dkdomain=yandex.ru dmarc=pass fromdomain=yandex.ru); spf=pass (google.com: domain of linux-ext4+bounces-1907-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1907-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=yandex.ru 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 CE0B21C20C53 for ; Fri, 5 Apr 2024 21:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C438174EFB; Fri, 5 Apr 2024 21:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b="hpiQA8ev" X-Original-To: linux-ext4@vger.kernel.org Received: from forward100c.mail.yandex.net (forward100c.mail.yandex.net [178.154.239.211]) (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 43CF0174ECB; Fri, 5 Apr 2024 21:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.154.239.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351307; cv=none; b=HIC2x6LCeqMRV+vbI3ILoMyDLjBZoGG0rE73dr7s23fyvPGIVlWJDGtKgdwFVQA4X7bYtXA0Gt3YAprYrYKYCCc/MPb9tcQ7wBzKWfqveDQdCiRgvATwC3VR4kuHEWbXh8PslBvLmfcaXUkKBxP5NAVInqXG/nl9tf+o02FxKAY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712351307; c=relaxed/simple; bh=BuUaqwqRMooOCayqSdCfqcPUua5XUE2+B4+1D+Bpq+g=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G32+GWMb62yRDDZgjWZZKOLJiOdyFcqcLTRSI2pBRmzUa3NQRSE6A8kGab/vvJsmBIU+O2dVHGOYAIaP1bq7xQTjXQf5opvzsm8rS/ALXJyB8XyssCHnH/MwPUIRHPBFwGWdoa0k1Ov//l89q4BnUcamZ5bs86ENHTZcYruWo/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru; spf=pass smtp.mailfrom=yandex.ru; dkim=pass (1024-bit key) header.d=yandex.ru header.i=@yandex.ru header.b=hpiQA8ev; arc=none smtp.client-ip=178.154.239.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:410d:0:640:81ab:0]) by forward100c.mail.yandex.net (Yandex) with ESMTPS id EAC2B608FF; Sat, 6 Apr 2024 00:08:20 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id 58dgY40f2mI0-s2z5ewZt; Sat, 06 Apr 2024 00:08:20 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1712351300; bh=ankcvjCnWYEl74QlyFijcb2pcN+AU5nXfIOxKz9HVUs=; h=Message-Id:Date:Cc:Subject:To:From; b=hpiQA8evIJLZ4olpHFL2cQ7I03vbuDXkgHOLLB/mqNk3Wo8SF4TSZiwF+2K0q/Nh6 /fVWGp+IFFs1PKipv7/RJfusYMvKU4nU2m0BZmYTYqCHhjWhwTZjka8jR7GNGKVS2f gftU5k1NiwGNjMKMrSCXRJwFMVypvj3iGpjFnMyg= Authentication-Results: mail-nwsmtp-smtp-production-main-54.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru From: Mikhail Ukhin To: "Theodore Ts'o" Cc: Mikhail Ukhin , stable@vger.kernel.org, Andreas Dilger , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, Michail Ivanov , Pavel Koshutin , lvc-project@linuxtesting.org, Ritesh Harjani , Artem Sadovnikov Subject: [PATCH v2] ext4: fix i_data_sem unlock order in ext4_ind_migrate() Date: Sat, 6 Apr 2024 00:08:03 +0300 Message-Id: <20240405210803.9152-1-mish.uxin2012@yandex.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Fuzzing reports a possible deadlock in jbd2_log_wait_commit. The problem occurs in ext4_ind_migrate due to an incorrect order of unlocking of the journal and write semaphores - the order of unlocking must be the reverse of the order of locking. Found by Linux Verification Center (linuxtesting.org) with syzkaller. Reviewed-by: Ritesh Harjani (IBM) Signed-off-by: Artem Sadovnikov Signed-off-by: Mikhail Ukhin --- v2: New addresses have been added and Ritesh Harjani has been noted as a reviewer. fs/ext4/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index b0ea646454ac..59290356aa5b 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c @@ -663,8 +663,8 @@ int ext4_ind_migrate(struct inode *inode) if (unlikely(ret2 && !ret)) ret = ret2; errout: - ext4_journal_stop(handle); up_write(&EXT4_I(inode)->i_data_sem); + ext4_journal_stop(handle); out_unlock: percpu_up_write(&sbi->s_writepages_rwsem); return ret; -- 2.25.1