Commit e2598dbd authored by David S. Miller's avatar David S. Miller
Browse files

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 2f3a247c dbda0fba
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -222,7 +222,7 @@ struct sctp_datahdr {
	__be16 stream;
	__be16 ssn;
	__u32 ppid;
	__u8  payload[];
	/* __u8  payload[]; */
};

struct sctp_data_chunk {
@@ -270,7 +270,7 @@ struct sctp_inithdr {
	__be16 num_outbound_streams;
	__be16 num_inbound_streams;
	__be32 initial_tsn;
	__u8  params[];
	/* __u8  params[]; */
};

struct sctp_init_chunk {
@@ -385,7 +385,7 @@ struct sctp_sackhdr {
	__be32 a_rwnd;
	__be16 num_gap_ack_blocks;
	__be16 num_dup_tsns;
	union sctp_sack_variable variable[];
	/* union sctp_sack_variable variable[]; */
};

struct sctp_sack_chunk {
@@ -443,7 +443,7 @@ struct sctp_shutdown_chunk {
struct sctp_errhdr {
	__be16 cause;
	__be16 length;
	__u8  variable[];
	/* __u8  variable[]; */
};

struct sctp_operr_chunk {
@@ -603,7 +603,7 @@ struct sctp_fwdtsn_skip {

struct sctp_fwdtsn_hdr {
	__be32 new_cum_tsn;
	struct sctp_fwdtsn_skip skip[];
	/* struct sctp_fwdtsn_skip skip[]; */
};

struct sctp_fwdtsn_chunk {
@@ -620,7 +620,7 @@ struct sctp_ifwdtsn_skip {

struct sctp_ifwdtsn_hdr {
	__be32 new_cum_tsn;
	struct sctp_ifwdtsn_skip skip[];
	/* struct sctp_ifwdtsn_skip skip[]; */
};

struct sctp_ifwdtsn_chunk {
@@ -667,7 +667,7 @@ struct sctp_addip_param {

struct sctp_addiphdr {
	__be32	serial;
	__u8	params[];
	/* __u8	params[]; */
};

struct sctp_addip_chunk {
@@ -727,7 +727,7 @@ struct sctp_addip_chunk {
struct sctp_authhdr {
	__be16 shkey_id;
	__be16 hmac_id;
	__u8   hmac[];
	/* __u8   hmac[]; */
};

struct sctp_auth_chunk {
@@ -742,7 +742,7 @@ struct sctp_infox {

struct sctp_reconf_chunk {
	struct sctp_chunkhdr chunk_hdr;
	__u8 params[];
	/* __u8 params[]; */
};

struct sctp_strreset_outreq {
+6 −6
Original line number Diff line number Diff line
@@ -425,11 +425,11 @@ static inline bool sctp_chunk_pending(const struct sctp_chunk *chunk)
 * the chunk length to indicate when to stop.  Make sure
 * there is room for a param header too.
 */
#define sctp_walk_params(pos, chunk, member)\
_sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member)
#define sctp_walk_params(pos, chunk)\
_sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length))

#define _sctp_walk_params(pos, chunk, end, member)\
for (pos.v = chunk->member;\
#define _sctp_walk_params(pos, chunk, end)\
for (pos.v = (u8 *)(chunk + 1);\
     (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\
      (void *)chunk + end) &&\
     pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
@@ -452,8 +452,8 @@ for (err = (struct sctp_errhdr *)((void *)chunk_hdr + \
_sctp_walk_fwdtsn((pos), (chunk), ntohs((chunk)->chunk_hdr->length) - sizeof(struct sctp_fwdtsn_chunk))

#define _sctp_walk_fwdtsn(pos, chunk, end)\
for (pos = chunk->subh.fwdtsn_hdr->skip;\
     (void *)pos <= (void *)chunk->subh.fwdtsn_hdr->skip + end - sizeof(struct sctp_fwdtsn_skip);\
for (pos = (void *)(chunk->subh.fwdtsn_hdr + 1);\
     (void *)pos <= (void *)(chunk->subh.fwdtsn_hdr + 1) + end - sizeof(struct sctp_fwdtsn_skip);\
     pos++)

/* External references. */
+1 −1
Original line number Diff line number Diff line
@@ -332,7 +332,7 @@ struct sctp_cookie {
	 * the association TCB is re-constructed from the cookie.
	 */
	__u32 raw_addr_list_len;
	struct sctp_init_chunk peer_init[];
	/* struct sctp_init_chunk peer_init[]; */
};


+3 −2
Original line number Diff line number Diff line
@@ -1597,9 +1597,10 @@ int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc,
					 struct sctp_cookie *cookie,
					 gfp_t gfp)
{
	int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length);
	struct sctp_init_chunk *peer_init = (struct sctp_init_chunk *)(cookie + 1);
	int var_size2 = ntohs(peer_init->chunk_hdr.length);
	int var_size3 = cookie->raw_addr_list_len;
	__u8 *raw = (__u8 *)cookie->peer_init + var_size2;
	__u8 *raw = (__u8 *)peer_init + var_size2;

	return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw, var_size3,
				      asoc->ep->base.bind_addr.port, gfp);
+1 −1
Original line number Diff line number Diff line
@@ -738,7 +738,7 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,

	tfm = asoc->ep->auth_hmacs[hmac_id];

	digest = auth->auth_hdr.hmac;
	digest = (u8 *)(&auth->auth_hdr + 1);
	if (crypto_shash_setkey(tfm, &asoc_key->data[0], asoc_key->len))
		goto free;

Loading