* [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
@ 2015-02-16 15:21 Ilya Enkovich
2015-02-16 15:33 ` Jakub Jelinek
0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-02-16 15:21 UTC (permalink / raw)
To: gcc-patches
Hi,
This patch restricts usage of Pointer Bounds Checker with Sanitizer. OK for trunk?
Thanks,
Ilya
--
gcc/
2015-02-16 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/65044
* toplev.c (process_options): Restrict Pointer Bounds Checker
usage with sanitizers.
gcc/testsuite/
2015-02-16 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/65044
* gcc.target/i386/pr65044.c: New.
diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c
new file mode 100644
index 0000000..79ecb04
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65044.c
@@ -0,0 +1,12 @@
+/* { dg-error "-fcheck-pointer-bounds is not supported with sanitizers" } */
+/* { dg-do compile } */
+/* { dg-require-effective-target mpx } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
+
+extern int x[];
+
+void
+foo ()
+{
+ x[0] = 0;
+}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 99cf180..bf987c8 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1376,6 +1376,9 @@ process_options (void)
{
if (targetm.chkp_bound_mode () == VOIDmode)
error ("-fcheck-pointer-bounds is not supported for this target");
+
+ if (flag_sanitize)
+ error ("-fcheck-pointer-bounds is not supported with sanitizers");
}
/* One region RA really helps to decrease the code size. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-02-16 15:21 [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer Ilya Enkovich
@ 2015-02-16 15:33 ` Jakub Jelinek
2015-02-16 15:57 ` Ilya Enkovich
0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2015-02-16 15:33 UTC (permalink / raw)
To: Ilya Enkovich; +Cc: gcc-patches
On Mon, Feb 16, 2015 at 06:20:59PM +0300, Ilya Enkovich wrote:
> This patch restricts usage of Pointer Bounds Checker with Sanitizer. OK for trunk?
There are many sanitizers, and for most of them I don't see why they would
be in any conflict with -mmpx, it is just -fsanitize=address and
-fsanitize=kernel-address.
So perhaps test instead if (flag_sanitize & SANITIZE_ADDRESS) != 0, and
better clear the flag_pointer_bounds after issuing the error, error () is
not a fatal function, so you need something sensible for error-recovery.
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-02-16 15:33 ` Jakub Jelinek
@ 2015-02-16 15:57 ` Ilya Enkovich
2015-02-16 16:01 ` Jakub Jelinek
0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-02-16 15:57 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 16 Feb 16:31, Jakub Jelinek wrote:
> On Mon, Feb 16, 2015 at 06:20:59PM +0300, Ilya Enkovich wrote:
> > This patch restricts usage of Pointer Bounds Checker with Sanitizer. OK for trunk?
>
> There are many sanitizers, and for most of them I don't see why they would
> be in any conflict with -mmpx, it is just -fsanitize=address and
> -fsanitize=kernel-address.
> So perhaps test instead if (flag_sanitize & SANITIZE_ADDRESS) != 0, and
> better clear the flag_pointer_bounds after issuing the error, error () is
> not a fatal function, so you need something sensible for error-recovery.
>
> Jakub
I don't know all sanitizers in details. Code generated by some of them may be incorrect from checker point of view. Thus I just wanted to disable unexplored and untested combinations.
Ilya
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-02-16 15:57 ` Ilya Enkovich
@ 2015-02-16 16:01 ` Jakub Jelinek
2015-02-16 17:15 ` Ilya Enkovich
0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2015-02-16 16:01 UTC (permalink / raw)
To: Ilya Enkovich; +Cc: gcc-patches
On Mon, Feb 16, 2015 at 06:56:45PM +0300, Ilya Enkovich wrote:
> On 16 Feb 16:31, Jakub Jelinek wrote:
> > On Mon, Feb 16, 2015 at 06:20:59PM +0300, Ilya Enkovich wrote:
> > > This patch restricts usage of Pointer Bounds Checker with Sanitizer. OK for trunk?
> >
> > There are many sanitizers, and for most of them I don't see why they would
> > be in any conflict with -mmpx, it is just -fsanitize=address and
> > -fsanitize=kernel-address.
> > So perhaps test instead if (flag_sanitize & SANITIZE_ADDRESS) != 0, and
> > better clear the flag_pointer_bounds after issuing the error, error () is
> > not a fatal function, so you need something sensible for error-recovery.
> >
> > Jakub
>
> I don't know all sanitizers in details. Code generated by some of them may be incorrect from checker point of view. Thus I just wanted to disable unexplored and untested combinations.
Shouldn't be that hard to write a testcase and test it.
Most of the sanitizers just add code like
if (some_condition)
__ubsan_handle_... ();
where from the POV of the program the __ubsan_* function reports or might
report some problem, and optionally abort the program.
That some_condition can be a check of the pointer value, shift count,
divisor check, etc.
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-02-16 16:01 ` Jakub Jelinek
@ 2015-02-16 17:15 ` Ilya Enkovich
2015-03-02 10:25 ` Ilya Enkovich
0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-02-16 17:15 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 16 Feb 17:01, Jakub Jelinek wrote:
> On Mon, Feb 16, 2015 at 06:56:45PM +0300, Ilya Enkovich wrote:
> > On 16 Feb 16:31, Jakub Jelinek wrote:
> > > On Mon, Feb 16, 2015 at 06:20:59PM +0300, Ilya Enkovich wrote:
> > > > This patch restricts usage of Pointer Bounds Checker with Sanitizer. OK for trunk?
> > >
> > > There are many sanitizers, and for most of them I don't see why they would
> > > be in any conflict with -mmpx, it is just -fsanitize=address and
> > > -fsanitize=kernel-address.
> > > So perhaps test instead if (flag_sanitize & SANITIZE_ADDRESS) != 0, and
> > > better clear the flag_pointer_bounds after issuing the error, error () is
> > > not a fatal function, so you need something sensible for error-recovery.
> > >
> > > Jakub
> >
> > I don't know all sanitizers in details. Code generated by some of them may be incorrect from checker point of view. Thus I just wanted to disable unexplored and untested combinations.
>
> Shouldn't be that hard to write a testcase and test it.
>
> Most of the sanitizers just add code like
> if (some_condition)
> __ubsan_handle_... ();
> where from the POV of the program the __ubsan_* function reports or might
> report some problem, and optionally abort the program.
> That some_condition can be a check of the pointer value, shift count,
> divisor check, etc.
>
> Jakub
OK. With no tricky memory references this should be safe. Here is a patch to filter off Adress Sanitizer only.
Thanks for review!
Ilya
--
gcc/
2015-02-16 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/65044
* toplev.c (process_options): Restrict Pointer Bounds Checker
usage with Address Sanitizer.
gcc/testsuite/
2015-02-16 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/65044
* gcc.target/i386/pr65044.c: New.
diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c
new file mode 100644
index 0000000..4f318d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65044.c
@@ -0,0 +1,12 @@
+/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" } */
+/* { dg-do compile } */
+/* { dg-require-effective-target mpx } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
+
+extern int x[];
+
+void
+foo ()
+{
+ x[0] = 0;
+}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 99cf180..70eb6b6 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1376,6 +1376,11 @@ process_options (void)
{
if (targetm.chkp_bound_mode () == VOIDmode)
error ("-fcheck-pointer-bounds is not supported for this target");
+
+ if (flag_sanitize & SANITIZE_ADDRESS)
+ error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
+
+ flag_check_pointer_bounds = 0;
}
/* One region RA really helps to decrease the code size. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-02-16 17:15 ` Ilya Enkovich
@ 2015-03-02 10:25 ` Ilya Enkovich
2015-03-09 14:51 ` Jakub Jelinek
0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-03-02 10:25 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
Ping
2015-02-16 20:15 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> On 16 Feb 17:01, Jakub Jelinek wrote:
>> On Mon, Feb 16, 2015 at 06:56:45PM +0300, Ilya Enkovich wrote:
>> > On 16 Feb 16:31, Jakub Jelinek wrote:
>> > > On Mon, Feb 16, 2015 at 06:20:59PM +0300, Ilya Enkovich wrote:
>> > > > This patch restricts usage of Pointer Bounds Checker with Sanitizer. OK for trunk?
>> > >
>> > > There are many sanitizers, and for most of them I don't see why they would
>> > > be in any conflict with -mmpx, it is just -fsanitize=address and
>> > > -fsanitize=kernel-address.
>> > > So perhaps test instead if (flag_sanitize & SANITIZE_ADDRESS) != 0, and
>> > > better clear the flag_pointer_bounds after issuing the error, error () is
>> > > not a fatal function, so you need something sensible for error-recovery.
>> > >
>> > > Jakub
>> >
>> > I don't know all sanitizers in details. Code generated by some of them may be incorrect from checker point of view. Thus I just wanted to disable unexplored and untested combinations.
>>
>> Shouldn't be that hard to write a testcase and test it.
>>
>> Most of the sanitizers just add code like
>> if (some_condition)
>> __ubsan_handle_... ();
>> where from the POV of the program the __ubsan_* function reports or might
>> report some problem, and optionally abort the program.
>> That some_condition can be a check of the pointer value, shift count,
>> divisor check, etc.
>>
>> Jakub
>
> OK. With no tricky memory references this should be safe. Here is a patch to filter off Adress Sanitizer only.
>
> Thanks for review!
>
> Ilya
> --
> gcc/
>
> 2015-02-16 Ilya Enkovich <ilya.enkovich@intel.com>
>
> PR target/65044
> * toplev.c (process_options): Restrict Pointer Bounds Checker
> usage with Address Sanitizer.
>
> gcc/testsuite/
>
> 2015-02-16 Ilya Enkovich <ilya.enkovich@intel.com>
>
> PR target/65044
> * gcc.target/i386/pr65044.c: New.
>
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c
> new file mode 100644
> index 0000000..4f318d6
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr65044.c
> @@ -0,0 +1,12 @@
> +/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" } */
> +/* { dg-do compile } */
> +/* { dg-require-effective-target mpx } */
> +/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
> +
> +extern int x[];
> +
> +void
> +foo ()
> +{
> + x[0] = 0;
> +}
> diff --git a/gcc/toplev.c b/gcc/toplev.c
> index 99cf180..70eb6b6 100644
> --- a/gcc/toplev.c
> +++ b/gcc/toplev.c
> @@ -1376,6 +1376,11 @@ process_options (void)
> {
> if (targetm.chkp_bound_mode () == VOIDmode)
> error ("-fcheck-pointer-bounds is not supported for this target");
> +
> + if (flag_sanitize & SANITIZE_ADDRESS)
> + error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
> +
> + flag_check_pointer_bounds = 0;
> }
>
> /* One region RA really helps to decrease the code size. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-03-02 10:25 ` Ilya Enkovich
@ 2015-03-09 14:51 ` Jakub Jelinek
2015-03-12 11:28 ` Ilya Enkovich
0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2015-03-09 14:51 UTC (permalink / raw)
To: Ilya Enkovich; +Cc: gcc-patches
On Mon, Mar 02, 2015 at 01:25:43PM +0300, Ilya Enkovich wrote:
> > --- a/gcc/toplev.c
> > +++ b/gcc/toplev.c
> > @@ -1376,6 +1376,11 @@ process_options (void)
> > {
> > if (targetm.chkp_bound_mode () == VOIDmode)
> > error ("-fcheck-pointer-bounds is not supported for this target");
> > +
> > + if (flag_sanitize & SANITIZE_ADDRESS)
> > + error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
> > +
> > + flag_check_pointer_bounds = 0;
> > }
Doesn't this disable -fcheck-pointer-bounds always?
I'd expect you want to clear flag_check_pointer_bounds only if you issued
one of the two errors...
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-03-09 14:51 ` Jakub Jelinek
@ 2015-03-12 11:28 ` Ilya Enkovich
2015-03-12 11:56 ` Jakub Jelinek
0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-03-12 11:28 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On 09 Mar 15:51, Jakub Jelinek wrote:
> On Mon, Mar 02, 2015 at 01:25:43PM +0300, Ilya Enkovich wrote:
> > > --- a/gcc/toplev.c
> > > +++ b/gcc/toplev.c
> > > @@ -1376,6 +1376,11 @@ process_options (void)
> > > {
> > > if (targetm.chkp_bound_mode () == VOIDmode)
> > > error ("-fcheck-pointer-bounds is not supported for this target");
> > > +
> > > + if (flag_sanitize & SANITIZE_ADDRESS)
> > > + error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
> > > +
> > > + flag_check_pointer_bounds = 0;
> > > }
>
> Doesn't this disable -fcheck-pointer-bounds always?
> I'd expect you want to clear flag_check_pointer_bounds only if you issued
> one of the two errors...
>
> Jakub
Whoops! Here is a less destructive version.
Thanks,
Ilya
--
gcc/
2015-03-11 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/65044
* toplev.c (process_options): Restrict Pointer Bounds Checker
usage with Address Sanitizer.
gcc/testsuite/
2015-03-11 Ilya Enkovich <ilya.enkovich@intel.com>
PR target/65044
* gcc.target/i386/pr65044.c: New.
diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c
new file mode 100644
index 0000000..4f318d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr65044.c
@@ -0,0 +1,12 @@
+/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" } */
+/* { dg-do compile } */
+/* { dg-require-effective-target mpx } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
+
+extern int x[];
+
+void
+foo ()
+{
+ x[0] = 0;
+}
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 99cf180..b06eed3 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1375,7 +1375,17 @@ process_options (void)
if (flag_check_pointer_bounds)
{
if (targetm.chkp_bound_mode () == VOIDmode)
- error ("-fcheck-pointer-bounds is not supported for this target");
+ {
+ error ("-fcheck-pointer-bounds is not supported for this target");
+ flag_check_pointer_bounds = 0;
+ }
+
+ if (flag_sanitize & SANITIZE_ADDRESS)
+ {
+ error ("-fcheck-pointer-bounds is not supported with "
+ "Address Sanitizer");
+ flag_check_pointer_bounds = 0;
+ }
}
/* One region RA really helps to decrease the code size. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-03-12 11:28 ` Ilya Enkovich
@ 2015-03-12 11:56 ` Jakub Jelinek
2015-03-12 11:16 ` Ilya Enkovich
0 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2015-03-12 11:56 UTC (permalink / raw)
To: Ilya Enkovich; +Cc: gcc-patches
On Thu, Mar 12, 2015 at 11:51:51AM +0300, Ilya Enkovich wrote:
> On 09 Mar 15:51, Jakub Jelinek wrote:
> > On Mon, Mar 02, 2015 at 01:25:43PM +0300, Ilya Enkovich wrote:
> > > > --- a/gcc/toplev.c
> > > > +++ b/gcc/toplev.c
> > > > @@ -1376,6 +1376,11 @@ process_options (void)
> > > > {
> > > > if (targetm.chkp_bound_mode () == VOIDmode)
> > > > error ("-fcheck-pointer-bounds is not supported for this target");
> > > > +
> > > > + if (flag_sanitize & SANITIZE_ADDRESS)
> > > > + error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
> > > > +
> > > > + flag_check_pointer_bounds = 0;
> > > > }
> >
> > Doesn't this disable -fcheck-pointer-bounds always?
> > I'd expect you want to clear flag_check_pointer_bounds only if you issued
> > one of the two errors...
> >
> > Jakub
>
> Whoops! Here is a less destructive version.
Ok for trunk. Did the old version pass make check? If so, perhaps you want to add
(incrementally) some test that would actually verify that
-fcheck-pointer-bounds does what it should do (e.g. by scanning tree dumps
etc.).
Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer
2015-03-12 11:56 ` Jakub Jelinek
@ 2015-03-12 11:16 ` Ilya Enkovich
0 siblings, 0 replies; 10+ messages in thread
From: Ilya Enkovich @ 2015-03-12 11:16 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
2015-03-12 12:02 GMT+03:00 Jakub Jelinek <jakub@redhat.com>:
> On Thu, Mar 12, 2015 at 11:51:51AM +0300, Ilya Enkovich wrote:
>> On 09 Mar 15:51, Jakub Jelinek wrote:
>> > On Mon, Mar 02, 2015 at 01:25:43PM +0300, Ilya Enkovich wrote:
>> > > > --- a/gcc/toplev.c
>> > > > +++ b/gcc/toplev.c
>> > > > @@ -1376,6 +1376,11 @@ process_options (void)
>> > > > {
>> > > > if (targetm.chkp_bound_mode () == VOIDmode)
>> > > > error ("-fcheck-pointer-bounds is not supported for this target");
>> > > > +
>> > > > + if (flag_sanitize & SANITIZE_ADDRESS)
>> > > > + error ("-fcheck-pointer-bounds is not supported with Address Sanitizer");
>> > > > +
>> > > > + flag_check_pointer_bounds = 0;
>> > > > }
>> >
>> > Doesn't this disable -fcheck-pointer-bounds always?
>> > I'd expect you want to clear flag_check_pointer_bounds only if you issued
>> > one of the two errors...
>> >
>> > Jakub
>>
>> Whoops! Here is a less destructive version.
>
> Ok for trunk. Did the old version pass make check? If so, perhaps you want to add
> (incrementally) some test that would actually verify that
> -fcheck-pointer-bounds does what it should do (e.g. by scanning tree dumps
> etc.).
Thanks! I sent previous version before make check. There are several
chkp tests which would fail.
Ilya
>
> Jakub
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-03-12 11:56 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-16 15:21 [PATCH, CHKP, PR target/65044] Restrict pointer bounds checker with Sanitizer Ilya Enkovich
2015-02-16 15:33 ` Jakub Jelinek
2015-02-16 15:57 ` Ilya Enkovich
2015-02-16 16:01 ` Jakub Jelinek
2015-02-16 17:15 ` Ilya Enkovich
2015-03-02 10:25 ` Ilya Enkovich
2015-03-09 14:51 ` Jakub Jelinek
2015-03-12 11:28 ` Ilya Enkovich
2015-03-12 11:56 ` Jakub Jelinek
2015-03-12 11:16 ` Ilya Enkovich
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).