public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org>
To: "monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org"
	<monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	"arnd-r2nGTMty4D4@public.gmane.org"
	<arnd-r2nGTMty4D4@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org"
	<keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org"
	<parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	"Michal.Kalderon-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org"
	<Michal.Kalderon-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>,
	Bart Van Assche <Bart.VanAssche-Sjgp3cTcYWE@public.gmane.org>,
	"sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
	<sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
	"danielmicay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
	<danielmicay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org"
	<Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>,
	"hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
	<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org"
	<davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	"dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org"
	<dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"noaos-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org"
	<noaos-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH] infiniband: avoid overflow warning
Date: Mon, 31 Jul 2017 15:32:00 +0000	[thread overview]
Message-ID: <1501515117.2466.9.camel@wdc.com> (raw)
In-Reply-To: <CAK8P3a2AP7WSF2HUe_4nxsNFqCit_djKdd3_5ab6P1YgP7bvJQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

On Mon, 2017-07-31 at 09:30 +0200, Arnd Bergmann wrote:
> On Mon, Jul 31, 2017 at 9:08 AM, Moni Shoua <monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org> wrote:
> > On Mon, Jul 31, 2017 at 9:50 AM, Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org> wrote:
> > > --- a/include/rdma/ib_addr.h
> > > +++ b/include/rdma/ib_addr.h
> > > @@ -172,7 +172,8 @@ static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid)
> > >                                        (struct in6_addr *)gid);
> > >                 break;
> > >         case AF_INET6:
> > > -               memcpy(gid->raw, &((struct sockaddr_in6 *)addr)->sin6_addr, 16);
> > > +               *(struct in6_addr *)&gid->raw =
> > > +                       ((struct sockaddr_in6 *)addr)->sin6_addr;
> > >                 break;
> > >         default:
> > >                 return -EINVAL;
> > 
> > what happens if you replace 16 with sizeof(struct in6_addr)?
> 
> Same thing: the problem is that gcc already knows the size of the structure we
> pass in here, and it is in fact shorter.
> 
> I also tried changing the struct sockaddr pointer to a sockaddr_storage pointer,
> without success. Other approaches that do work are:
> 
> - mark addr_event() as "noinline" to prevent gcc from seeing the true
> size of the
>   inetaddr_event stack object in rdma_ip2gid(). I considered this a little ugly.
> 
> - change inetaddr_event to put a larger structure on the stack, using
>   sockaddr_storage or sockaddr_in6. This would be less efficient.
> 
> - define a union of sockaddr_in and sockaddr_in6, and use that as the argument
>   to rdma_ip2gid/rdma_gid2ip, and change all callers to use that union type.
>   This is probably the cleanest approach as it gets rid of a lot of questionable
>   type casts, but it's a relatively large patch and also slightly less
> efficient as we have
>   to zero more stack storage in some cases.

Hello Arnd,

So inetaddr_event() assigns AF_INET so .sin_family and gcc warns about code
that is only executed if .sin_family == AF_INET6? Since this warning is the
result of incorrect interprocedural analysis by gcc, shouldn't this be
reported as a bug to the gcc authors?

Thanks,

Bart.--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2017-07-31 15:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31  6:50 [PATCH] infiniband: avoid overflow warning Arnd Bergmann
     [not found] ` <20170731065016.2947796-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-07-31  7:08   ` Moni Shoua
     [not found]     ` <CAG9sBKNaFTAuf2gL9QLOCwvH-xAq7SXfaMZxNMFo7d=6cH3TkQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31  7:30       ` Arnd Bergmann
     [not found]         ` <CAK8P3a2AP7WSF2HUe_4nxsNFqCit_djKdd3_5ab6P1YgP7bvJQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31 15:32           ` Bart Van Assche [this message]
     [not found]             ` <1501515117.2466.9.camel-Sjgp3cTcYWE@public.gmane.org>
2017-07-31 16:04               ` Arnd Bergmann
     [not found]                 ` <CAK8P3a1r22C-Uxs93OSbS4_eRNhKUTv8xwc6wwGahE80whCjyA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31 16:17                   ` Bart Van Assche
     [not found]                     ` <1501517853.2466.12.camel-Sjgp3cTcYWE@public.gmane.org>
2017-07-31 19:19                       ` Arnd Bergmann
2017-07-31 19:35                         ` Daniel Micay
2017-07-31 20:58         ` Kees Cook
     [not found]           ` <CAGXu5jJ66RY05M=sYZeAMVPEtpneOKyBN2CSNsrewj4EREeu+g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31 21:10             ` Arnd Bergmann
     [not found]               ` <CAK8P3a045_-89OQk+qG7odJ2NeeObq6QaKXccsaC_jOJxfYbfQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31 21:18                 ` Kees Cook
     [not found]                   ` <CAGXu5j+EPe7csgFt5SnDoobQWkOGH5qaoSZ=QMHHoGFFsMV45Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31 21:37                     ` Daniel Micay
2017-07-31 21:52                     ` Arnd Bergmann
     [not found]                       ` <CAK8P3a3q9d1_WU9hknhy5wH8_f26S3EUr=U1fu5=YL+3TmhBEw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-07-31 22:06                         ` Kees Cook
2017-08-18 16:40   ` Doug Ledford

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=1501515117.2466.9.camel@wdc.com \
    --to=bart.vanassche-sjgp3ctcywe@public.gmane.org \
    --cc=Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
    --cc=Michal.Kalderon-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=danielmicay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=monis-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=noaos-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=parav-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox