public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavoars@kernel.org>
To: Jan Kara <jack@suse.com>
Cc: linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	linux-hardening@vger.kernel.org
Subject: [PATCH][next] udf: Fix undefined behavior bug in struct udf_fileident_iter
Date: Mon, 2 Oct 2023 18:14:26 +0200	[thread overview]
Message-ID: <ZRrsYkKIQe8K6F/t@work> (raw)

`struct fileIdentDesc` is a flexible structure, which means that it
contains a flexible-array member at the bottom. This could potentially
lead to an overwrite of the objects following `fi` in `struct
udf_fileident_iter` at run-time.

Fix this by placing the declaration of object `fi` at the end of
`struct udf_fileident_iter`.

-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.

Fixes: d16076d9b684 ("udf: New directory iteration code")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 fs/udf/udfdecl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 88692512a466..736f591abc89 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -93,11 +93,11 @@ struct udf_fileident_iter {
 	sector_t loffset;		/* Block offset of 'pos' within above
 					 * extent */
 	struct extent_position epos;	/* Position after the above extent */
-	struct fileIdentDesc fi;	/* Copied directory entry */
 	uint8_t *name;			/* Pointer to entry name */
 	uint8_t *namebuf;		/* Storage for entry name in case
 					 * the name is split between two blocks
 					 */
+	struct fileIdentDesc fi;	/* Copied directory entry */
 };
 
 struct udf_vds_record {
-- 
2.34.1


             reply	other threads:[~2023-10-02 16:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-02 16:14 Gustavo A. R. Silva [this message]
2023-10-02 17:38 ` [PATCH][next] udf: Fix undefined behavior bug in struct udf_fileident_iter Kees Cook
2023-10-03  9:26 ` Jan Kara

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=ZRrsYkKIQe8K6F/t@work \
    --to=gustavoars@kernel.org \
    --cc=jack@suse.com \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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