public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c
@ 2012-11-26 21:58 H.J. Lu
  2012-11-27  8:32 ` Markus Trippelsdorf
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2012-11-26 21:58 UTC (permalink / raw)
  To: gcc-patches

Hi,

OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and
OPT_SPECIAL_input_file are special options, which aren't in cl_options.
This patch avoids

if (!(cl_options[foption->opt_index].flags & CL_TARGET))

on them.  This patch skips them.  OK to install?

Thanks.


H.J.
---
2012-11-26  H.J. Lu  <hongjiu.lu@intel.com>

	PR lto/55474
	* lto-wrapper.c (merge_and_complain): Handle
	OPT_SPECIAL_unknown, OPT_SPECIAL_ignore,
	OPT_SPECIAL_program_name and OPT_SPECIAL_input_file.

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index 1f4d212..24de743 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -393,6 +393,12 @@ merge_and_complain (struct cl_decoded_option **decoded_options,
       struct cl_decoded_option *foption = &fdecoded_options[i];
       switch (foption->opt_index)
 	{
+	case OPT_SPECIAL_unknown:
+	case OPT_SPECIAL_ignore:
+	case OPT_SPECIAL_program_name:
+	case OPT_SPECIAL_input_file:
+	  break;
+
 	default:
 	  if (!(cl_options[foption->opt_index].flags & CL_TARGET))
 	    break;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c
  2012-11-26 21:58 PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c H.J. Lu
@ 2012-11-27  8:32 ` Markus Trippelsdorf
  2012-11-27 10:07   ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Markus Trippelsdorf @ 2012-11-27  8:32 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches

On 2012.11.26 at 13:58 -0800, H.J. Lu wrote:
> Hi,
> 
> OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and
> OPT_SPECIAL_input_file are special options, which aren't in cl_options.
> This patch avoids
> 
> if (!(cl_options[foption->opt_index].flags & CL_TARGET))
> 
> on them.  This patch skips them.  OK to install?

The same fix is necessary for gcc/lto-opts.c.
This solves the issue from PR54795 comment 5, 13 and 20.

2012-11-27  Markus Trippelsdorf  <markus@trippelsdorf.de>

	PR lto/54795
	* lto-opts.c (lto_write_options): Also handle
	OPT_SPECIAL_unknown, OPT_SPECIAL_ignore and
	OPT_SPECIAL_program_name.


diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
index a235f41..a61a26f 100644
--- a/gcc/lto-opts.c
+++ b/gcc/lto-opts.c
@@ -93,6 +93,20 @@ lto_write_options (void)
     {
       struct cl_decoded_option *option = &save_decoded_options[i];
 
+      /* Skip explicitly some common options that we do not need.  */
+      switch (option->opt_index)
+      {
+	case OPT_dumpbase:
+	case OPT_SPECIAL_unknown:
+	case OPT_SPECIAL_ignore:
+	case OPT_SPECIAL_program_name:
+	case OPT_SPECIAL_input_file:
+	  continue;
+
+	default:
+	  break;
+      }
+
       /* Skip frontend and driver specific options here.  */
       if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO)))
 	continue;
@@ -108,17 +122,6 @@ lto_write_options (void)
       if (cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING))
 	continue;
 
-      /* Skip explicitly some common options that we do not need.  */
-      switch (option->opt_index)
-	{
-	case OPT_dumpbase:
-	case OPT_SPECIAL_input_file:
-	  continue;
-
-	default:
-	  break;
-	}
-
       for (j = 0; j < option->canonical_option_num_elements; ++j)
 	append_to_collect_gcc_options (&temporary_obstack, &first_p,
 				       option->canonical_option[j]);
