From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: <linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 4/5] fs/ntfs3: Restore overflow checking for attr size in mi_enum_attr
Date: Fri, 30 Dec 2022 15:26:18 +0400 [thread overview]
Message-ID: <e7c02fd6-3e32-7b25-935b-67f5539184e5@paragon-software.com> (raw)
In-Reply-To: <b06828df-f9b9-1c5d-d6db-05839bad7016@paragon-software.com>
Fixed comment.
Removed explicit initialization for INDEX_ROOT.
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
fs/ntfs3/index.c | 7 ++++---
fs/ntfs3/record.c | 5 +++++
fs/ntfs3/super.c | 2 +-
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/ntfs3/index.c b/fs/ntfs3/index.c
index 8718df791a55..9fefeac5fe7e 100644
--- a/fs/ntfs3/index.c
+++ b/fs/ntfs3/index.c
@@ -994,7 +994,7 @@ struct INDEX_ROOT *indx_get_root(struct ntfs_index
*indx, struct ntfs_inode *ni,
struct ATTR_LIST_ENTRY *le = NULL;
struct ATTRIB *a;
const struct INDEX_NAMES *in = &s_index_names[indx->type];
- struct INDEX_ROOT *root = NULL;
+ struct INDEX_ROOT *root;
a = ni_find_attr(ni, NULL, &le, ATTR_ROOT, in->name, in->name_len,
NULL,
mi);
@@ -1007,8 +1007,9 @@ struct INDEX_ROOT *indx_get_root(struct ntfs_index
*indx, struct ntfs_inode *ni,
root = resident_data_ex(a, sizeof(struct INDEX_ROOT));
/* length check */
- if (root && offsetof(struct INDEX_ROOT, ihdr) +
le32_to_cpu(root->ihdr.used) >
- le32_to_cpu(a->res.data_size)) {
+ if (root &&
+ offsetof(struct INDEX_ROOT, ihdr) + le32_to_cpu(root->ihdr.used) >
+ le32_to_cpu(a->res.data_size)) {
return NULL;
}
diff --git a/fs/ntfs3/record.c b/fs/ntfs3/record.c
index abfe004774c0..0603169ee8a0 100644
--- a/fs/ntfs3/record.c
+++ b/fs/ntfs3/record.c
@@ -220,6 +220,11 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi,
struct ATTRIB *attr)
return NULL;
}
+ if (off + asize < off) {
+ /* Overflow check. */
+ return NULL;
+ }
+
attr = Add2Ptr(attr, asize);
off += asize;
}
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 0967035146ce..19d0889b131f 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1187,7 +1187,7 @@ static int ntfs_fill_super(struct super_block *sb,
struct fs_context *fc)
/*
* Typical $AttrDef contains up to 20 entries.
- * Check for extremely large size.
+ * Check for extremely large/small size.
*/
if (inode->i_size < sizeof(struct ATTR_DEF_ENTRY) ||
inode->i_size > 100 * sizeof(struct ATTR_DEF_ENTRY)) {
--
2.34.1
next prev parent reply other threads:[~2022-12-30 11:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-30 11:23 [PATCH 0/5] fs/ntfs3: Refactoring and bugfix Konstantin Komarov
2022-12-30 11:23 ` [PATCH 1/5] fs/ntfs3: Add null pointer checks Konstantin Komarov
2022-12-30 11:25 ` [PATCH 2/5] fs/ntfs3: Improved checking of attribute's name length Konstantin Komarov
2022-12-30 11:25 ` [PATCH 3/5] fs/ntfs3: Check for extremely large size of $AttrDef Konstantin Komarov
2022-12-30 11:26 ` Konstantin Komarov [this message]
2022-12-30 11:27 ` [PATCH 5/5] fs/ntfs3: Refactoring of various minor issues Konstantin Komarov
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=e7c02fd6-3e32-7b25-935b-67f5539184e5@paragon-software.com \
--to=almaz.alexandrovich@paragon-software.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
/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®