From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: almaz.alexandrovich@paragon-software.com, edward.lo@ambergroup.io
Cc: ntfs3@lists.linux.dev, linux-kernel@vger.kernel.org,
Jia-Ju Bai <baijiaju1990@gmail.com>,
TOTE Robot <oslab@tsinghua.edu.cn>
Subject: [PATCH resend] fs: ntfs3: Add check for mft_ni in mi_read()
Date: Sat, 14 Jan 2023 09:54:41 +0800 [thread overview]
Message-ID: <20230114015441.777119-1-baijiaju1990@gmail.com> (raw)
In a previous commit 2681631c2973, the parameter ni of
attr_load_runs_vcn() can be NULL, and thus a NULL check is added.
However, in the same call stack, this variable is also dereferenced in
mi_read():
mi_read()
ni_lock(mft_ni);
attr_load_runs_vcn(mft_ni)
if (ni) -> Add a check by previous commit (ni is mft_ni)
ni_unlock(mft_ni);
Thus, to avoid possible null-pointer dereferences, mft_ni should be
also checked in mi_read().
These results are reported by a static tool designed by myself
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
---
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 defce6a5c8e1..9c5f922543c2 100644
--- a/fs/ntfs3/record.c
+++ b/fs/ntfs3/record.c
@@ -144,13 +144,13 @@ int mi_read(struct mft_inode *mi, bool is_mft)
if (err != -ENOENT)
goto out;
- if (rw_lock) {
+ if (rw_lock && mft_ni) {
ni_lock(mft_ni);
down_write(rw_lock);
}
err = attr_load_runs_vcn(mft_ni, ATTR_DATA, NULL, 0, &mft_ni->file.run,
vbo >> sbi->cluster_bits);
- if (rw_lock) {
+ if (rw_lock && mft_ni) {
up_write(rw_lock);
ni_unlock(mft_ni);
}
--
2.34.1
next reply other threads:[~2023-01-14 1:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-14 1:54 Jia-Ju Bai [this message]
2023-01-14 2:13 ` Al Viro
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=20230114015441.777119-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=edward.lo@ambergroup.io \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
--cc=oslab@tsinghua.edu.cn \
/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®