All of lore.kernel.org
 help / color / mirror / Atom feed
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 2/5] fs/ntfs3: Improved checking of attribute's name length
Date: Fri, 30 Dec 2022 15:25:13 +0400	[thread overview]
Message-ID: <4e72d357-35de-f0d8-7f4b-f3f0e5f641b8@paragon-software.com> (raw)
In-Reply-To: <b06828df-f9b9-1c5d-d6db-05839bad7016@paragon-software.com>

Added comment, added null pointer checking.

Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/inode.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 8225d0b7c48c..51f9542de7b0 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -137,7 +137,13 @@ static struct inode *ntfs_read_mft(struct inode *inode,
      rsize = attr->non_res ? 0 : le32_to_cpu(attr->res.data_size);
      asize = le32_to_cpu(attr->size);

-    if (le16_to_cpu(attr->name_off) + attr->name_len > asize)
+    /*
+     * Really this check was done in 'ni_enum_attr_ex' -> ... 
'mi_enum_attr'.
+     * There not critical to check this case again
+     */
+    if (attr->name_len &&
+        sizeof(short) * attr->name_len + le16_to_cpu(attr->name_off) >
+            asize)
          goto out;

      if (attr->non_res) {
-- 
2.34.1

  parent reply	other threads:[~2022-12-30 11:25 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 ` Konstantin Komarov [this message]
2022-12-30 11:25 ` [PATCH 3/5] fs/ntfs3: Check for extremely large size of $AttrDef Konstantin Komarov
2022-12-30 11:26 ` [PATCH 4/5] fs/ntfs3: Restore overflow checking for attr size in mi_enum_attr Konstantin Komarov
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=4e72d357-35de-f0d8-7f4b-f3f0e5f641b8@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.