Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'sctp-nested-flex-arrays'

Xin Long says:

====================
sctp: fix a plenty of flexible-array-nested warnings

Paolo noticed a compile warning in SCTP,

../net/sctp/stream_sched_fc.c: note: in included file (through ../include/net/sctp/sctp.h):
../include/net/sctp/structs.h:335:41: warning: array of flexible structures

But not only this, there are actually quite a lot of such warnings in
some SCTP structs. This patchset fixes most of warnings by deleting
these nested flexible array members.

After this patchset, there are still some warnings left:

# make C=2 CF="-Wflexible-array-nested" M=./net/sctp/
./include/net/sctp/structs.h:1145:41: warning: nested flexible array
./include/uapi/linux/sctp.h:641:34: warning: nested flexible array
./include/uapi/linux/sctp.h:643:34: warning: nested flexible array
./include/uapi/linux/sctp.h:644:33: warning: nested flexible array
./include/uapi/linux/sctp.h:650:40: warning: nested flexible array
./include/uapi/linux/sctp.h:653:39: warning: nested flexible array

the 1st is caused by __data[] in struct ip_options, not in SCTP;
the others are in uapi, and we should not touch them.

Note that instead of completely deleting it, we just leave it as a
comment in the struct, signalling to the reader that we do expect
such variable parameters over there, as Marcelo suggested.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+49 -48
+9 -9
include/linux/sctp.h
··· 222 222 __be16 stream; 223 223 __be16 ssn; 224 224 __u32 ppid; 225 - __u8 payload[]; 225 + /* __u8 payload[]; */ 226 226 }; 227 227 228 228 struct sctp_data_chunk { ··· 270 270 __be16 num_outbound_streams; 271 271 __be16 num_inbound_streams; 272 272 __be32 initial_tsn; 273 - __u8 params[]; 273 + /* __u8 params[]; */ 274 274 }; 275 275 276 276 struct sctp_init_chunk { ··· 385 385 __be32 a_rwnd; 386 386 __be16 num_gap_ack_blocks; 387 387 __be16 num_dup_tsns; 388 - union sctp_sack_variable variable[]; 388 + /* union sctp_sack_variable variable[]; */ 389 389 }; 390 390 391 391 struct sctp_sack_chunk { ··· 443 443 struct sctp_errhdr { 444 444 __be16 cause; 445 445 __be16 length; 446 - __u8 variable[]; 446 + /* __u8 variable[]; */ 447 447 }; 448 448 449 449 struct sctp_operr_chunk { ··· 603 603 604 604 struct sctp_fwdtsn_hdr { 605 605 __be32 new_cum_tsn; 606 - struct sctp_fwdtsn_skip skip[]; 606 + /* struct sctp_fwdtsn_skip skip[]; */ 607 607 }; 608 608 609 609 struct sctp_fwdtsn_chunk { ··· 620 620 621 621 struct sctp_ifwdtsn_hdr { 622 622 __be32 new_cum_tsn; 623 - struct sctp_ifwdtsn_skip skip[]; 623 + /* struct sctp_ifwdtsn_skip skip[]; */ 624 624 }; 625 625 626 626 struct sctp_ifwdtsn_chunk { ··· 667 667 668 668 struct sctp_addiphdr { 669 669 __be32 serial; 670 - __u8 params[]; 670 + /* __u8 params[]; */ 671 671 }; 672 672 673 673 struct sctp_addip_chunk { ··· 727 727 struct sctp_authhdr { 728 728 __be16 shkey_id; 729 729 __be16 hmac_id; 730 - __u8 hmac[]; 730 + /* __u8 hmac[]; */ 731 731 }; 732 732 733 733 struct sctp_auth_chunk { ··· 742 742 743 743 struct sctp_reconf_chunk { 744 744 struct sctp_chunkhdr chunk_hdr; 745 - __u8 params[]; 745 + /* __u8 params[]; */ 746 746 }; 747 747 748 748 struct sctp_strreset_outreq {
+6 -6
include/net/sctp/sctp.h
··· 425 425 * the chunk length to indicate when to stop. Make sure 426 426 * there is room for a param header too. 427 427 */ 428 - #define sctp_walk_params(pos, chunk, member)\ 429 - _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) 428 + #define sctp_walk_params(pos, chunk)\ 429 + _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length)) 430 430 431 - #define _sctp_walk_params(pos, chunk, end, member)\ 432 - for (pos.v = chunk->member;\ 431 + #define _sctp_walk_params(pos, chunk, end)\ 432 + for (pos.v = (u8 *)(chunk + 1);\ 433 433 (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\ 434 434 (void *)chunk + end) &&\ 435 435 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ ··· 452 452 _sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk)) 453 453 454 454 #define _sctp_walk_fwdtsn(pos, chunk, end)\ 455 - for (pos = chunk->subh.fwdtsn_hdr->skip;\ 456 - (void *)pos <= (void *)chunk->subh.fwdtsn_hdr->skip + end - sizeof(struct sctp_fwdtsn_skip);\ 455 + for (pos = (void *)(chunk->subh.fwdtsn_hdr + 1);\ 456 + (void *)pos <= (void *)(chunk->subh.fwdtsn_hdr + 1) + end - sizeof(struct sctp_fwdtsn_skip);\ 457 457 pos++) 458 458 459 459 /* External references. */
+1 -1
include/net/sctp/structs.h
··· 332 332 * the association TCB is re-constructed from the cookie. 333 333 */ 334 334 __u32 raw_addr_list_len; 335 - struct sctp_init_chunk peer_init[]; 335 + /* struct sctp_init_chunk peer_init[]; */ 336 336 }; 337 337 338 338
+3 -2
net/sctp/associola.c
··· 1597 1597 struct sctp_cookie *cookie, 1598 1598 gfp_t gfp) 1599 1599 { 1600 - int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length); 1600 + struct sctp_init_chunk *peer_init = (struct sctp_init_chunk *)(cookie + 1); 1601 + int var_size2 = ntohs(peer_init->chunk_hdr.length); 1601 1602 int var_size3 = cookie->raw_addr_list_len; 1602 - __u8 *raw = (__u8 *)cookie->peer_init + var_size2; 1603 + __u8 *raw = (__u8 *)peer_init + var_size2; 1603 1604 1604 1605 return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw, var_size3, 1605 1606 asoc->ep->base.bind_addr.port, gfp);
+1 -1
net/sctp/auth.c
··· 738 738 739 739 tfm = asoc->ep->auth_hmacs[hmac_id]; 740 740 741 - digest = auth->auth_hdr.hmac; 741 + digest = (u8 *)(&auth->auth_hdr + 1); 742 742 if (crypto_shash_setkey(tfm, &asoc_key->data[0], asoc_key->len)) 743 743 goto free; 744 744
+1 -1
net/sctp/input.c
··· 1150 1150 init = (struct sctp_init_chunk *)skb->data; 1151 1151 1152 1152 /* Walk the parameters looking for embedded addresses. */ 1153 - sctp_walk_params(params, init, init_hdr.params) { 1153 + sctp_walk_params(params, init) { 1154 1154 1155 1155 /* Note: Ignoring hostname addresses. */ 1156 1156 af = sctp_get_af_specific(param_type2af(params.p->type));
+7 -4
net/sctp/outqueue.c
··· 1231 1231 1232 1232 unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1; 1233 1233 1234 - frags = sack->variable; 1234 + frags = (union sctp_sack_variable *)(sack + 1); 1235 1235 for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) { 1236 1236 unack_data -= ((ntohs(frags[i].gab.end) - 1237 1237 ntohs(frags[i].gab.start) + 1)); ··· 1252 1252 struct sctp_transport *transport; 1253 1253 struct sctp_chunk *tchunk = NULL; 1254 1254 struct list_head *lchunk, *transport_list, *temp; 1255 - union sctp_sack_variable *frags = sack->variable; 1256 1255 __u32 sack_ctsn, ctsn, tsn; 1257 1256 __u32 highest_tsn, highest_new_tsn; 1258 1257 __u32 sack_a_rwnd; ··· 1312 1313 1313 1314 /* Get the highest TSN in the sack. */ 1314 1315 highest_tsn = sack_ctsn; 1315 - if (gap_ack_blocks) 1316 + if (gap_ack_blocks) { 1317 + union sctp_sack_variable *frags = 1318 + (union sctp_sack_variable *)(sack + 1); 1319 + 1316 1320 highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end); 1321 + } 1317 1322 1318 1323 if (TSN_lt(asoc->highest_sacked, highest_tsn)) 1319 1324 asoc->highest_sacked = highest_tsn; ··· 1792 1789 * Block are assumed to have been received correctly. 1793 1790 */ 1794 1791 1795 - frags = sack->variable; 1792 + frags = (union sctp_sack_variable *)(sack + 1); 1796 1793 blocks = ntohs(sack->num_gap_ack_blocks); 1797 1794 tsn_offset = tsn - ctsn; 1798 1795 for (i = 0; i < blocks; ++i) {
+11 -11
net/sctp/sm_make_chunk.c
··· 1707 1707 ktime_get_real()); 1708 1708 1709 1709 /* Copy the peer's init packet. */ 1710 - memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr, 1710 + memcpy(cookie + 1, init_chunk->chunk_hdr, 1711 1711 ntohs(init_chunk->chunk_hdr->length)); 1712 1712 1713 1713 /* Copy the raw local address list of the association. */ 1714 - memcpy((__u8 *)&cookie->c.peer_init[0] + 1714 + memcpy((__u8 *)(cookie + 1) + 1715 1715 ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len); 1716 1716 1717 1717 if (sctp_sk(ep->base.sk)->hmac) { ··· 2306 2306 ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW) 2307 2307 return sctp_process_inv_mandatory(asoc, chunk, errp); 2308 2308 2309 - sctp_walk_params(param, peer_init, init_hdr.params) { 2309 + sctp_walk_params(param, peer_init) { 2310 2310 if (param.p->type == SCTP_PARAM_STATE_COOKIE) 2311 2311 has_cookie = true; 2312 2312 } ··· 2329 2329 chunk, errp); 2330 2330 2331 2331 /* Verify all the variable length parameters */ 2332 - sctp_walk_params(param, peer_init, init_hdr.params) { 2332 + sctp_walk_params(param, peer_init) { 2333 2333 result = sctp_verify_param(net, ep, asoc, param, cid, 2334 2334 chunk, errp); 2335 2335 switch (result) { ··· 2381 2381 src_match = 1; 2382 2382 2383 2383 /* Process the initialization parameters. */ 2384 - sctp_walk_params(param, peer_init, init_hdr.params) { 2384 + sctp_walk_params(param, peer_init) { 2385 2385 if (!src_match && 2386 2386 (param.p->type == SCTP_PARAM_IPV4_ADDRESS || 2387 2387 param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { ··· 3202 3202 union sctp_params param; 3203 3203 3204 3204 addip = (struct sctp_addip_chunk *)chunk->chunk_hdr; 3205 - sctp_walk_params(param, addip, addip_hdr.params) { 3205 + sctp_walk_params(param, addip) { 3206 3206 size_t length = ntohs(param.p->length); 3207 3207 3208 3208 *errp = param.p; ··· 3215 3215 /* ensure there is only one addr param and it's in the 3216 3216 * beginning of addip_hdr params, or we reject it. 3217 3217 */ 3218 - if (param.v != addip->addip_hdr.params) 3218 + if (param.v != (addip + 1)) 3219 3219 return false; 3220 3220 addr_param_seen = true; 3221 3221 break; 3222 3222 case SCTP_PARAM_IPV6_ADDRESS: 3223 3223 if (length != sizeof(struct sctp_ipv6addr_param)) 3224 3224 return false; 3225 - if (param.v != addip->addip_hdr.params) 3225 + if (param.v != (addip + 1)) 3226 3226 return false; 3227 3227 addr_param_seen = true; 3228 3228 break; ··· 3302 3302 goto done; 3303 3303 3304 3304 /* Process the TLVs contained within the ASCONF chunk. */ 3305 - sctp_walk_params(param, addip, addip_hdr.params) { 3305 + sctp_walk_params(param, addip) { 3306 3306 /* Skip preceeding address parameters. */ 3307 3307 if (param.p->type == SCTP_PARAM_IPV4_ADDRESS || 3308 3308 param.p->type == SCTP_PARAM_IPV6_ADDRESS) ··· 3636 3636 return NULL; 3637 3637 3638 3638 reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr; 3639 - retval->param_hdr.v = reconf->params; 3639 + retval->param_hdr.v = (u8 *)(reconf + 1); 3640 3640 3641 3641 return retval; 3642 3642 } ··· 3878 3878 __u16 cnt = 0; 3879 3879 3880 3880 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; 3881 - sctp_walk_params(param, hdr, params) { 3881 + sctp_walk_params(param, hdr) { 3882 3882 __u16 length = ntohs(param.p->length); 3883 3883 3884 3884 *errp = param.p;
+1 -2
net/sctp/sm_sideeffect.c
··· 984 984 { 985 985 struct sctp_chunkhdr *unk_chunk_hdr; 986 986 987 - unk_chunk_hdr = (struct sctp_chunkhdr *) 988 - err_hdr->variable; 987 + unk_chunk_hdr = (struct sctp_chunkhdr *)(err_hdr + 1); 989 988 switch (unk_chunk_hdr->type) { 990 989 /* ADDIP 4.1 A9) If the peer responds to an ASCONF with 991 990 * an ERROR chunk reporting that it did not recognized
+6 -8
net/sctp/sm_statefuns.c
··· 794 794 /* This is a brand-new association, so these are not yet side 795 795 * effects--it is safe to run them here. 796 796 */ 797 - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; 798 - 797 + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); 799 798 if (!sctp_process_init(new_asoc, chunk, 800 799 &chunk->subh.cookie_hdr->c.peer_addr, 801 800 peer_init, GFP_ATOMIC)) ··· 1336 1337 * throughout the code today. 1337 1338 */ 1338 1339 errhdr = (struct sctp_errhdr *)buffer; 1339 - addrparm = (union sctp_addr_param *)errhdr->variable; 1340 + addrparm = (union sctp_addr_param *)(errhdr + 1); 1340 1341 1341 1342 /* Copy into a parm format. */ 1342 1343 len = af->to_addr_param(ssa, addrparm); ··· 1868 1869 /* new_asoc is a brand-new association, so these are not yet 1869 1870 * side effects--it is safe to run them here. 1870 1871 */ 1871 - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; 1872 - 1872 + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); 1873 1873 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, 1874 1874 GFP_ATOMIC)) 1875 1875 goto nomem; ··· 1988 1990 /* new_asoc is a brand-new association, so these are not yet 1989 1991 * side effects--it is safe to run them here. 1990 1992 */ 1991 - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; 1993 + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); 1992 1994 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, 1993 1995 GFP_ATOMIC)) 1994 1996 goto nomem; ··· 4140 4142 (void *)err_param, commands); 4141 4143 4142 4144 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; 4143 - sctp_walk_params(param, hdr, params) { 4145 + sctp_walk_params(param, hdr) { 4144 4146 struct sctp_chunk *reply = NULL; 4145 4147 struct sctp_ulpevent *ev = NULL; 4146 4148 ··· 4391 4393 * 3. Compute the new digest 4392 4394 * 4. Compare saved and new digests. 4393 4395 */ 4394 - digest = auth_hdr->hmac; 4396 + digest = (u8 *)(auth_hdr + 1); 4395 4397 skb_pull(chunk->skb, sig_len); 4396 4398 4397 4399 save_digest = kmemdup(digest, sig_len, GFP_ATOMIC);
+1 -1
net/sctp/stream.c
··· 491 491 return NULL; 492 492 493 493 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; 494 - sctp_walk_params(param, hdr, params) { 494 + sctp_walk_params(param, hdr) { 495 495 /* sctp_strreset_tsnreq is actually the basic structure 496 496 * of all stream reconf params, so it's safe to use it 497 497 * to access request_seq.
+2 -2
net/sctp/stream_interleave.c
··· 1153 1153 } 1154 1154 1155 1155 #define _sctp_walk_ifwdtsn(pos, chunk, end) \ 1156 - for (pos = chunk->subh.ifwdtsn_hdr->skip; \ 1157 - (void *)pos <= (void *)chunk->subh.ifwdtsn_hdr->skip + (end) - \ 1156 + for (pos = (void *)(chunk->subh.ifwdtsn_hdr + 1); \ 1157 + (void *)pos <= (void *)(chunk->subh.ifwdtsn_hdr + 1) + (end) - \ 1158 1158 sizeof(struct sctp_ifwdtsn_skip); pos++) 1159 1159 1160 1160 #define sctp_walk_ifwdtsn(pos, ch) \