Re: [PATCH] sctp: account stream padding length for reconf chunk
flat view
From: Eiichi Tsukata <hidden>
Date: 2021-10-12 00:17:40
Also in:
linux-sctp
Hi Marcelo
On Oct 11, 2021, at 22:15, Marcelo Ricardo Leitner [off-list ref] wrote:
...
So if stream_num was originally 1, stream_len would be 2, and with padding, 4. Here, nums would be 2 then, and not 1. The padding gets accounted as if it was payload. IOW, the patch is making the padding part of the parameter data by adding it to the header as well. SCTP padding works by having it in between them, and not inside them. This other approach avoids this issue by adding the padding only when allocating the packet. It (ab)uses the fact that inreq and outreq are already aligned to 4 bytes. Eiichi, can you please give it a go?
Thanks, I understood. I’ve tested your diff with my reproducer and it certainly works. Your diff looks good to me.
quoted hunk ↗ jump to hunk
---8<---diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index b8fa8f1a7277..c7503fd64915 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c@@ -3697,7 +3697,7 @@ struct sctp_chunk *sctp_make_strreset_req(outlen = (sizeof(outreq) + stream_len) * out; inlen = (sizeof(inreq) + stream_len) * in; - retval = sctp_make_reconf(asoc, outlen + inlen); + retval = sctp_make_reconf(asoc, SCTP_PAD4(outlen) + SCTP_PAD4(inlen)); if (!retval) return NULL;
Regards, Eiichi