kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] vxlan: keep flags and vni in network byte order
@ 2016-11-11 12:49 Dan Carpenter
  2016-11-11 13:05 ` Jiri Benc
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-11-11 12:49 UTC (permalink / raw)
  To: kernel-janitors

Hello Jiri Benc,

The patch 54bfd872bf16: "vxlan: keep flags and vni in network byte
order" from Feb 16, 2016, leads to the following static checker
warning:

	./include/net/vxlan.h:340 vxlan_vni()
	warn: potential shift truncation.  '0xffffff00 << 8'

include/net/vxlan.h
   335  static inline __be32 vxlan_vni(__be32 vni_field)
   336  {
   337  #if defined(__BIG_ENDIAN)
   338          return (__force __be32)((__force u32)vni_field >> 8);
   339  #else
   340          return (__force __be32)((__force u32)(vni_field & VXLAN_VNI_MASK) << 8);

Are you sure this is correct?  VXLAN_VNI_MASK already has an << 8 shift
so this feels like maybe it is a double shift.

   341  #endif
   342  }

regards,
dan carpenter

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

* Re: [bug report] vxlan: keep flags and vni in network byte order
  2016-11-11 12:49 [bug report] vxlan: keep flags and vni in network byte order Dan Carpenter
@ 2016-11-11 13:05 ` Jiri Benc
  2016-11-11 13:12 ` Jiri Benc
  2016-11-11 13:27 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Benc @ 2016-11-11 13:05 UTC (permalink / raw)
  To: kernel-janitors

On Fri, 11 Nov 2016 15:49:41 +0300, Dan Carpenter wrote:
> Hello Jiri Benc,
> 
> The patch 54bfd872bf16: "vxlan: keep flags and vni in network byte
> order" from Feb 16, 2016, leads to the following static checker
> warning:
> 
> 	./include/net/vxlan.h:340 vxlan_vni()
> 	warn: potential shift truncation.  '0xffffff00 << 8'
> 
> include/net/vxlan.h
>    335  static inline __be32 vxlan_vni(__be32 vni_field)
>    336  {
>    337  #if defined(__BIG_ENDIAN)
>    338          return (__force __be32)((__force u32)vni_field >> 8);
>    339  #else
>    340          return (__force __be32)((__force u32)(vni_field & VXLAN_VNI_MASK) << 8);
> 
> Are you sure this is correct?  VXLAN_VNI_MASK already has an << 8 shift
> so this feels like maybe it is a double shift.

The static checker clearly can't understand endian conversion macros.
VXLAN_VNI_MASK is:

cpu_to_be32(VXLAN_VID_MASK << 8)

Thus on little endian, it becomes 0x00ffffff.

 Jiri

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

* Re: [bug report] vxlan: keep flags and vni in network byte order
  2016-11-11 12:49 [bug report] vxlan: keep flags and vni in network byte order Dan Carpenter
  2016-11-11 13:05 ` Jiri Benc
@ 2016-11-11 13:12 ` Jiri Benc
  2016-11-11 13:27 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Benc @ 2016-11-11 13:12 UTC (permalink / raw)
  To: kernel-janitors

On Fri, 11 Nov 2016 14:05:09 +0100, Jiri Benc wrote:
> The static checker clearly can't understand endian conversion macros.
> VXLAN_VNI_MASK is:
> 
> cpu_to_be32(VXLAN_VID_MASK << 8)
> 
> Thus on little endian, it becomes 0x00ffffff.

Btw, until the unspecified static checker you used is not fixed to
resolve such macros correctly, it can't be really used to check the
kernel source, yet alone to generate bug reports. It will trip over
false positive in gazillion places.

 Jiri

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

* Re: [bug report] vxlan: keep flags and vni in network byte order
  2016-11-11 12:49 [bug report] vxlan: keep flags and vni in network byte order Dan Carpenter
  2016-11-11 13:05 ` Jiri Benc
  2016-11-11 13:12 ` Jiri Benc
@ 2016-11-11 13:27 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2016-11-11 13:27 UTC (permalink / raw)
  To: kernel-janitors

On Fri, Nov 11, 2016 at 02:12:03PM +0100, Jiri Benc wrote:
> On Fri, 11 Nov 2016 14:05:09 +0100, Jiri Benc wrote:
> > The static checker clearly can't understand endian conversion macros.
> > VXLAN_VNI_MASK is:
> > 
> > cpu_to_be32(VXLAN_VID_MASK << 8)
> > 
> > Thus on little endian, it becomes 0x00ffffff.

Ah right.

> 
> Btw, until the unspecified static checker you used is not fixed to
> resolve such macros correctly, it can't be really used to check the
> kernel source, yet alone to generate bug reports. It will trip over
> false positive in gazillion places.

Nope.  Just this one.

regards,
dan carpenter


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

end of thread, other threads:[~2016-11-11 13:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11 12:49 [bug report] vxlan: keep flags and vni in network byte order Dan Carpenter
2016-11-11 13:05 ` Jiri Benc
2016-11-11 13:12 ` Jiri Benc
2016-11-11 13:27 ` Dan Carpenter

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