Skip to contentSkip to conversation

cxgb4_next_header .match_val/.match_mask should be net-endian

endianness bug? Al Viro 3 participants 5 messages Aug 5, 2018 – Aug 6, 2018

Subsystems (3)
lore
Share & tools
lore

Al Viro

author
#0 lore raw

AFAICS, cxgb4_next_header() expects to find match_val/match_mask in
struct cxgb4_next_header stored as big-endian:

                        /* Found a possible candidate.  Find a key that
                         * matches the corresponding offset, value, and
                         * mask to jump to next header.
                         */
                        for (j = 0; j < cls->knode.sel->nkeys; j++) {
                                off = cls->knode.sel->keys[j].off;
                                val = cls->knode.sel->keys[j].val;
                                mask = cls->knode.sel->keys[j].mask;

                                if (next[i].match_off == off &&
                                    next[i].match_val == val &&
                                    next[i].match_mask == mask) {
                                        found = true;
                                        break;
                                }
                        }

Here ->keys[] is struct tc_u32_key and there mask and val are definitely __be32. match_val and match_mask are never changed after initialization and they are set to:

* .match_off = 8, .match_val = 0x600, .match_mask = 0xFF00

	meant to check for IPV4.Protocol == TCP, i.e. octet at offset 9 being 6
* .match_off = 8, .match_val = 0x1100, .match_mask = 0xFF00
	meant to check for IPV4.Protocol == UDP, i.e. octet at offset 9 being 0x11
* .match_off = 4, .match_val = 0x60000, .match_mask = 0xFF0000
	IPV6.NextHeader == TCP, i.e. octet at offset 6 being 6
* .match_off = 4, .match_val = 0x110000, .match_mask = 0xFF0000
	IPV6.NextHeader == UDP, i.e. octet at offset 6 being 0x11

On little-endian host those do yield the right values - e.g. 0x1100 is {0, 17, 0, 0}, etc. On big-endian, though, these will end up checking in IPv4 case the octet at offset 10 (i.e. upper 16 bits of checksum) and for IPv6
- the octet at offset 5 (i.e. the lower 8 bits of payload length).

Unless I'm misreading that code, it needs the following to do the right thing both on l-e and b-e. Comments?

---

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h +8 -8
index a4b99edcc339..ec226b1cebf4 100644
@@ -259,11 +259,11 @@ struct cxgb4_next_header {
  */
 static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = {
 	{ .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
-	  .match_off = 8, .match_val = 0x600, .match_mask = 0xFF00,
-	  .jump = cxgb4_tcp_fields },
+	  .match_off = 8, .match_val = htonl(6 << 16),
+	  .match_mask = htonl(0xff<<16), .jump = cxgb4_tcp_fields },
 	{ .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
-	  .match_off = 8, .match_val = 0x1100, .match_mask = 0xFF00,
-	  .jump = cxgb4_udp_fields },
+	  .match_off = 8, .match_val = htonl(17 << 16),
+	  .match_mask = htonl(0xff<<16), .jump = cxgb4_udp_fields },
 	{ .jump = NULL }
 };
 
@@ -272,11 +272,11 @@ static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = {
  */
 static const struct cxgb4_next_header cxgb4_ipv6_jumps[] = {
 	{ .offset = 0x28, .offoff = 0, .shift = 0, .mask = 0,
-	  .match_off = 4, .match_val = 0x60000, .match_mask = 0xFF0000,
-	  .jump = cxgb4_tcp_fields },
+	  .match_off = 4, .match_val = htonl(6 << 8),
+	  .match_mask = htonl(0xff << 8), .jump = cxgb4_tcp_fields },
 	{ .offset = 0x28, .offoff = 0, .shift = 0, .mask = 0,
-	  .match_off = 4, .match_val = 0x110000, .match_mask = 0xFF0000,
-	  .jump = cxgb4_udp_fields },
+	  .match_off = 4, .match_val = htonl(17 << 8),
+	  .match_mask = htonl(0xff << 8), .jump = cxgb4_udp_fields },
 	{ .jump = NULL }
 };
 
author
#1 lore raw
Quoted 7 lines · Al Viro

On little-endian host those do yield the right values - e.g. 0x1100 is {0, 17, 0, 0}, etc. On big-endian, though, these will end up checking in IPv4 case the octet at offset 10 (i.e. upper 16 bits of checksum) and for IPv6
- the octet at offset 5 (i.e. the lower 8 bits of payload length).

