All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: "Ian Jackson" <ian.jackson@eu.citrix.com>,
	"Tim Deegan" <tim@xen.org>, "Wei Liu" <wei.liu2@citrix.com>,
	"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH 7/7] tools/kdd: mute spurious gcc warning
Date: Fri, 6 Apr 2018 14:41:18 +0100	[thread overview]
Message-ID: <20180406134117.cnw6taklnojynfn3@citrix.com> (raw)
In-Reply-To: <dc5d9a85-ab9c-2cdb-9319-1284158e4596@oracle.com>

On Fri, Apr 06, 2018 at 09:39:50AM -0400, Boris Ostrovsky wrote:
> On 04/06/2018 09:07 AM, Wei Liu wrote:
> > On Fri, Apr 06, 2018 at 08:39:53AM -0400, Boris Ostrovsky wrote:
> >> On 04/04/2018 09:50 PM, Marek Marczykowski-Górecki wrote:
> >>> gcc-8 complains:
> >>>
> >>>     kdd.c:698:13: error: 'memcpy' offset [-204, -717] is out of the bounds [0, 216] of object 'ctrl' with type 'kdd_ctrl' {aka 'union <anonymous>'} [-Werror=array-bounds]
> >>>                  memcpy(buf, ((uint8_t *)&ctrl.c32) + offset, len);
> >>>                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >>>     kdd.c: In function 'kdd_select_callback':
> >>>     kdd.c:642:14: note: 'ctrl' declared here
> >>>          kdd_ctrl ctrl;
> >>>                   ^~~~
> >>>
> >>> But this is impossible - 'offset' is unsigned and correctly validated
> >>> few lines before.
> >>>
> >>> Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> >>> ---
> >>>  tools/debugger/kdd/kdd.c | 3 +++
> >>>  1 file changed, 3 insertions(+)
> >>>
> >>> diff --git a/tools/debugger/kdd/kdd.c b/tools/debugger/kdd/kdd.c
> >>> index 1bd5dd5..61d769e 100644
> >>> --- a/tools/debugger/kdd/kdd.c
> >>> +++ b/tools/debugger/kdd/kdd.c
> >>> @@ -695,7 +695,10 @@ static void kdd_handle_read_ctrl(kdd_state *s)
> >>>              KDD_LOG(s, "Request outside of known control space\n");
> >>>              len = 0;
> >>>          } else {
> >>> +#pragma GCC diagnostic push
> >>> +#pragma GCC diagnostic ignored "-Warray-bounds"
> >>>              memcpy(buf, ((uint8_t *)&ctrl.c32) + offset, len);
> >>> +#pragma GCC diagnostic pop
> >>>          }
> >>>      }
> >>>  
> >>
> >> Breaks 32-bit build, at least with my (ancient, gcc version 4.4.5
> >> 20101112 (Red Hat 4.4.5-2) (GCC)) compiler:
> >>
> >>
> >>
> >> kdd.c: In function ‘kdd_handle_read_ctrl’:
> >> kdd.c:698: error: #pragma GCC diagnostic not allowed inside functions
> >> kdd.c:699: error: #pragma GCC diagnostic not allowed inside functions
> >> kdd.c:701: error: #pragma GCC diagnostic not allowed inside functions
> >> make[5]: *** [kdd.o] Error 1
> >>
> > Does moving the relevant #pragma's outside of the function fix it?
> 
> The additional problem with these pragmas is that apparently push/pop
> have been introduced in gcc 4.6.0:
> 
> https://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
> 
> If you change release number to a lower one (e.g. 4.5.4) you won't see them.
> 
> So I can move "diagnostic ignored" from inside the function and that
> will clear the "GCC diagnostic not allowed inside functions" error. But
> then push/pop are not recognized:
> 
> cc1: warnings being treated as errors
> kdd.c:639: error: expected [error|warning|ignored] after ‘#pragma GCC
> diagnostic’
> kdd.c:714: error: expected [error|warning|ignored] after ‘#pragma GCC
> diagnostic’
> 
> (Interestingly, my 64-bit build completed without issues)

Hmm... this is messy.

If you have information about which version does what we can try to
enclose the #pragma's with #if __GCC__.

Wei.

> 
> -boris

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2018-04-06 13:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-05  1:50 [PATCH 0/7] Fix warnings found by gcc 8 Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 1/7] tools/libxc: fix strncpy size Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 2/7] tools/misc: fix hypothetical buffer overflow in xen-lowmemd Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 3/7] tools/blktap2: fix hypothetical buffer overflow Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 4/7] tools/blktap2: fix possible '\0' truncation Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 5/7] tools/xenpmd: " Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 6/7] tools/gdbsx: fix -Wstringop-truncation warning Marek Marczykowski-Górecki
2018-04-05  1:50 ` [PATCH 7/7] tools/kdd: mute spurious gcc warning Marek Marczykowski-Górecki
2018-04-06 12:39   ` Boris Ostrovsky
2018-04-06 13:07     ` Wei Liu
2018-04-06 13:39       ` Boris Ostrovsky
2018-04-06 13:41         ` Wei Liu [this message]
2018-04-06 13:56           ` Boris Ostrovsky
2018-04-06 14:32             ` Marek Marczykowski-Górecki
2018-04-06 15:12               ` Wei Liu
2018-04-06 15:32                 ` [PATCH] tools/kdd: use mute -Warray-bounds only on new gcc version Marek Marczykowski-Górecki
2018-04-06 17:12                   ` Wei Liu
2018-04-06 22:39                     ` Marek Marczykowski-Górecki
2018-04-07  7:36                       ` Tim Deegan
2018-04-06 17:03               ` [PATCH 7/7] tools/kdd: mute spurious gcc warning Tim Deegan
2018-04-05  9:03 ` [PATCH 0/7] Fix warnings found by gcc 8 Wei Liu
2018-04-05 12:49   ` Juergen Gross

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=20180406134117.cnw6taklnojynfn3@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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 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.