netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ipv6 sit: work around bogus gcc-8 -Wrestrict warning
@ 2018-02-22 15:55 Arnd Bergmann
  2018-02-22 16:40 ` Eric Dumazet
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-02-22 15:55 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: Arnd Bergmann, stable, Martin Sebor, David Ahern,
	Matthias Schiffer, Nicolas Dichtel, WANG Cong, Eric Dumazet,
	Craig Gallek, netdev, linux-kernel

gcc-8 has a new warning that detects overlapping input and output arguments
in memcpy(). It triggers for sit_init_net() calling ipip6_tunnel_clone_6rd(),
which is actually correct:

net/ipv6/sit.c: In function 'sit_init_net':
net/ipv6/sit.c:192:3: error: 'memcpy' source argument is the same as destination [-Werror=restrict]

The problem here is that the logic detecting the memcpy() arguments finds them
to be the same, but the conditional that tests for the input and output of
ipip6_tunnel_clone_6rd() to be identical is not a compile-time constant.

We know that netdev_priv(t->dev) is the same as t for a tunnel device,
and comparing "dev" directly here lets the compiler figure out as well
that 'dev == sitn->fb_tunnel_dev' when called from sit_init_net(), so
it no longer warns.

This code is old, so Cc stable to make sure that we don't get the warning
for older kernels built with new gcc.

Cc: stable@vger.kernel.org
Cc: Martin Sebor <msebor@gmail.com>
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83456
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/ipv6/sit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 3873d3877135..3a1775a62973 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -182,7 +182,7 @@ static void ipip6_tunnel_clone_6rd(struct net_device *dev, struct sit_net *sitn)
 #ifdef CONFIG_IPV6_SIT_6RD
 	struct ip_tunnel *t = netdev_priv(dev);
 
-	if (t->dev == sitn->fb_tunnel_dev) {
+	if (dev == sitn->fb_tunnel_dev) {
 		ipv6_addr_set(&t->ip6rd.prefix, htonl(0x20020000), 0, 0, 0);
 		t->ip6rd.relay_prefix = 0;
 		t->ip6rd.prefixlen = 16;
-- 
2.9.0

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

* Re: [PATCH] ipv6 sit: work around bogus gcc-8 -Wrestrict warning
  2018-02-22 15:55 [PATCH] ipv6 sit: work around bogus gcc-8 -Wrestrict warning Arnd Bergmann
@ 2018-02-22 16:40 ` Eric Dumazet
  2018-02-22 16:56   ` Arnd Bergmann
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2018-02-22 16:40 UTC (permalink / raw)
  To: Arnd Bergmann, David S. Miller; +Cc: netdev, linux-kernel

On Thu, 2018-02-22 at 16:55 +0100, Arnd Bergmann wrote:

... 
> 
> This code is old, so Cc stable to make sure that we don't get the warning
> for older kernels built with new gcc.
> 
> Cc: stable@vger.kernel.org


This part makes little sense to me for two reasons.

1) David Miller handles stable submission himself
 ( Documentation/networking/netdev-FAQ.txt )

2) We are not supposed to make sure old kernels will compile with
future compilers.

That would need a lot of work and potential new bugs, not worth the
time.

Otherwise your patch looks fine really ;)

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

* Re: [PATCH] ipv6 sit: work around bogus gcc-8 -Wrestrict warning
  2018-02-22 16:40 ` Eric Dumazet
@ 2018-02-22 16:56   ` Arnd Bergmann
  2018-02-23 16:00     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2018-02-22 16:56 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: David S. Miller, Networking, Linux Kernel Mailing List

On Thu, Feb 22, 2018 at 5:40 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> On Thu, 2018-02-22 at 16:55 +0100, Arnd Bergmann wrote:
>
> ...
>>
>> This code is old, so Cc stable to make sure that we don't get the warning
>> for older kernels built with new gcc.
>>
>> Cc: stable@vger.kernel.org
>
>
> This part makes little sense to me for two reasons.
>
> 1) David Miller handles stable submission himself
>  ( Documentation/networking/netdev-FAQ.txt )

Right, sorry I keep forgetting this.

> 2) We are not supposed to make sure old kernels will compile with
> future compilers.
>
> That would need a lot of work and potential new bugs, not worth the
> time.

I did spent a some time backporting the gcc-7 fixes to stable kernels
already.

The 4.4 and 4.9 releases did not build cleanly with gcc-7 originally
but now they do, which is useful since Greg actually uses that
compiler for test building them.

I expect to do the same for gcc-8. Most of the fixes are trivial
anyway, and some of them fix actual bugs that would otherwise
get missed.

      Arnd

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

* Re: [PATCH] ipv6 sit: work around bogus gcc-8 -Wrestrict warning
  2018-02-22 16:56   ` Arnd Bergmann
@ 2018-02-23 16:00     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2018-02-23 16:00 UTC (permalink / raw)
  To: arnd; +Cc: eric.dumazet, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Thu, 22 Feb 2018 17:56:12 +0100

> I expect to do the same for gcc-8. Most of the fixes are trivial
> anyway, and some of them fix actual bugs that would otherwise get
> missed.

It does make the code easier to understand and you can more directly
see what it's trying to check.

Applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2018-02-23 16:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-22 15:55 [PATCH] ipv6 sit: work around bogus gcc-8 -Wrestrict warning Arnd Bergmann
2018-02-22 16:40 ` Eric Dumazet
2018-02-22 16:56   ` Arnd Bergmann
2018-02-23 16:00     ` David Miller

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 NNTP newsgroup(s).