From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E445C001B0 for ; Mon, 24 Jul 2023 01:28:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231588AbjGXB2r (ORCPT ); Sun, 23 Jul 2023 21:28:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231539AbjGXB1p (ORCPT ); Sun, 23 Jul 2023 21:27:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEDF446B0; Sun, 23 Jul 2023 18:25:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2825860E9C; Mon, 24 Jul 2023 01:24:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C272DC433BD; Mon, 24 Jul 2023 01:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690161856; bh=nZcd8Y0w1L07bToIpy37Cq9joP5aPuM7Dv2MNvW6M3Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bo8GrmqOw3+yYM3hageqGBaae8Lawp3WqKRXStXw9qwT1fZ7LPFzcsd3UDdoWaME1 ZX1VHf4yS7Hn54q9NoFeyrNO9LIt1DnjqAa7+alg2oEeVti1Mm6RYWOAgDqDo+8sO5 hNSAnIsTR6qMivfrocvTBNkNzEirYHuIkODlXIPHQfBTCLgtaspNviRTjv80efegzu aUz7VMJf3Yp/J9YvjX3P8UIiT7zQvqTTeE4rE8g5jNPdILASW+tlyvcKOncK8wFlsX 2TYMdebfujb6Mr51757GM6LbpYGvE1/WQjDNpro34VqbtL43G+c4INmTjel/uFtGIz aoimUWA8pDXuw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Immad Mir , syzbot+f1faa20eec55e0c8644c@syzkaller.appspotmail.com, Dave Kleikamp , Sasha Levin , shaggy@kernel.org, jfs-discussion@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.15 22/23] FS: JFS: Fix null-ptr-deref Read in txBegin Date: Sun, 23 Jul 2023 21:23:33 -0400 Message-Id: <20230724012334.2317140-22-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230724012334.2317140-1-sashal@kernel.org> References: <20230724012334.2317140-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.15.121 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Immad Mir [ Upstream commit 47cfdc338d674d38f4b2f22b7612cc6a2763ba27 ] Syzkaller reported an issue where txBegin may be called on a superblock in a read-only mounted filesystem which leads to NULL pointer deref. This could be solved by checking if the filesystem is read-only before calling txBegin, and returning with appropiate error code. Reported-By: syzbot+f1faa20eec55e0c8644c@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?id=be7e52c50c5182cc09a09ea6fc456446b2039de3 Signed-off-by: Immad Mir Signed-off-by: Dave Kleikamp Signed-off-by: Sasha Levin --- fs/jfs/namei.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 4fbbf88435e69..b3a0fe0649c49 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -799,6 +799,11 @@ static int jfs_link(struct dentry *old_dentry, if (rc) goto out; + if (isReadOnly(ip)) { + jfs_error(ip->i_sb, "read-only filesystem\n"); + return -EROFS; + } + tid = txBegin(ip->i_sb, 0); mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT); -- 2.39.2