From nobody Fri Dec 19 10:09:53 2025 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD08E221FCF for ; Mon, 8 Dec 2025 12:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765197957; cv=none; b=k7DSSinv2se1rTvzlrW4cl7DJMLUBPbPc9zzrN5JxpsLveMTO7EEgn6xSKZvsjkK+FUD1GdJsgDFl5SByvsJ52NAa0USW4NUfXOfcs/KwhEdkOCrd+Z++y2q9lI/5LXieUCn3PhjfMTWpnvSD1Jp1ojJTDotcdvPySc5N9OxHes= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765197957; c=relaxed/simple; bh=pHKk3KMjtFoifVs1u6wF9F6BM8haSfKlWNHtkHGs9Cs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=kK8z1F7yBNWt+IkhDWbZDsNaJgNrtNyU/8RyKFW8WKqqWldH3+HCVcdAdKUNW1tF7K5DgovqC1LH6wIEteBkiSu6425MBYcvTIfhqqZz0u4kd+cg3UYvMTRelEL1J45fZBUNPyvPadbnpUvmIoXGC8xE0TFYT5ier8gw6ey+LPY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7c6c91ba9caso6962988a34.0 for ; Mon, 08 Dec 2025 04:45:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765197955; x=1765802755; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5m5Jc/DcPscL1kTJbPdqSPkJtaZ8kSFCkilKAefLA7Q=; b=D9KPdw26Ao3weUD08RsfCACoNVQW6rjJVtzoTFoF/4uSPoJM+wHLHFg5DS5QAOqG6R 9/w4oSo5HZ6V9PGz/yWHR9DCnrEgivno/pTd4kAyYDbpjS3tbzWflCwa99+s2ClEv+2g j0f5Nclkikp6V41OGnHquUzm7asCnvsmM9iIFIeoW2ctCzgFPfPnuUwyP0oChAglYVGF p+lZ8OfE9Y+YQAe/jNDzSnOkkZRUd0/S7tvuaXFA6xZwciplMNxw4S7AAmy8mm3DT40d kZZ8YKMBbfyCZ8roR+UdEuJmNoTsmk6rrEAn+hDkD8wkqlLmpHN08obwVk61HJI6mzhz lizA== X-Gm-Message-State: AOJu0YwLtLnIVwVi8gs/jcFdxqYvOrmK+vDXLg4jHgbNaptb6bQksjQd KCLaF1Is+vMwea0O5F1ZPxqtERDeqE5wHMCEdtuUP6mAyD9nAmDLIWcv/FoY9PncrHBByMXUbt4 peVawvtpPOsG93hbkDe4R8JhC1V3pi/CLdMNvLHIgIjRjnBzfbOFI6n8dDMA= X-Google-Smtp-Source: AGHT+IGnbnUOXF02qnTbtaY/PzKhSyDX9dLMv+evHKM6CNqigYlLqgeBruVw/XWiiRJz7UL3geE15CCsWHbSath3LuTYAf1pGH7E Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:22a7:b0:657:4733:dde with SMTP id 006d021491bc7-6599a89e7b2mr3277709eaf.8.1765197954987; Mon, 08 Dec 2025 04:45:54 -0800 (PST) Date: Mon, 08 Dec 2025 04:45:54 -0800 In-Reply-To: <69368649.a70a0220.38f243.0093.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6936c882.a70a0220.38f243.00a5.GAE@google.com> Subject: Forwarded: [PATCH] ext4: fix missing i_data_sem lock in move_extent repair path From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] ext4: fix missing i_data_sem lock in move_extent repair pa= th Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master ext4_swap_extents() requires both i_data_sem locks to be held, as enforced by BUG_ON checks at the function entry. However, the repair_branches error path in mext_move_extent() calls ext4_swap_extents() without holding these locks. When mext_folio_mkwrite() fails after a successful extent swap, the code jumps to repair_branches to restore the original extent mapping. At this point, i_data_sem has already been released, causing the BUG_ON in ext4_swap_extents() to trigger. Fix this by acquiring i_data_sem for both inodes before calling ext4_swap_extents() in the repair_branches path, matching the locking pattern used in the normal swap path. Reported-by: syzbot+4ea6bd8737669b423aae@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D4ea6bd8737669b423aae Signed-off-by: Deepanshu Kartikey --- fs/ext4/move_extent.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 0550fd30fd10..635fb8a52e0c 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -393,9 +393,11 @@ static int mext_move_extent(struct mext_data *mext, u6= 4 *m_len) =20 repair_branches: ret2 =3D 0; + ext4_double_down_write_data_sem(orig_inode, donor_inode); r_len =3D ext4_swap_extents(handle, donor_inode, orig_inode, mext->donor_lblk, orig_map->m_lblk, *m_len, 0, &ret2); + ext4_double_up_write_data_sem(orig_inode, donor_inode); if (ret2 || r_len !=3D *m_len) { ext4_error_inode_block(orig_inode, (sector_t)(orig_map->m_lblk), EIO, "Unable to copy data block, data will be lost!"); --=20 2.43.0