From patchwork Wed Apr 19 15:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13217037 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7121EC77B75 for ; Wed, 19 Apr 2023 15:19:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233559AbjDSPTX (ORCPT ); Wed, 19 Apr 2023 11:19:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233549AbjDSPTQ (ORCPT ); Wed, 19 Apr 2023 11:19:16 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423EE7680; Wed, 19 Apr 2023 08:18:47 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id br19so4791598qtb.7; Wed, 19 Apr 2023 08:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681917396; x=1684509396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ACNg3in/pkKi1xmc2bSu1ksz6xcHFFBw+fJlM+8OI8c=; b=RcdPPF7WcBxXdQyvMqfgA/fR3Id/960Gk7WqicmjOiufhpVKMkwokykAuPfvbM575y pMJSk2nqm4fTPI1xZ+f6cbaKedBUvohN6SmAA8llG95tAsoxm+XTja8KOqRk0hAZawKu XSLMkhtqmNWi8DXb+ogUeAjNTGnB92ABOXOVOQoVaewsYcEr2hQmUru/SkknKNfY2mRo tZqNB9kqlcUP/Kq/LOgoKW1GT/qjhnwAM7S59Au34Ms9BHByTo4Nfj3zVnajXHtyGKJL lG3nyEKFW0NpnaNsMSJHNQfiIbbXv836OaFsCxRuYEjU7c6sRqzFBJDUBTZaQ0KIOi9v Qwfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681917396; x=1684509396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ACNg3in/pkKi1xmc2bSu1ksz6xcHFFBw+fJlM+8OI8c=; b=D/X+RzdITuUQUhPOJTbXCiZE2xUOx8PXipRQJhTXro7/vE8yI06tvxJVK5THAVELSp coTvlhz4wk9+WBv/+APyJTawhSZlWJ8Pcv/f6MclY6h8VWSNj7fAuS/vD6AoIERZxn77 Qd6khnbDT3C4Kt2PKHHkHJhyIpE7mVMyY4b7QntIq8UA9ogeqb1lBV5YH+0+o4dc5pZv ofzo2WkEtnPi6+l041ch9XTNAWEL+mzViWtbkCih3DxYuZRGqopPgN58wlwqEi2WeFwy 2FiwXqOuPgTVsSeJcld0WHyyM9SYB05/CqUWfYs4xWTEJAji3dKW/cN+AQCMrapG1xjB f5jQ== X-Gm-Message-State: AAQBX9cc61aAyDRkjNGsLIzbwLU9cRpClBIl9hyHY7Loy5uWS8rfgX4i lPdKjqotcn7tFz+7GenaQBw4vaUiBt/Rug== X-Google-Smtp-Source: AKy350b5U8WZ5bNppfqC4HBS7bS2ykF9e3PkxbLDDcARqk7upBy7g9FibDJerofsAtyEA3UD0kAVhg== X-Received: by 2002:ac8:5a54:0:b0:3e2:4280:bc56 with SMTP id o20-20020ac85a54000000b003e24280bc56mr6403405qta.41.1681917395847; Wed, 19 Apr 2023 08:16:35 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v11-20020a05620a0f0b00b007469b5bc2c4sm4753336qkl.13.2023.04.19.08.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 08:16:35 -0700 (PDT) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Marcelo Ricardo Leitner Subject: [PATCH net-next 1/6] sctp: delete the nested flexible array params Date: Wed, 19 Apr 2023 11:16:28 -0400 Message-Id: <93430583976e882b25a186ab940ba03a06014097.1681917361.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch deletes the flexible-array params[] from the structure sctp_inithdr, sctp_addiphdr and sctp_reconf_chunk to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/input.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h): ./include/linux/sctp.h:278:29: warning: nested flexible array ./include/linux/sctp.h:675:30: warning: nested flexible array This warning is reported if a structure having a flexible array member is included by other structures. Signed-off-by: Xin Long --- include/linux/sctp.h | 6 +++--- include/net/sctp/sctp.h | 8 ++++---- net/sctp/input.c | 2 +- net/sctp/sm_make_chunk.c | 18 +++++++++--------- net/sctp/sm_statefuns.c | 2 +- net/sctp/stream.c | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 358dc08e0831..0ff36a2737a3 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -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 { @@ -667,7 +667,7 @@ struct sctp_addip_param { struct sctp_addiphdr { __be32 serial; - __u8 params[]; + /* __u8 params[]; */ }; struct sctp_addip_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 { diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index c335dd01a597..74fae532b944 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h @@ -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) &&\ diff --git a/net/sctp/input.c b/net/sctp/input.c index 127bf28a6033..2613c4d74b16 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -1150,7 +1150,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net, init = (struct sctp_init_chunk *)skb->data; /* Walk the parameters looking for embedded addresses. */ - sctp_walk_params(params, init, init_hdr.params) { + sctp_walk_params(params, init) { /* Note: Ignoring hostname addresses. */ af = sctp_get_af_specific(param_type2af(params.p->type)); diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index c8f4ec5d5f98..4dbbbc2a7742 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -2306,7 +2306,7 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep, ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW) return sctp_process_inv_mandatory(asoc, chunk, errp); - sctp_walk_params(param, peer_init, init_hdr.params) { + sctp_walk_params(param, peer_init) { if (param.p->type == SCTP_PARAM_STATE_COOKIE) has_cookie = true; } @@ -2329,7 +2329,7 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep, chunk, errp); /* Verify all the variable length parameters */ - sctp_walk_params(param, peer_init, init_hdr.params) { + sctp_walk_params(param, peer_init) { result = sctp_verify_param(net, ep, asoc, param, cid, chunk, errp); switch (result) { @@ -2381,7 +2381,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, src_match = 1; /* Process the initialization parameters. */ - sctp_walk_params(param, peer_init, init_hdr.params) { + sctp_walk_params(param, peer_init) { if (!src_match && (param.p->type == SCTP_PARAM_IPV4_ADDRESS || param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { @@ -3202,7 +3202,7 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, union sctp_params param; addip = (struct sctp_addip_chunk *)chunk->chunk_hdr; - sctp_walk_params(param, addip, addip_hdr.params) { + sctp_walk_params(param, addip) { size_t length = ntohs(param.p->length); *errp = param.p; @@ -3215,14 +3215,14 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, /* ensure there is only one addr param and it's in the * beginning of addip_hdr params, or we reject it. */ - if (param.v != addip->addip_hdr.params) + if (param.v != (addip + 1)) return false; addr_param_seen = true; break; case SCTP_PARAM_IPV6_ADDRESS: if (length != sizeof(struct sctp_ipv6addr_param)) return false; - if (param.v != addip->addip_hdr.params) + if (param.v != (addip + 1)) return false; addr_param_seen = true; break; @@ -3302,7 +3302,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, goto done; /* Process the TLVs contained within the ASCONF chunk. */ - sctp_walk_params(param, addip, addip_hdr.params) { + sctp_walk_params(param, addip) { /* Skip preceeding address parameters. */ if (param.p->type == SCTP_PARAM_IPV4_ADDRESS || param.p->type == SCTP_PARAM_IPV6_ADDRESS) @@ -3636,7 +3636,7 @@ static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc, return NULL; reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr; - retval->param_hdr.v = reconf->params; + retval->param_hdr.v = (u8 *)(reconf + 1); return retval; } @@ -3878,7 +3878,7 @@ bool sctp_verify_reconf(const struct sctp_association *asoc, __u16 cnt = 0; hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; - sctp_walk_params(param, hdr, params) { + sctp_walk_params(param, hdr) { __u16 length = ntohs(param.p->length); *errp = param.p; diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index ce5426171206..39d416e7f795 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -4142,7 +4142,7 @@ enum sctp_disposition sctp_sf_do_reconf(struct net *net, (void *)err_param, commands); hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; - sctp_walk_params(param, hdr, params) { + sctp_walk_params(param, hdr) { struct sctp_chunk *reply = NULL; struct sctp_ulpevent *ev = NULL; diff --git a/net/sctp/stream.c b/net/sctp/stream.c index ee6514af830f..c241cc552e8d 100644 --- a/net/sctp/stream.c +++ b/net/sctp/stream.c @@ -491,7 +491,7 @@ static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param( return NULL; hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; - sctp_walk_params(param, hdr, params) { + sctp_walk_params(param, hdr) { /* sctp_strreset_tsnreq is actually the basic structure * of all stream reconf params, so it's safe to use it * to access request_seq. From patchwork Wed Apr 19 15:16:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13217023 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75C77C77B7C for ; Wed, 19 Apr 2023 15:19:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232911AbjDSPTD (ORCPT ); Wed, 19 Apr 2023 11:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231719AbjDSPTC (ORCPT ); Wed, 19 Apr 2023 11:19:02 -0400 Received: from mail-oa1-x2e.google.com (mail-oa1-x2e.google.com [IPv6:2001:4860:4864:20::2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C39D55276; Wed, 19 Apr 2023 08:18:26 -0700 (PDT) Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-187dc84637aso7415837fac.2; Wed, 19 Apr 2023 08:18:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681917397; x=1684509397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Gy/aHQhJo3z37sbDf6ajKje4fKZ5wE8Tq3mhw1LqkKc=; b=jX6InRAIyTjD1cOfVFHpDWJt1VEls3KZi/E6astHG2Ys1CjaqPC2qTCDR1cYn0wEXy MtstKn+7qISxdyyktJJpFgv8uo3uoNgD6iKlViQ13jHEGlkLM2sfKx6JOKTXAZGTm8FG GSq1cS2lfjzGFpNYHK/lKGJFNXkwEagqMk0s+Hf6I5ILm/6k2kWpCmLfiV+tKftriLG5 m0ubnhzrw6X701oErmo6rr/nBnN8V3RMqJpYcqRNKoME3eEzNXuNi1ipbWTdogcu0ppv UVnVf4aEmnTuzGxUaiZc9JkTiy2a2Fe6bZ23eqE8LmHIyZfV/Zb9v5fAxC+VwRWWoqBU qTWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681917397; x=1684509397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gy/aHQhJo3z37sbDf6ajKje4fKZ5wE8Tq3mhw1LqkKc=; b=Az4ppt0Ncaa9Ar+t6qWIYPrUy5FFSPl+P5j3UD1QIsT3VdTzNk3rvFX/My3O6553X6 fhVo1oNdbS2TeLX6ayW7RtQSv8DAk9RHdD4on1Bi+88sQpboTsTGw1ilMumRK81EQQaW xXbNbqXYkgGAUepCuvUYcBre68AMlsDXqQ0GX6BTAJdE+i8O7M3DLsTqATobH3WAY5Hl uNzyN1iohbynLiZdx+xr9foA5MXfk3Q9uITuXocJE9KrwKwCsU5RvNBS9ieMSQyUnvzw nx1NWQvVqhzbPoGaEDkOfCE9AJkq5G9tD5TTJhwqCvS+IadcIZzBcIj7uQlj21EADRsj /P+Q== X-Gm-Message-State: AAQBX9ccXhu228We3Ud6JCcBL1avgCaWu8qd3GV0PGWd8PDVuIeFWtbk SfhIriOQoVEiVYZjA3wPnROQhdBidC2Yyg== X-Google-Smtp-Source: AKy350Z+0ei2gpizHYdeBbAlRLc+NVhM7qYrlOBAUDUVod7sMaTG+NaP14YW7O4PcjuUrLkbu1d4ow== X-Received: by 2002:a05:6358:c6a5:b0:118:1a32:fcef with SMTP id fe37-20020a056358c6a500b001181a32fcefmr10488rwb.6.1681917396702; Wed, 19 Apr 2023 08:16:36 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v11-20020a05620a0f0b00b007469b5bc2c4sm4753336qkl.13.2023.04.19.08.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 08:16:36 -0700 (PDT) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Marcelo Ricardo Leitner Subject: [PATCH net-next 2/6] sctp: delete the nested flexible array skip Date: Wed, 19 Apr 2023 11:16:29 -0400 Message-Id: <48a8d405dd4d81f7be75b7f39685e090867d858b.1681917361.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch deletes the flexible-array skip[] from the structure sctp_ifwdtsn/fwdtsn_hdr to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/stream_interleave.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h): ./include/linux/sctp.h:611:32: warning: nested flexible array ./include/linux/sctp.h:628:33: warning: nested flexible array Signed-off-by: Xin Long --- include/linux/sctp.h | 4 ++-- include/net/sctp/sctp.h | 4 ++-- net/sctp/stream_interleave.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 0ff36a2737a3..9815b801fec0 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -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 { diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 74fae532b944..2a67100b2a17 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h @@ -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. */ diff --git a/net/sctp/stream_interleave.c b/net/sctp/stream_interleave.c index b046b11200c9..840f24045ae2 100644 --- a/net/sctp/stream_interleave.c +++ b/net/sctp/stream_interleave.c @@ -1153,8 +1153,8 @@ static void sctp_generate_iftsn(struct sctp_outq *q, __u32 ctsn) } #define _sctp_walk_ifwdtsn(pos, chunk, end) \ - for (pos = chunk->subh.ifwdtsn_hdr->skip; \ - (void *)pos <= (void *)chunk->subh.ifwdtsn_hdr->skip + (end) - \ + for (pos = (void *)(chunk->subh.ifwdtsn_hdr + 1); \ + (void *)pos <= (void *)(chunk->subh.ifwdtsn_hdr + 1) + (end) - \ sizeof(struct sctp_ifwdtsn_skip); pos++) #define sctp_walk_ifwdtsn(pos, ch) \ From patchwork Wed Apr 19 15:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13217036 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F250BC77B7F for ; Wed, 19 Apr 2023 15:19:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233562AbjDSPTY (ORCPT ); Wed, 19 Apr 2023 11:19:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233550AbjDSPTR (ORCPT ); Wed, 19 Apr 2023 11:19:17 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF5025FE9; Wed, 19 Apr 2023 08:18:47 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id fg9so12446047qtb.1; Wed, 19 Apr 2023 08:18:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681917397; x=1684509397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fBOL+UsV1Rmf+Bmt1XKnavmQfuZMIoYDh5MH42mWVWs=; b=KjFbVhJE3IKOe1QR+uivEGZVljahqn4VshS1vRTvKdFy1KtbuZMhSulhMHD58EeZOR yQFf5QzfG6XhyLDkeGvcW9k7NymvxWMci06afnGE5jvWAdeAMyl7jnhxbVJiN6C+uupZ 4DLP+P3XKTf4f7H2XX84CfOzN68GqeuN7zsQbuO57Twr3hIvjHeRarVL7OsOz1VGwUml AhMLQdMjYQd9GZNnpGZGLzaI1XIwcOky6EjFbMvt3wtWRcJMBjFo8ZYKR21fj4slTmOU 5Qr2TLZ+ZfdOHHlMHnAWeWoERQXfXcta6PrvWGfc0z+zvLPCyBmZwd4WSRDMBww+wyZI jdVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681917397; x=1684509397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fBOL+UsV1Rmf+Bmt1XKnavmQfuZMIoYDh5MH42mWVWs=; b=OGkhqzMdKhYuGXtEc9gO6qH9RFyUeDlUyGCDcPsPbwW9fThCF26DEtIjdkGki0EWtZ OlJBnCmeKCjjWUgjAG/2Ec8vTE07KeMhxruiiUZ+lvjhv85SqDbcUMdhK7fWpF62I2TL x6BaUjBjQqwixXbkOToSFDKtQZE7AHdDkJp3BURDOzOfdx5JTG/Vfi83O4XcdxpFBVtX XoB1SsVQa2a0Ka+LRtqXCkNRuXGXcCRJ0NdBAAOYDH3eXU34j6fisP0fxXlDGIf9u++K HmvfUBHRzx2/byFIvyl8cVNXZrxThjcqXdZKrCJiKDek4Vukxl90+plG7NJoIdvRty4y nLMg== X-Gm-Message-State: AAQBX9dM5clPq1UeYDWcKZqwwVGGZdl5aHqC/dWlvKPVwsXsRDPdc6zh DnlBtpu9oRk8y/DU/n6PFJ8O0CfbbqUrCA== X-Google-Smtp-Source: AKy350alvPsrvd3vbZ46U2PcB6egpavaokgH1wa8cZgLfTivpgHYgmK/Stj6strdPZuvWc0tBqaGAg== X-Received: by 2002:a05:622a:1888:b0:3ef:37e3:cc64 with SMTP id v8-20020a05622a188800b003ef37e3cc64mr6884024qtc.3.1681917397528; Wed, 19 Apr 2023 08:16:37 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v11-20020a05620a0f0b00b007469b5bc2c4sm4753336qkl.13.2023.04.19.08.16.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 08:16:37 -0700 (PDT) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Marcelo Ricardo Leitner Subject: [PATCH net-next 3/6] sctp: delete the nested flexible array variable Date: Wed, 19 Apr 2023 11:16:30 -0400 Message-Id: <438e6a7c6f51a31babcd217793a7884903813c64.1681917361.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch deletes the flexible-array variable[] from the structure sctp_sackhdr and sctp_errhdr to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/sm_statefuns.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h): ./include/linux/sctp.h:451:28: warning: nested flexible array ./include/linux/sctp.h:393:29: warning: nested flexible array Signed-off-by: Xin Long --- include/linux/sctp.h | 4 ++-- net/sctp/outqueue.c | 11 +++++++---- net/sctp/sm_sideeffect.c | 3 +-- net/sctp/sm_statefuns.c | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 9815b801fec0..01a0eb7e9fa1 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -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 { diff --git a/net/sctp/outqueue.c b/net/sctp/outqueue.c index 20831079fb09..0dc6b8ab9963 100644 --- a/net/sctp/outqueue.c +++ b/net/sctp/outqueue.c @@ -1231,7 +1231,7 @@ static void sctp_sack_update_unack_data(struct sctp_association *assoc, unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1; - frags = sack->variable; + frags = (union sctp_sack_variable *)(sack + 1); for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) { unack_data -= ((ntohs(frags[i].gab.end) - ntohs(frags[i].gab.start) + 1)); @@ -1252,7 +1252,6 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk) struct sctp_transport *transport; struct sctp_chunk *tchunk = NULL; struct list_head *lchunk, *transport_list, *temp; - union sctp_sack_variable *frags = sack->variable; __u32 sack_ctsn, ctsn, tsn; __u32 highest_tsn, highest_new_tsn; __u32 sack_a_rwnd; @@ -1313,8 +1312,12 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk) /* Get the highest TSN in the sack. */ highest_tsn = sack_ctsn; - if (gap_ack_blocks) + if (gap_ack_blocks) { + union sctp_sack_variable *frags = + (union sctp_sack_variable *)(sack + 1); + highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end); + } if (TSN_lt(asoc->highest_sacked, highest_tsn)) asoc->highest_sacked = highest_tsn; @@ -1789,7 +1792,7 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn) * Block are assumed to have been received correctly. */ - frags = sack->variable; + frags = (union sctp_sack_variable *)(sack + 1); blocks = ntohs(sack->num_gap_ack_blocks); tsn_offset = tsn - ctsn; for (i = 0; i < blocks; ++i) { diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 463c4a58d2c3..7fbeb99d8d32 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c @@ -984,8 +984,7 @@ static void sctp_cmd_process_operr(struct sctp_cmd_seq *cmds, { struct sctp_chunkhdr *unk_chunk_hdr; - unk_chunk_hdr = (struct sctp_chunkhdr *) - err_hdr->variable; + unk_chunk_hdr = (struct sctp_chunkhdr *)(err_hdr + 1); switch (unk_chunk_hdr->type) { /* ADDIP 4.1 A9) If the peer responds to an ASCONF with * an ERROR chunk reporting that it did not recognized diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 39d416e7f795..8d0cfd689b20 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -1337,7 +1337,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa, * throughout the code today. */ errhdr = (struct sctp_errhdr *)buffer; - addrparm = (union sctp_addr_param *)errhdr->variable; + addrparm = (union sctp_addr_param *)(errhdr + 1); /* Copy into a parm format. */ len = af->to_addr_param(ssa, addrparm); From patchwork Wed Apr 19 15:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13217022 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F702C77B73 for ; Wed, 19 Apr 2023 15:19:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233345AbjDSPTE (ORCPT ); Wed, 19 Apr 2023 11:19:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232847AbjDSPTD (ORCPT ); Wed, 19 Apr 2023 11:19:03 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB3A89037; Wed, 19 Apr 2023 08:18:27 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id u37so8474763qtc.10; Wed, 19 Apr 2023 08:18:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681917398; x=1684509398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UL/KNEeyR1A4RYYeedrgo97igGODZqnW3SkGYg2Vrwo=; b=ddxGwC30RarItFP+nn0S7+8+u7X6Q/1ku1eFQbWZp7vNiMDKNOf83tL0qFd8h3eKL3 BANYoCsd7l/ozK60P/bMFpQWJ2SE/w0KI6Zx181ieX2aQl0GSyzEYRDJ31pZmO+ESm+Y vexZPPoPqwA8UdHN+tNlsQeGA83ifvvdyUvkJJ/4aA4esv+aa6dgAHP6OhYym7OCiHWM dRIscN/MATMIOexK2VTZ51C4zA/ZV0PooKWufJPbF2Tll9ZG7Ra1BijaAJqO54MHPFfy b5VGla+qs++qun3PJTfla6x9YKZEy7BaGtJ2OoniHBEELuFQoyUGKwYyAKvVX9DcSwuT ab1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681917398; x=1684509398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UL/KNEeyR1A4RYYeedrgo97igGODZqnW3SkGYg2Vrwo=; b=KI/3NBXX583eMLX7cU6PRE+Jq2bW8i7Y7ud1U0GBvl5gqof5lTmQ7qRKA90psXfXi7 Oe/Ut+taqG/fip/7e1hD/T1KYZOrEWPdJIcQpR3/o/+ZH3YGYj7YTQbThAM5EamOs+YL 7nIHOi/yNlDadVhJO7KdEONiJCkrxgCW1PqXzrPZhIg7f7XRqJstXEJQOmePMAgcpYKg u/HNY0q49eEujMCe78eWmhgpz3ALd8zuJ8r9rRtH1BL99W6Lz6R6t+dBKsdvzRqh4knB ve6QPuyHnuXZyCsAe2gR8YMgNm9D19CwlUChw+qacILS4cM0b3dMxyT6usJsuT5+Uue1 s+Iw== X-Gm-Message-State: AAQBX9fWrI0laaPWwfbTIA7HdxqfFHrFe60uns2TxkjjShhB/QPt//BC TJ40RozdXigGbnFXHQfhuoxdSb+M0Nir/Q== X-Google-Smtp-Source: AKy350YCtoqxK16MjwkwxtPD7y3QFYbtjeTNKy3J7CC+CGc6w+Xb2GqZfhKt7I61iimOpWO/lYa6kQ== X-Received: by 2002:ac8:5816:0:b0:3d7:b045:d38 with SMTP id g22-20020ac85816000000b003d7b0450d38mr7617158qtg.35.1681917398404; Wed, 19 Apr 2023 08:16:38 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v11-20020a05620a0f0b00b007469b5bc2c4sm4753336qkl.13.2023.04.19.08.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 08:16:38 -0700 (PDT) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Marcelo Ricardo Leitner Subject: [PATCH net-next 4/6] sctp: delete the nested flexible array peer_init Date: Wed, 19 Apr 2023 11:16:31 -0400 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch deletes the flexible-array peer_init[] from the structure sctp_cookie to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/sm_make_chunk.c: note: in included file (through include/net/sctp/sctp.h): ./include/net/sctp/structs.h:1588:28: warning: nested flexible array ./include/net/sctp/structs.h:343:28: warning: nested flexible array Signed-off-by: Xin Long --- include/net/sctp/structs.h | 2 +- net/sctp/associola.c | 5 +++-- net/sctp/sm_make_chunk.c | 4 ++-- net/sctp/sm_statefuns.c | 8 +++----- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 070c9458fff4..5c72d1864dd6 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h @@ -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[]; */ }; diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 63ba5551c13f..796529167e8d 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -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); diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 4dbbbc2a7742..08527d882e56 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c @@ -1707,11 +1707,11 @@ static struct sctp_cookie_param *sctp_pack_cookie( ktime_get_real()); /* Copy the peer's init packet. */ - memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr, + memcpy(cookie + 1, init_chunk->chunk_hdr, ntohs(init_chunk->chunk_hdr->length)); /* Copy the raw local address list of the association. */ - memcpy((__u8 *)&cookie->c.peer_init[0] + + memcpy((__u8 *)(cookie + 1) + ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len); if (sctp_sk(ep->base.sk)->hmac) { diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 8d0cfd689b20..7b8eb735fa88 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -794,8 +794,7 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, /* This is a brand-new association, so these are not yet side * effects--it is safe to run them here. */ - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; - + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); if (!sctp_process_init(new_asoc, chunk, &chunk->subh.cookie_hdr->c.peer_addr, peer_init, GFP_ATOMIC)) @@ -1869,8 +1868,7 @@ static enum sctp_disposition sctp_sf_do_dupcook_a( /* new_asoc is a brand-new association, so these are not yet * side effects--it is safe to run them here. */ - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; - + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, GFP_ATOMIC)) goto nomem; @@ -1990,7 +1988,7 @@ static enum sctp_disposition sctp_sf_do_dupcook_b( /* new_asoc is a brand-new association, so these are not yet * side effects--it is safe to run them here. */ - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, GFP_ATOMIC)) goto nomem; From patchwork Wed Apr 19 15:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13217038 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC128C77B73 for ; Wed, 19 Apr 2023 15:19:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233526AbjDSPTZ (ORCPT ); Wed, 19 Apr 2023 11:19:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233464AbjDSPTT (ORCPT ); Wed, 19 Apr 2023 11:19:19 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F5E4489; Wed, 19 Apr 2023 08:18:51 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id m21so22345430qtg.0; Wed, 19 Apr 2023 08:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681917418; x=1684509418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=i7bp3sdV7JAVhgQxmlbWl+vFysG/hec405GOyDsGjbQ=; b=GASRW55qbaZfVVXFxmYE/PT1hCZcxw73Ojq8A36359ZQ4rRajuaZeYHu7raJbibRoA E4B12PbOYxofoOqxjhErMCkTFSOjGJ+nMioXUo7Jr6C1EwZqXVoRSs4lJCMuuDHJv9Sy iJ3owTtV8Q57NNcoN0dAWxBTxlFtcMhnbea8LaJzu/S81+CLd/x1vYstgVeEfzpnreBv EwRW37ATYQHe7me/7+0EhqH6XiE3ZK0m9vf0LDRrNZUh1FEov+jjBA5jbw8mRsbhOO5o 2z4LleyztkYxjfBQZcUefgKAW+4RgKrQ7JN1945Bastl/Zkh+UNOwOBoct5yyJ/Nrfhw 52ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681917418; x=1684509418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=i7bp3sdV7JAVhgQxmlbWl+vFysG/hec405GOyDsGjbQ=; b=bWpvUWL1kOcQoe4TXcqYtWvhB7Y1rsaTlofFYuIucbv3ZFVUtCzfNjWuDSmD/dZT2p SwY0Otc2YGDf8T6Vsg5i2cWeWMCGJ2FnkYY214d9kPIFO7Ue5Y0tXVlpkEoVBnHzVCsd J4n8PS+Usf+0P/xAsnHkNZM2X+UeIazQHKaHDxWLDC+LwSWpA6AExfB9seCji2rKj56S xABfQLEJsXgy/aN4EKhZCwrHonnaarcgbEOX3ReeAL6SMpQwLwfwUypJOco3sN+G+/sB ESr9pt9IA0w6Fi2vpxMz3UweuwSaw9wa+qJkineCU4xYjNwtccDdDltMwrVSIR1clM3J OJcg== X-Gm-Message-State: AAQBX9fkHiNDsHAQzfXgv+RSAZ/trHf/ipXyeCvz0qca5NeRGY/LhQKI 3kO0aBwuk0mH51fLTcIHguc6o4IUSYQuTA== X-Google-Smtp-Source: AKy350aNKbpQ3sm5HcgzzeebHTIke4J+3KlEeOBXva/H3Us3/bbnOg8wbqmXCAfaBr24nDM5GntZ9w== X-Received: by 2002:a25:5945:0:b0:b8e:e032:b654 with SMTP id n66-20020a255945000000b00b8ee032b654mr22860086ybb.56.1681917399416; Wed, 19 Apr 2023 08:16:39 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v11-20020a05620a0f0b00b007469b5bc2c4sm4753336qkl.13.2023.04.19.08.16.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 08:16:39 -0700 (PDT) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Marcelo Ricardo Leitner Subject: [PATCH net-next 5/6] sctp: delete the nested flexible array hmac Date: Wed, 19 Apr 2023 11:16:32 -0400 Message-Id: <98dc440abe4cb430e3fa65385c1418572b151774.1681917361.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch deletes the flexible-array hmac[] from the structure sctp_authhdr to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/auth.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h): ./include/linux/sctp.h:735:29: warning: nested flexible array Signed-off-by: Xin Long --- include/linux/sctp.h | 2 +- net/sctp/auth.c | 2 +- net/sctp/sm_statefuns.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 01a0eb7e9fa1..d182e8c41985 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -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 { diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 34964145514e..c58fffc86a0c 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c @@ -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; diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 7b8eb735fa88..97f1155a2045 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c @@ -4391,7 +4391,7 @@ static enum sctp_ierror sctp_sf_authenticate( * 3. Compute the new digest * 4. Compare saved and new digests. */ - digest = auth_hdr->hmac; + digest = (u8 *)(auth_hdr + 1); skb_pull(chunk->skb, sig_len); save_digest = kmemdup(digest, sig_len, GFP_ATOMIC); From patchwork Wed Apr 19 15:16:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 13217024 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 053C9C77B73 for ; Wed, 19 Apr 2023 15:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233455AbjDSPTM (ORCPT ); Wed, 19 Apr 2023 11:19:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233449AbjDSPTI (ORCPT ); Wed, 19 Apr 2023 11:19:08 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63DB483F7; Wed, 19 Apr 2023 08:18:35 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id ff18so10916407qtb.13; Wed, 19 Apr 2023 08:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681917400; x=1684509400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3NzT/hpuNnryCcqzSUjen8isl1rZWNC+fIQh1MymFgo=; b=lvc3TyOZQkLu7RUX9PDBPh181gatDjN+TE9ZFR2eJYwmqG4mURsq1KTJ1Tj0QCq7K8 MepYov5UzrWK1YruY9KU49NrHYcJ0VCQ3vaDti/F5Gu6DGxPkI+6D4zkhjqadfH7j4mj 59WM1rPoLdbznUDsuw3nqsnELM2mrCbVvo/Tz6ZCN1l/FFjZXqMiYKp+8qTZI/daqVVG 9EO9h2UfmevoxxqmY3RkRxZ4D4HodLAtTGslkBqEIrZn8zGV1o5x9LgRKt9vCU47scIU TGjuPv/OWzM7qzBYclJxNpCDUgloKGKyw5C6BOuTVm6PLu3mkTN/aicPOi4nKwXkQK5A aFOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681917400; x=1684509400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3NzT/hpuNnryCcqzSUjen8isl1rZWNC+fIQh1MymFgo=; b=EQoroHysNGFY/zA6818ScAqGTt2c3pllIscLKQBAJb9okxTIQlSJmjRgF0tFCQrPmc WZxJ7BYSJmZwv/mFTghYMPvtWqCFeVIiVIJUj0X6jiLZZ+06KwzOIKn9OJk3lGTR69aV Yrb9DzqnSI49xnMJtSm2EA48sCilZKE4Lt8N5loS+ufZ5OiB0by32axqqsXkjYoTwFzy pydHtnPQr1+Wcdk6b9NyRwa4K+euo81QloDGFn5VCmlhWV7oekPJj4JEoF3w28XY9LlA VAIznhV7dBFcj8s77pXZkY1FxwZ+BQcesVxgsho/DDKusvRQfHqllZ8bCZcblB/W2NWZ wuoQ== X-Gm-Message-State: AAQBX9cIcIaw77hbwZyLExWcvkyQRBgIEl/3SVmrv+U3wy84jujlg1G4 qtoN5+zoT1QhlcE3cPjFdCit7irfeaqSWQ== X-Google-Smtp-Source: AKy350ZlfQixJ5eO1K9C6XWgyAnyKZduyo7kcHujkvd1ildzBYwQFjALxNRE9WoMi1DTYWqJQKU+Yw== X-Received: by 2002:ac8:5acb:0:b0:3ef:414e:fb6a with SMTP id d11-20020ac85acb000000b003ef414efb6amr5372187qtd.55.1681917400309; Wed, 19 Apr 2023 08:16:40 -0700 (PDT) Received: from wsfd-netdev15.ntdv.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id v11-20020a05620a0f0b00b007469b5bc2c4sm4753336qkl.13.2023.04.19.08.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 08:16:40 -0700 (PDT) From: Xin Long To: network dev , linux-sctp@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Marcelo Ricardo Leitner Subject: [PATCH net-next 6/6] sctp: delete the nested flexible array payload Date: Wed, 19 Apr 2023 11:16:33 -0400 Message-Id: <811ba34fc96b2ec46105af451be97cf87eb410f3.1681917361.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch deletes the flexible-array payload[] from the structure sctp_datahdr to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/socket.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h): ./include/linux/sctp.h:230:29: warning: nested flexible array This member is not even used anywhere. Signed-off-by: Xin Long --- include/linux/sctp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sctp.h b/include/linux/sctp.h index d182e8c41985..836a7e200f39 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h @@ -222,7 +222,7 @@ struct sctp_datahdr { __be16 stream; __be16 ssn; __u32 ppid; - __u8 payload[]; + /* __u8 payload[]; */ }; struct sctp_data_chunk {