Unless I'm misreading that code, it needs the following to do the right thing both on l-e and b-e. Comments?

... and it looks like the same story with ->mask - it's compared to ->offmask, which is __be16. For little-endian hosts the values make sense (htons(0x0f00), with offoff 0 and shift 6, i.e. "take the first two octets, treat them as net-endian, clear everything except IHL bits and shift down by 6, which'd yield IHL*4"), for big-endian they don't - you'd get TOS * 4 instead...

#2 lore raw
In reply to Al Viro
Quoted 69 lines · Al Viro

AFAICS, cxgb4_next_header() expects to find match_val/match_mask in
struct cxgb4_next_header stored as big-endian:

                        /* Found a possible candidate.  Find a key that
                         * matches the corresponding offset, value, and
                         * mask to jump to next header.
                         */
                        for (j = 0; j < cls->knode.sel->nkeys; j++) {
                                off = cls->knode.sel->keys[j].off;
                                val = cls->knode.sel->keys[j].val;
                                mask = cls->knode.sel->keys[j].mask;

                                if (next[i].match_off == off &&
                                    next[i].match_val == val &&
                                    next[i].match_mask == mask) {
                                        found = true;
                                        break;
                                }
                        }

Here ->keys[] is struct tc_u32_key and there mask and val are definitely __be32. match_val and match_mask are never changed after initialization and they are set to:

* .match_off = 8, .match_val = 0x600, .match_mask = 0xFF00

	meant to check for IPV4.Protocol == TCP, i.e. octet at offset 9 being 6
* .match_off = 8, .match_val = 0x1100, .match_mask = 0xFF00
	meant to check for IPV4.Protocol == UDP, i.e. octet at offset 9 being 0x11
* .match_off = 4, .match_val = 0x60000, .match_mask = 0xFF0000
	IPV6.NextHeader == TCP, i.e. octet at offset 6 being 6
* .match_off = 4, .match_val = 0x110000, .match_mask = 0xFF0000
	IPV6.NextHeader == UDP, i.e. octet at offset 6 being 0x11

On little-endian host those do yield the right values - e.g. 0x1100 is {0, 17, 0, 0}, etc. On big-endian, though, these will end up checking in IPv4 case the octet at offset 10 (i.e. upper 16 bits of checksum) and for IPv6
- the octet at offset 5 (i.e. the lower 8 bits of payload length).

Unless I'm misreading that code, it needs the following to do the right thing both on l-e and b-e. Comments?

---

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h +4 -6
index a4b99edcc339..ec226b1cebf4 100644
@@ -259,11 +259,11 @@ struct cxgb4_next_header {
  */
 static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = {
 	{ .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
-	  .match_off = 8, .match_val = 0x600, .match_mask = 0xFF00,
-	  .jump = cxgb4_tcp_fields },
+	  .match_off = 8, .match_val = htonl(6 << 16),
+	  .match_mask = htonl(0xff<<16), .jump = cxgb4_tcp_fields },
 	{ .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
-	  .match_off = 8, .match_val = 0x1100, .match_mask = 0xFF00,
-	  .jump = cxgb4_udp_fields },
+	  .match_off = 8, .match_val = htonl(17 << 16),
+	  .match_mask = htonl(0xff<<16), .jump = cxgb4_udp_fields },
 	{ .jump = NULL }
 };
 
@@ -272,11 +272,11 @@ static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = {
  */
 static const struct cxgb4_next_header cxgb4_ipv6_jumps[] = {
 	{ .offset = 0x28, .offoff = 0, .shift = 0, .mask = 0,
-	  .match_off = 4, .match_val = 0x60000, .match_mask = 0xFF0000,
-	  .jump = cxgb4_tcp_fields },

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = { · line 282

Quoted 10 lines
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h +4 -2
+	  .match_off = 4, .match_val = htonl(6 << 8),
+	  .match_mask = htonl(0xff << 8), .jump = cxgb4_tcp_fields },
 	{ .offset = 0x28, .offoff = 0, .shift = 0, .mask = 0,
-	  .match_off = 4, .match_val = 0x110000, .match_mask = 0xFF0000,
-	  .jump = cxgb4_udp_fields },
+	  .match_off = 4, .match_val = htonl(17 << 8),
+	  .match_mask = htonl(0xff << 8), .jump = cxgb4_udp_fields },
 	{ .jump = NULL }
 };
 

