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] fs/ntfs3: Disable ATTR_LIST_ENTRY size check
Date: Thu, 21 Dec 2023 14:35:39 +0300	[thread overview]
Message-ID: <894db108-509b-4026-a90e-666a759a3f9f@paragon-software.com> (raw)


The use of sizeof(struct ATTR_LIST_ENTRY) has been replaced with le_size(0)
due to alignment peculiarities on different platforms.

Reported-by: kernel test robot <lkp@intel.com>
Closes: 
https://lore.kernel.org/oe-kbuild-all/202312071005.g6YrbaIe-lkp@intel.com/
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
---
  fs/ntfs3/attrlist.c | 8 ++++----
  fs/ntfs3/ntfs.h     | 2 --
  2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/ntfs3/attrlist.c b/fs/ntfs3/attrlist.c
index 7c01735d1219..48e7da47c6b7 100644
--- a/fs/ntfs3/attrlist.c
+++ b/fs/ntfs3/attrlist.c
@@ -127,12 +127,13 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct 
ntfs_inode *ni,
  {
      size_t off;
      u16 sz;
+    const unsigned le_min_size = le_size(0);

      if (!le) {
          le = ni->attr_list.le;
      } else {
          sz = le16_to_cpu(le->size);
-        if (sz < sizeof(struct ATTR_LIST_ENTRY)) {
+        if (sz < le_min_size) {
              /* Impossible 'cause we should not return such le. */
              return NULL;
          }
@@ -141,7 +142,7 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct 
ntfs_inode *ni,

      /* Check boundary. */
      off = PtrOffset(ni->attr_list.le, le);
-    if (off + sizeof(struct ATTR_LIST_ENTRY) > ni->attr_list.size) {
+    if (off + le_min_size > ni->attr_list.size) {
          /* The regular end of list. */
          return NULL;
      }
@@ -149,8 +150,7 @@ struct ATTR_LIST_ENTRY *al_enumerate(struct 
ntfs_inode *ni,
      sz = le16_to_cpu(le->size);

      /* Check le for errors. */
-    if (sz < sizeof(struct ATTR_LIST_ENTRY) ||
-        off + sz > ni->attr_list.size ||
+    if (sz < le_min_size || off + sz > ni->attr_list.size ||
          sz < le->name_off + le->name_len * sizeof(short)) {
          return NULL;
      }
diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h
index c8981429c721..9c7478150a03 100644
--- a/fs/ntfs3/ntfs.h
+++ b/fs/ntfs3/ntfs.h
@@ -527,8 +527,6 @@ struct ATTR_LIST_ENTRY {

  }; // sizeof(0x20)

-static_assert(sizeof(struct ATTR_LIST_ENTRY) == 0x20);
-
  static inline u32 le_size(u8 name_len)
  {
      return ALIGN(offsetof(struct ATTR_LIST_ENTRY, name) +
-- 
2.34.1


                 reply	other threads:[~2023-12-21 11:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=894db108-509b-4026-a90e-666a759a3f9f@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.