From: Jivan Hakobyan <jivanhakobyan9@gmail.com>
To: gcc-patches@gcc.gnu.org
Cc: Jeff Law <jlaw@ventanamicro.com>
Subject: LTO: buffer overflow in lto_output_init_mode_table
Date: Thu, 22 Jun 2023 15:36:51 +0400 [thread overview]
Message-ID: <CAHso6sMRM9YmzmpuHTeMNAd1e2PKXkCkkkdnM1-M34YqGZ8b2w@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 398 bytes --]
In the case when enabled -flto=N GCC aborted compilation.
The reason is the overflowing streamer_mode_table buffer.
It has 1 << 8 bytes but lto_output_init_mode_table() tries to fill
with MAX_MACHINE_MODE bytes.
gcc/ChangeLog:
* tree-streamer.h (streamer_mode_table): Changed buffer size
* tree-streamer.cc (streamer_mode_table): Likewise.
--
With the best regards
Jivan Hakobyan
[-- Attachment #2: lto.patch --]
[-- Type: text/x-patch, Size: 1232 bytes --]
diff --git a/gcc/tree-streamer.cc b/gcc/tree-streamer.cc
index ed65a7692e3..a28ef9c7920 100644
--- a/gcc/tree-streamer.cc
+++ b/gcc/tree-streamer.cc
@@ -35,7 +35,7 @@ along with GCC; see the file COPYING3. If not see
During streaming in, we translate the on the disk mode using this
table. For normal LTO it is set to identity, for ACCEL_COMPILER
depending on the mode_table content. */
-unsigned char streamer_mode_table[1 << 8];
+unsigned char streamer_mode_table[MAX_MACHINE_MODE];
/* Check that all the TS_* structures handled by the streamer_write_* and
streamer_read_* routines are exactly ALL the structures defined in
diff --git a/gcc/tree-streamer.h b/gcc/tree-streamer.h
index 170d61cf20b..51a292c8d80 100644
--- a/gcc/tree-streamer.h
+++ b/gcc/tree-streamer.h
@@ -75,7 +75,7 @@ void streamer_write_tree_body (struct output_block *, tree);
void streamer_write_integer_cst (struct output_block *, tree);
/* In tree-streamer.cc. */
-extern unsigned char streamer_mode_table[1 << 8];
+extern unsigned char streamer_mode_table[MAX_MACHINE_MODE];
void streamer_check_handled_ts_structures (void);
bool streamer_tree_cache_insert (struct streamer_tree_cache_d *, tree,
hashval_t, unsigned *);
next reply other threads:[~2023-06-22 11:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 11:36 Jivan Hakobyan [this message]
2023-06-22 11:42 ` Robin Dapp
2023-06-22 12:36 ` Jivan Hakobyan
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=CAHso6sMRM9YmzmpuHTeMNAd1e2PKXkCkkkdnM1-M34YqGZ8b2w@mail.gmail.com \
--to=jivanhakobyan9@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jlaw@ventanamicro.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).