All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Anton Altaparmakov <anton@tuxera.com>
Cc: Kees Cook <keescook@chromium.org>,
	Namjae Jeon <linkinjeon@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-ntfs-dev@lists.sourceforge.net,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ntfs: Replace struct ntfs_name 0-sized array with flexible array
Date: Fri, 16 Feb 2024 15:29:03 -0800	[thread overview]
Message-ID: <20240216232903.work.643-kees@kernel.org> (raw)

ntfs_name::name is used as a destination in memcpy(), so it cannot be a
0-sized array any more. Convert it to a flexible array and annotated
with __counted_by, which matches the allocations.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: linux-ntfs-dev@lists.sourceforge.net
Cc: linux-hardening@vger.kernel.org
---
 fs/ntfs/dir.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs/dir.h b/fs/ntfs/dir.h
index 0e326753df40..cafcd339094c 100644
--- a/fs/ntfs/dir.h
+++ b/fs/ntfs/dir.h
@@ -22,7 +22,7 @@ typedef struct {
 	MFT_REF mref;
 	FILE_NAME_TYPE_FLAGS type;
 	u8 len;
-	ntfschar name[0];
+	ntfschar name[] __counted_by(len);
 } __attribute__ ((__packed__)) ntfs_name;
 
 /* The little endian Unicode string $I30 as a global constant. */
-- 
2.34.1


                 reply	other threads:[~2024-02-16 23:29 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=20240216232903.work.643-kees@kernel.org \
    --to=keescook@chromium.org \
    --cc=anton@tuxera.com \
    --cc=gustavoars@kernel.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    /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.