Your observation is correct. The current logic is broken for Big-Endian. Thanks for fixing it up Al!

As you've already found in the other email thread, ->mask also needs to be fixed. Should be ".mask = htons(0xf << 8)".

Thanks,
Rahul

#3 lore raw
In reply to Al Viro
Thank you for the patch! Perhaps something to improve:

Hi Al,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.18-rc8 next-20180806]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Al-Viro/cxgb4_next_header-match_val-match_mask-should-be-net-endian/20180806-183127
reproduce:

        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:262:40: sparse: incorrect type in initializer (different base types) @@    expected unsigned int [unsigned] [usertype] match_val @@    got ed int [unsigned] [usertype] match_val @@
   drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:262:40:    expected unsigned int [unsigned] [usertype] match_val
   drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:262:40:    got restricted __be32 [usertype] <noident>
>> drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:263:25: sparse: incorrect type in initializer (different base types) @@    expected unsigned int [unsigned] [usertype] match_mask @@    got ed int [unsigned] [usertype] match_mask @@

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:263:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:263:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:265:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:265:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:265:40: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:266:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:266:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:266:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:275:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:275:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:275:40: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:276:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:276:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:276:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:278:40: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_val @@ got ed int [unsigned] [usertype] match_val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:278:40: expected unsigned int [unsigned] [usertype] match_val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:278:40: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:279:25: sparse: incorrect type in initializer (different base types) @@ expected unsigned int [unsigned] [usertype] match_mask @@ got ed int [unsigned] [usertype] match_mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:279:25: expected unsigned int [unsigned] [usertype] match_mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:279:25: got restricted __be32 [usertype] <noident>
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:56:21: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] val @@ got ed int [unsigned] [usertype] val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:56:21: expected unsigned int [unsigned] [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:56:21: got restricted __be32 [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:57:22: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] mask @@ got ed int [unsigned] [usertype] mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:57:22: expected unsigned int [unsigned] [usertype] mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:57:22: got restricted __be32 [usertype] mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:236:59: sparse: restricted __be16 degrades to integer
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:246:37: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] val @@ got ed int [unsigned] [usertype] val @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:246:37: expected unsigned int [unsigned] [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:246:37: got restricted __be32 [usertype] val
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:247:38: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [unsigned] [usertype] mask @@ got ed int [unsigned] [usertype] mask @@
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:247:38: expected unsigned int [unsigned] [usertype] mask
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c:247:38: got restricted __be32 [usertype] mask
include/linux/mm.h:591:13: sparse: undefined identifier '__builtin_mul_overflow' drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:48:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:49:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:60:21: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:61:20: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:79:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:80:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:116:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:117:24: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:125:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:126:26: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h:221:25: sparse: cast to restricted __be32

vim +262 drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32_parse.h

256
257 /* Accept a rule with a jump to transport layer header based on IHL field in
258 * IPv4 header.
259 */
260 static const struct cxgb4_next_header cxgb4_ipv4_jumps[] = {
261 { .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,

 > 262		  .match_off = 8, .match_val = htonl(6 << 16),
 > 263		  .match_mask = htonl(0xff<<16), .jump = cxgb4_tcp_fields },

264 { .offset = 0, .offoff = 0, .shift = 6, .mask = 0xF,
265 .match_off = 8, .match_val = htonl(17 << 16),
266 .match_mask = htonl(0xff<<16), .jump = cxgb4_udp_fields },
267 { .jump = NULL }
268 };
269

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

author
#4 lore raw
Quoted 8 lines · kbuild test robot

Hi Al,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on net-next/master]
[also build test WARNING on v4.18-rc8 next-20180806]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

Quoted 5 lines

url: https://github.com/0day-ci/linux/commits/Al-Viro/cxgb4_next_header-match_val-match_mask-should-be-net-endian/20180806-183127
reproduce:

        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

Yes, there are arseloads of misannotations. And I do have followups that *do* annotate that (which is exactly how that bug had been found in the first place). But I'd rather separate fixes from trivial annotations - the former might need to be backported, the latter would only cause extra PITA for backport.