From nobody Sat Feb 7 18:21:09 2026 Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (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 9A209192D76 for ; Tue, 24 Dec 2024 14:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.43.8.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735052106; cv=none; b=GRYhEiZ06xi+aMEUWMyyk2BqEXIgWaNb2r9yCQ9p/Jiav89FO6Y5Dlws70t7QPcqGyv1wcxyFM3V42FqkcBytRTQoGzgvx5opjjK4iXC+fJTHZ4Waw4cNKiGL8RcAV6VGHoE+C82RlaQFvfMhyLqnsvOvhoNS0HyG/DW/SOC1e0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735052106; c=relaxed/simple; bh=K3HQFu6GgTHv7g2O3mvEfHjLYWjP7/Y0kwZTMhX8Gqc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j6/Lw9OYC4bR7xQ7UnJopJV+CqKPqXlewNOiETZ1tHjRUBDcwOunaNkvX4ciKqaqXxk8Z70+WtpZ0GCoDNMWe12BvksDyxu7rE53FjAC5Ujr3Ais+jAIqgJVoXwjC7gicQ6NOEW+D6A+RE3phKSg3plnlYA1nZz2z/bQpZZo3eU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=193.43.8.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from altlinux.ipa.basealt.ru (unknown [178.76.204.78]) by air.basealt.ru (Postfix) with ESMTPSA id E047F233AF; Tue, 24 Dec 2024 17:49:28 +0300 (MSK) From: Vasiliy Kovalev To: Dave Kleikamp , Josef Bacik , Matthew Wilcox , Christian Brauner , jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: lvc-project@linuxtesting.org, kovalev@altlinux.org, syzbot+4e89b5368baba8324e07@syzkaller.appspotmail.com Subject: [PATCH 1/2] jfs: add check read-only before txBeginAnon() call Date: Tue, 24 Dec 2024 17:49:13 +0300 Message-Id: <20241224144914.976419-2-kovalev@altlinux.org> X-Mailer: git-send-email 2.33.8 In-Reply-To: <20241224144914.976419-1-kovalev@altlinux.org> References: <20241224144914.976419-1-kovalev@altlinux.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Added a read-only check before calling `txBeginAnon` in `extAlloc` and `extRecord`. This prevents modification attempts on a read-only mounted filesystem, avoiding potential errors or crashes. Call trace: txBeginAnon+0xac/0x154 extAlloc+0xe8/0xdec fs/jfs/jfs_extent.c:78 jfs_get_block+0x340/0xb98 fs/jfs/inode.c:248 __block_write_begin_int+0x580/0x166c fs/buffer.c:2128 __block_write_begin fs/buffer.c:2177 [inline] block_write_begin+0x98/0x11c fs/buffer.c:2236 jfs_write_begin+0x44/0x88 fs/jfs/inode.c:299 Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: syzbot+4e89b5368baba8324e07@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=3D4e89b5368baba8324e07 Signed-off-by: Vasiliy Kovalev --- fs/jfs/jfs_extent.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/jfs/jfs_extent.c b/fs/jfs/jfs_extent.c index 63d21822d309be..46529bcc8297ea 100644 --- a/fs/jfs/jfs_extent.c +++ b/fs/jfs/jfs_extent.c @@ -74,6 +74,11 @@ extAlloc(struct inode *ip, s64 xlen, s64 pno, xad_t * xp= , bool abnr) int rc; int xflag; =20 + if (isReadOnly(ip)) { + jfs_error(ip->i_sb, "read-only filesystem\n"); + return -EIO; + } + /* This blocks if we are low on resources */ txBeginAnon(ip->i_sb); =20 @@ -253,6 +258,11 @@ int extRecord(struct inode *ip, xad_t * xp) { int rc; =20 + if (isReadOnly(ip)) { + jfs_error(ip->i_sb, "read-only filesystem\n"); + return -EIO; + } + txBeginAnon(ip->i_sb); =20 mutex_lock(&JFS_IP(ip)->commit_mutex); --=20 2.33.8 From nobody Sat Feb 7 18:21:09 2026 Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (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 9A1B938F91 for ; Tue, 24 Dec 2024 14:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.43.8.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735052106; cv=none; b=fm1L2N89FUT0Hnkh/uj7NIpzvh/6I14yq4MAOrTmjtkF39oL6erBtXsQPD6HCLQMczOEPAqIyYASrGmcRAe/kIfKtzPbkx3yUm/i2jqSUojgohXdwMsuOniBf3ofdFmcVGpx+41Ry6t/wZvIwRrHdvCcEJkj3Lf7l8imzzJT9NE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735052106; c=relaxed/simple; bh=CBYXLkNd12+jvfnIlbEUOdPG952WG7cnTmWtLmst6W4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GfhHoS93y+ewlVtX4JZfWMWfo4+NuxcFxklhIkRoxaHwUzYF8l7xUJBQ6Q3r7V3rF0j7QhiCudi8W1GZp7zib1u1A4SoYQ5VEx8/bkZE9HOeAr5rXhpCXXvqkgq9NapamQOBd4ddkEhCAaSRmKYf2IvHW6duONXboH5FsJ9zNoc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=193.43.8.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from altlinux.ipa.basealt.ru (unknown [178.76.204.78]) by air.basealt.ru (Postfix) with ESMTPSA id 9A035233B5; Tue, 24 Dec 2024 17:49:29 +0300 (MSK) From: Vasiliy Kovalev To: Dave Kleikamp , Josef Bacik , Matthew Wilcox , Christian Brauner , jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: lvc-project@linuxtesting.org, kovalev@altlinux.org, syzbot+4e89b5368baba8324e07@syzkaller.appspotmail.com Subject: [PATCH 2/2] jfs: add check read-only before truncation in jfs_truncate_nolock() Date: Tue, 24 Dec 2024 17:49:14 +0300 Message-Id: <20241224144914.976419-3-kovalev@altlinux.org> X-Mailer: git-send-email 2.33.8 In-Reply-To: <20241224144914.976419-1-kovalev@altlinux.org> References: <20241224144914.976419-1-kovalev@altlinux.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Added a check for "read-only" mode in the `jfs_truncate_nolock` function to avoid errors related to writing to a read-only filesystem. Call stack: block_write_begin() { jfs_write_failed() { jfs_truncate() { jfs_truncate_nolock() { txEnd() { ... log =3D JFS_SBI(tblk->sb)->log; // (log =3D=3D NULL) If the `isReadOnly(ip)` condition is triggered in `jfs_truncate_nolock`, the function execution will stop, and no further data modification will occur. Instead, the `xtTruncate` function will be called with the "COMMIT_WMAP" flag, preventing modifications in "read-only" mode. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: syzbot+4e89b5368baba8324e07@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=3D4e89b5368baba8324e07 Signed-off-by: Vasiliy Kovalev --- fs/jfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 07cfdc4405968b..60fc92dee24d20 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c @@ -369,7 +369,7 @@ void jfs_truncate_nolock(struct inode *ip, loff_t lengt= h) =20 ASSERT(length >=3D 0); =20 - if (test_cflag(COMMIT_Nolink, ip)) { + if (test_cflag(COMMIT_Nolink, ip) || isReadOnly(ip)) { xtTruncate(0, ip, length, COMMIT_WMAP); return; } --=20 2.33.8