From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Jia-Ju Bai <baijiaju@buaa.edu.cn>,
Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.15 19/24] fs: ntfs3: Fix possible null-pointer dereferences in mi_read()
Date: Sun, 23 Jul 2023 21:33:20 -0400 [thread overview]
Message-ID: <20230724013325.2332084-19-sashal@kernel.org> (raw)
In-Reply-To: <20230724013325.2332084-1-sashal@kernel.org>
From: Jia-Ju Bai <baijiaju@buaa.edu.cn>
[ Upstream commit 97498cd610c0d030a7bd49a7efad974790661162 ]
In a previous commit 2681631c2973 ("fs/ntfs3: Add null pointer check to
attr_load_runs_vcn"), ni can be NULL in attr_load_runs_vcn(), and thus it
should be checked before being used.
However, in the call stack of this commit, mft_ni in mi_read() is
aliased with ni in attr_load_runs_vcn(), and it is also used in
mi_read() at two places:
mi_read()
rw_lock = &mft_ni->file.run_lock -> No check
attr_load_runs_vcn(mft_ni, ...)
ni (namely mft_ni) is checked in the previous commit
attr_load_runs_vcn(..., &mft_ni->file.run) -> No check
Thus, to avoid possible null-pointer dereferences, the related checks
should be added.
These bugs are reported by a static analysis tool implemented by myself,
and they are found by extending a known bug fixed in the previous commit.
Thus, they could be theoretical bugs.
Signed-off-by: Jia-Ju Bai <baijiaju@buaa.edu.cn>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ntfs3/record.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c
index 41f6e578966b2..3d222b1c8f038 100644
--- a/fs/ntfs3/record.c
+++ b/fs/ntfs3/record.c
@@ -124,7 +124,7 @@ int mi_read(struct mft_inode *mi, bool is_mft)
struct rw_semaphore *rw_lock = NULL;
if (is_mounted(sbi)) {
- if (!is_mft) {
+ if (!is_mft && mft_ni) {
rw_lock = &mft_ni->file.run_lock;
down_read(rw_lock);
}
@@ -148,7 +148,7 @@ int mi_read(struct mft_inode *mi, bool is_mft)
ni_lock(mft_ni);
down_write(rw_lock);
}
- err = attr_load_runs_vcn(mft_ni, ATTR_DATA, NULL, 0, &mft_ni->file.run,
+ err = attr_load_runs_vcn(mft_ni, ATTR_DATA, NULL, 0, run,
vbo >> sbi->cluster_bits);
if (rw_lock) {
up_write(rw_lock);
--
2.39.2
next prev parent reply other threads:[~2023-07-24 1:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-24 1:33 [PATCH AUTOSEL 5.15 01/24] media: v4l2-mem2mem: add lock to protect parameter num_rdy Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 02/24] media: camss: set VFE bpl_alignment to 16 for sdm845 and sm8250 Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 03/24] usb: gadget: u_serial: Avoid spinlock recursion in __gs_console_push Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 04/24] media: platform: mediatek: vpu: fix NULL ptr dereference Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 05/24] thunderbolt: Read retimer NVM authentication status prior tb_retimer_set_inbound_sbtx() Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 06/24] xhci: Don't require a valid get_quirks() function pointer during xhci setup Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 07/24] usb: chipidea: imx: don't request QoS for imx8ulp Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 08/24] usb: cdns2: Device side header file for CDNS2 driver Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 09/24] usb: chipidea: imx: add missing USB PHY DPDM wakeup setting Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 10/24] gfs2: Fix possible data races in gfs2_show_options() Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 11/24] pcmcia: rsrc_nonstatic: Fix memory leak in nonstatic_release_resource_db() Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 12/24] firewire: net: fix use after free in fwnet_finish_incoming_packet() Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 13/24] watchdog: sp5100_tco: support Hygon FCH/SCH (Server Controller Hub) Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 14/24] Bluetooth: L2CAP: Fix use-after-free Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 15/24] Bluetooth: L2CAP: Fix use-after-free in l2cap_sock_ready_cb Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 16/24] Bluetooth: btusb: Add MT7922 bluetooth ID for the Asus Ally Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 17/24] drm/amdgpu: Fix potential fence use-after-free v2 Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 18/24] fs/ntfs3: Enhance sanity check while generating attr_list Sasha Levin
2023-07-24 1:33 ` Sasha Levin [this message]
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 20/24] fs/ntfs3: Use __GFP_NOWARN allocation at ntfs_load_attr_list() Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 21/24] fs/ntfs3: Mark ntfs dirty when on-disk struct is corrupted Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 22/24] ALSA: hda/realtek: Add quirks for Unis H3C Desktop B760 & Q760 Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 23/24] ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync() Sasha Levin
2023-07-24 1:33 ` [PATCH AUTOSEL 5.15 24/24] apparmor: fix use of strcpy in policy_unpack_test Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230724013325.2332084-19-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=baijiaju@buaa.edu.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®