-- 
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c
  2012-11-27  8:32 ` Markus Trippelsdorf
@ 2012-11-27 10:07   ` Richard Biener
  2012-11-27 21:20     ` H.J. Lu
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2012-11-27 10:07 UTC (permalink / raw)
  To: Markus Trippelsdorf; +Cc: H.J. Lu, gcc-patches

On Tue, Nov 27, 2012 at 9:32 AM, Markus Trippelsdorf
<markus@trippelsdorf.de> wrote:
> On 2012.11.26 at 13:58 -0800, H.J. Lu wrote:
>> Hi,
>>
>> OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and
>> OPT_SPECIAL_input_file are special options, which aren't in cl_options.
>> This patch avoids
>>
>> if (!(cl_options[foption->opt_index].flags & CL_TARGET))
>>
>> on them.  This patch skips them.  OK to install?
>
> The same fix is necessary for gcc/lto-opts.c.
> This solves the issue from PR54795 comment 5, 13 and 20.

Ok for both patches.

Thanks,
Richard.

> 2012-11-27  Markus Trippelsdorf  <markus@trippelsdorf.de>
>
>         PR lto/54795
>         * lto-opts.c (lto_write_options): Also handle
>         OPT_SPECIAL_unknown, OPT_SPECIAL_ignore and
>         OPT_SPECIAL_program_name.
>
>
> diff --git a/gcc/lto-opts.c b/gcc/lto-opts.c
> index a235f41..a61a26f 100644
> --- a/gcc/lto-opts.c
> +++ b/gcc/lto-opts.c
> @@ -93,6 +93,20 @@ lto_write_options (void)
>      {
>        struct cl_decoded_option *option = &save_decoded_options[i];
>
> +      /* Skip explicitly some common options that we do not need.  */
> +      switch (option->opt_index)
> +      {
> +       case OPT_dumpbase:
> +       case OPT_SPECIAL_unknown:
> +       case OPT_SPECIAL_ignore:
> +       case OPT_SPECIAL_program_name:
> +       case OPT_SPECIAL_input_file:
> +         continue;
> +
> +       default:
> +         break;
> +      }
> +
>        /* Skip frontend and driver specific options here.  */
>        if (!(cl_options[option->opt_index].flags & (CL_COMMON|CL_TARGET|CL_LTO)))
>         continue;
> @@ -108,17 +122,6 @@ lto_write_options (void)
>        if (cl_options[option->opt_index].flags & (CL_DRIVER|CL_WARNING))
>         continue;
>
> -      /* Skip explicitly some common options that we do not need.  */
> -      switch (option->opt_index)
> -       {
> -       case OPT_dumpbase:
> -       case OPT_SPECIAL_input_file:
> -         continue;
> -
> -       default:
> -         break;
> -       }
> -
>        for (j = 0; j < option->canonical_option_num_elements; ++j)
>         append_to_collect_gcc_options (&temporary_obstack, &first_p,
>                                        option->canonical_option[j]);
> --
> Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c
  2012-11-27 10:07   ` Richard Biener
@ 2012-11-27 21:20     ` H.J. Lu
  2012-11-28 10:23       ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: H.J. Lu @ 2012-11-27 21:20 UTC (permalink / raw)
  To: Richard Biener; +Cc: Markus Trippelsdorf, gcc-patches

On Tue, Nov 27, 2012 at 2:07 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Tue, Nov 27, 2012 at 9:32 AM, Markus Trippelsdorf
> <markus@trippelsdorf.de> wrote:
>> On 2012.11.26 at 13:58 -0800, H.J. Lu wrote:
>>> Hi,
>>>
>>> OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and
>>> OPT_SPECIAL_input_file are special options, which aren't in cl_options.
>>> This patch avoids
>>>
>>> if (!(cl_options[foption->opt_index].flags & CL_TARGET))
>>>
>>> on them.  This patch skips them.  OK to install?
>>
>> The same fix is necessary for gcc/lto-opts.c.
>> This solves the issue from PR54795 comment 5, 13 and 20.
>
> Ok for both patches.
>

Fixed on trunk. The same invalid memory access exists on 4.7 branch.
OK to backport to 4.7?

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c
  2012-11-27 21:20     ` H.J. Lu
@ 2012-11-28 10:23       ` Richard Biener
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2012-11-28 10:23 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Markus Trippelsdorf, gcc-patches

On Tue, Nov 27, 2012 at 10:19 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Nov 27, 2012 at 2:07 AM, Richard Biener
> <richard.guenther@gmail.com> wrote:
>> On Tue, Nov 27, 2012 at 9:32 AM, Markus Trippelsdorf
>> <markus@trippelsdorf.de> wrote:
>>> On 2012.11.26 at 13:58 -0800, H.J. Lu wrote:
>>>> Hi,
>>>>
>>>> OPT_SPECIAL_unknown, OPT_SPECIAL_ignore, OPT_SPECIAL_program_name and
>>>> OPT_SPECIAL_input_file are special options, which aren't in cl_options.
>>>> This patch avoids
>>>>
>>>> if (!(cl_options[foption->opt_index].flags & CL_TARGET))
>>>>
>>>> on them.  This patch skips them.  OK to install?
>>>
>>> The same fix is necessary for gcc/lto-opts.c.
>>> This solves the issue from PR54795 comment 5, 13 and 20.
>>
>> Ok for both patches.
>>
>
> Fixed on trunk. The same invalid memory access exists on 4.7 branch.
> OK to backport to 4.7?

Yes, of course.

Thanks,
Richard.

> Thanks.
>
> --
> H.J.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-11-28 10:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-26 21:58 PATCH: lto/55474: global-buffer-overflow in lto-wrapper.c H.J. Lu
2012-11-27  8:32 ` Markus Trippelsdorf
2012-11-27 10:07   ` Richard Biener
2012-11-27 21:20     ` H.J. Lu
2012-11-28 10:23       ` Richard Biener

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).