These warnings were found by running 'make C=2 M=net/sctp/'. They are introduced by not aware of Endian when coding stream reconf patches. Since commit c0d8bab6ae51 ("sctp: add get and set sockopt for reconf_enable") enabled stream reconf feature for users, the Fixes tag below would use it.
Unified · Split
| @@ -716,28 +716,28 @@ struct sctp_reconf_chunk { · 715 unmodified lines | ||
| 716 | 716 | |
| 717 | 717 | struct sctp_strreset_outreq { |
| 718 | 718 | struct sctp_paramhdr param_hdr; |
| 719 | − __u32 request_seq; | |
| 720 | − __u32 response_seq; | |
| 721 | − __u32 send_reset_at_tsn; | |
| 722 | − __u16 list_of_streams[0]; | |
| 719 | + __be32 request_seq; | |
| 720 | + __be32 response_seq; | |
| 721 | + __be32 send_reset_at_tsn; | |
| 722 | + __be16 list_of_streams[0]; | |
| 723 | 723 | }; |
| 724 | 724 | |
| 725 | 725 | struct sctp_strreset_inreq { |
| 726 | 726 | struct sctp_paramhdr param_hdr; |
| 727 | − __u32 request_seq; | |
| 728 | − __u16 list_of_streams[0]; | |
| 727 | + __be32 request_seq; | |
| 728 | + __be16 list_of_streams[0]; | |
| 729 | 729 | }; |
| 730 | 730 | |
| 731 | 731 | struct sctp_strreset_tsnreq { |
| 732 | 732 | struct sctp_paramhdr param_hdr; |
| 733 | − __u32 request_seq; | |
| 733 | + __be32 request_seq; | |
| 734 | 734 | }; |
| 735 | 735 | |
| 736 | 736 | struct sctp_strreset_addstrm { |
| 737 | 737 | struct sctp_paramhdr param_hdr; |
| 738 | − __u32 request_seq; | |
| 739 | − __u16 number_of_streams; | |
| 740 | − __u16 reserved; | |
| 738 | + __be32 request_seq; | |
| 739 | + __be16 number_of_streams; | |
| 740 | + __be16 reserved; | |
| 741 | 741 | }; |
| 742 | 742 | |
| 743 | 743 | enum { |
| @@ -752,16 +752,16 @@ enum { · 8 unmodified lines | ||
| 752 | 752 | |
| 753 | 753 | struct sctp_strreset_resp { |
| 754 | 754 | struct sctp_paramhdr param_hdr; |
| 755 | − __u32 response_seq; | |
| 756 | − __u32 result; | |
| 755 | + __be32 response_seq; | |
| 756 | + __be32 result; | |
| 757 | 757 | }; |
| 758 | 758 | |
| 759 | 759 | struct sctp_strreset_resptsn { |
| 760 | 760 | struct sctp_paramhdr param_hdr; |
| 761 | − __u32 response_seq; | |
| 762 | − __u32 result; | |
| 763 | − __u32 senders_next_tsn; | |
| 764 | − __u32 receivers_next_tsn; | |
| 761 | + __be32 response_seq; | |
| 762 | + __be32 result; | |
| 763 | + __be32 senders_next_tsn; | |
| 764 | + __be32 receivers_next_tsn; | |
| 765 | 765 | }; |
| 766 | 766 | |
| 767 | 767 | #endif /* __LINUX_SCTP_H__ */ |
| @@ -261,7 +261,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, · 260 unmodified lines | ||
| 261 | 261 | struct sctp_fwdtsn_skip *skiplist); |
| 262 | 262 | struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc); |
| 263 | 263 | struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc, |
| 264 | − __u16 stream_num, __u16 *stream_list, | |
| 264 | + __u16 stream_num, __be16 *stream_list, | |
| 265 | 265 | bool out, bool in); |
| 266 | 266 | struct sctp_chunk *sctp_make_strreset_tsnreq( |
| 267 | 267 | const struct sctp_association *asoc); |
| @@ -130,7 +130,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( · 129 unmodified lines | ||
| 130 | 130 | |
| 131 | 131 | struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( |
| 132 | 132 | const struct sctp_association *asoc, __u16 flags, |
| 133 | − __u16 stream_num, __u16 *stream_list, gfp_t gfp); | |
| 133 | + __u16 stream_num, __be16 *stream_list, gfp_t gfp); | |
| 134 | 134 | |
| 135 | 135 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event( |
| 136 | 136 | const struct sctp_association *asoc, __u16 flags, |
| @@ -3591,7 +3591,7 @@ static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc, · 3590 unmodified lines | ||
| 3591 | 3591 | */ |
| 3592 | 3592 | struct sctp_chunk *sctp_make_strreset_req( |
| 3593 | 3593 | const struct sctp_association *asoc, |
| 3594 | − __u16 stream_num, __u16 *stream_list, | |
| 3594 | + __u16 stream_num, __be16 *stream_list, | |
| 3595 | 3595 | bool out, bool in) |
| 3596 | 3596 | { |
| 3597 | 3597 | struct sctp_strreset_outreq outreq; |
| @@ -3788,7 +3788,8 @@ bool sctp_verify_reconf(const struct sctp_association *asoc, · 190 unmodified lines | ||
| 3788 | 3788 | { |
| 3789 | 3789 | struct sctp_reconf_chunk *hdr; |
| 3790 | 3790 | union sctp_params param; |
| 3791 | − __u16 last = 0, cnt = 0; | |
| 3791 | + __be16 last = 0; | |
| 3792 | + __u16 cnt = 0; | |
| 3792 | 3793 | |
| 3793 | 3794 | hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; |
| 3794 | 3795 | sctp_walk_params(param, hdr, params) { |
| @@ -118,6 +118,7 @@ int sctp_send_reset_streams(struct sctp_association *asoc, · 117 unmodified lines | ||
| 118 | 118 | __u16 i, str_nums, *str_list; |
| 119 | 119 | struct sctp_chunk *chunk; |
| 120 | 120 | int retval = -EINVAL; |
| 121 | + __be16 *nstr_list; | |
| 121 | 122 | bool out, in; |
| 122 | 123 | |
| 123 | 124 | if (!asoc->peer.reconf_capable || |
| @@ -148,13 +149,18 @@ int sctp_send_reset_streams(struct sctp_association *asoc, · 24 unmodified lines | ||
| 148 | 149 | if (str_list[i] >= stream->incnt) |
| 149 | 150 | goto out; |
| 150 | 151 | |
| 152 | + nstr_list = kcalloc(str_nums, sizeof(__be16), GFP_KERNEL); | |
| 153 | + if (!nstr_list) { | |
| 154 | + retval = -ENOMEM; | |
| 155 | + goto out; | |
| 156 | + } | |
| 157 | + | |
| 151 | 158 | for (i = 0; i < str_nums; i++) |
| 152 | − str_list[i] = htons(str_list[i]); | |
| 159 | + nstr_list[i] = htons(str_list[i]); | |
| 153 | 160 | |
| 154 | − chunk = sctp_make_strreset_req(asoc, str_nums, str_list, out, in); | |
| 161 | + chunk = sctp_make_strreset_req(asoc, str_nums, nstr_list, out, in); | |
| 155 | 162 | |
| 156 | − for (i = 0; i < str_nums; i++) | |
| 157 | − str_list[i] = ntohs(str_list[i]); | |
| 163 | + kfree(nstr_list); | |
| 158 | 164 | |
| 159 | 165 | if (!chunk) { |
| 160 | 166 | retval = -ENOMEM; |
| @@ -305,7 +311,7 @@ out: · 144 unmodified lines | ||
| 305 | 311 | } |
| 306 | 312 | |
| 307 | 313 | static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param( |
| 308 | − struct sctp_association *asoc, __u32 resp_seq, | |
| 314 | + struct sctp_association *asoc, __be32 resp_seq, | |
| 309 | 315 | __be16 type) |
| 310 | 316 | { |
| 311 | 317 | struct sctp_chunk *chunk = asoc->strreset_chunk; |
| @@ -345,8 +351,9 @@ struct sctp_chunk *sctp_process_strreset_outreq( · 33 unmodified lines | ||
| 345 | 351 | { |
| 346 | 352 | struct sctp_strreset_outreq *outreq = param.v; |
| 347 | 353 | struct sctp_stream *stream = &asoc->stream; |
| 348 | − __u16 i, nums, flags = 0, *str_p = NULL; | |
| 349 | 354 | __u32 result = SCTP_STRRESET_DENIED; |
| 355 | + __u16 i, nums, flags = 0; | |
| 356 | + __be16 *str_p = NULL; | |
| 350 | 357 | __u32 request_seq; |
| 351 | 358 | |
| 352 | 359 | request_seq = ntohl(outreq->request_seq); |
| @@ -439,8 +446,9 @@ struct sctp_chunk *sctp_process_strreset_inreq( · 86 unmodified lines | ||
| 439 | 446 | struct sctp_stream *stream = &asoc->stream; |
| 440 | 447 | __u32 result = SCTP_STRRESET_DENIED; |
| 441 | 448 | struct sctp_chunk *chunk = NULL; |
| 442 | − __u16 i, nums, *str_p; | |
| 443 | 449 | __u32 request_seq; |
| 450 | + __u16 i, nums; | |
| 451 | + __be16 *str_p; | |
| 444 | 452 | |
| 445 | 453 | request_seq = ntohl(inreq->request_seq); |
| 446 | 454 | if (TSN_lt(asoc->strreset_inseq, request_seq) || |
| @@ -769,7 +777,7 @@ struct sctp_chunk *sctp_process_strreset_resp( · 322 unmodified lines | ||
| 769 | 777 | |
| 770 | 778 | if (req->type == SCTP_PARAM_RESET_OUT_REQUEST) { |
| 771 | 779 | struct sctp_strreset_outreq *outreq; |
| 772 | − __u16 *str_p; | |
| 780 | + __be16 *str_p; | |
| 773 | 781 | |
| 774 | 782 | outreq = (struct sctp_strreset_outreq *)req; |
| 775 | 783 | str_p = outreq->list_of_streams; |
| @@ -794,7 +802,7 @@ struct sctp_chunk *sctp_process_strreset_resp( · 18 unmodified lines | ||
| 794 | 802 | nums, str_p, GFP_ATOMIC); |
| 795 | 803 | } else if (req->type == SCTP_PARAM_RESET_IN_REQUEST) { |
| 796 | 804 | struct sctp_strreset_inreq *inreq; |
| 797 | − __u16 *str_p; | |
| 805 | + __be16 *str_p; | |
| 798 | 806 | |
| 799 | 807 | /* if the result is performed, it's impossible for inreq */ |
| 800 | 808 | if (result == SCTP_STRRESET_PERFORMED) |
| @@ -847,7 +847,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( · 846 unmodified lines | ||
| 847 | 847 | |
| 848 | 848 | struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event( |
| 849 | 849 | const struct sctp_association *asoc, __u16 flags, __u16 stream_num, |
| 850 | − __u16 *stream_list, gfp_t gfp) | |
| 850 | + __be16 *stream_list, gfp_t gfp) | |
| 851 | 851 | { |
| 852 | 852 | struct sctp_stream_reset_event *sreset; |
| 853 | 853 | struct sctp_ulpevent *event; |