Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 3
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The commit message understates what the new check does, and
the drop behaviour it chose has costs.
- [Low] The patch fixes a bug that a remote peer can trigger.
- [Low] The commit message gives 'RFC 9260, Section 12.4' as the
requirement for the new abort in sctp_sf_eat_sack_6_2()…
- [Low] The commit body is formatted as an email and would end up in git
history that way.
--
sctp: validate SACK gap-ack block ranges
This patch adds a check of the Gap Ack Blocks to sctp_sf_eat_sack_6_2(),
run before the SACK is queued for processing. A block with a zero start,
an inverted range, or a start at or below the previous block's end causes
the packet to be discarded. A block that ends past the last sent TSN
aborts the association.
> The patch validates Gap Ack Blocks before processing the SACK. It
> discards zero, inverted, overlapping, or out-of-order ranges. If a
> well-formed block acknowledges a TSN that has not been sent, the
> association is aborted as required by RFC 9260, Section 12.4.
[Severity: Low]
Is RFC 9260, Section 12.4 the right reference for this abort? As far as I
can tell, that section is "Protection of Non-SCTP-Capable Hosts" in the
Security Considerations. It doesn't seem to require an abort when a Gap
Ack Block acknowledges a TSN that hasn't been sent. I haven't been able to
check the RFC text directly, so this needs confirming.
SACKs that used to be tolerated now tear down the association with
ECONNABORTED. Could the commit message cite the normative text that
requires this? If that text is only a SHOULD or MAY, could the message
say so?
[ ... ]
> Apply the supplied fix.patch and rebuild the kernel:
>
> git -C linux apply --check sctp.patch
> git -C linux apply sctp.patch
[Severity: Low]
This isn't a bug, but the script downloads fix.patch and then applies
sctp.patch, so it won't work as written.
The commit body is also formatted as an email. It opens with "Hello," and
has "Thanks, Shawn Shao" after the Signed-off-by line, and both would end
up in git history. Could the greeting, the closing and the long
reproduction script move below the --- line, or be trimmed?
The tested version string "v7.3-23903-g7cd8495c0f162 (Linux 7.4.0-rc4)"
also looks inconsistent.
[ ... ]
> Signed-off-by: Shawn Shao <shaw…@163.com>
[Severity: Low]
Should this have a Fixes: tag? The unchecked subtraction being guarded
against dates back to the initial git import:
net/sctp/outqueue.c:sctp_sack_update_unack_data() {
...
for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) {
unack_data -= ((ntohs(frags[i].gab.end) -
ntohs(frags[i].gab.start) + 1));
}
...
}
sctp_outq_sack() has long assumed that the last block holds the highest
end, which the new ordering check now enforces:
highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end);
Something like this would help stable backporters pick up the fix:
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 6a4205de0aa69..79d297af661d4 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
[ ... ]
> @@ -3497,6 +3501,24 @@ enum sctp_disposition sctp_sf_eat_sack_6_2(struct net *net,
> return SCTP_DISPOSITION_DISCARD;
> }
>
> + /* Gap Ack Blocks must describe sent TSNs in ascending order. */
> + frags = (union sctp_sack_variable *)(sackh + 1);
> + num_blocks = ntohs(sackh->num_gap_ack_blocks);
> + max_offset = asoc->next_tsn - ctsn - 1;
> + for (i = 0; i < num_blocks; i++) {
> + start = ntohs(frags[i].gab.start);
> + end = ntohs(frags[i].gab.end);
> + if (!start || start > end || (i && start <= last_end))
> + return sctp_sf_pdiscard(net, ep, asoc, type, arg,
> + commands);
[Severity: Medium]
Should a single bad block discard the whole packet here?
sctp_sf_pdiscard() queues SCTP_CMD_DISCARD_PACKET, and
sctp_cmd_interpreter() handles that command by marking the entire packet:
net/sctp/sm_sideeffect.c:sctp_cmd_interpreter() {
...
case SCTP_CMD_DISCARD_PACKET:
/* We need to discard the whole packet.
* Uncork the queue since there might be
* responses pending
*/
chunk->pdiscard = 1;
...
}
After that, sctp_inq_peek() and sctp_inq_pop() stop returning the
remaining chunks of the packet:
net/sctp/inqueue.c:sctp_inq_peek() {
...
if (chunk->singleton ||
chunk->end_of_packet ||
chunk->pdiscard)
return NULL;
...
}
So SCTP_CMD_PROCESS_SACK is never queued, and the SACK's otherwise valid
Cumulative TSN Ack and a_rwnd are ignored. ctsn_ack_point doesn't
advance, the peer rwnd isn't updated, and the transmitted queue isn't
freed. Any DATA or control chunks bundled after the SACK in the same
packet are dropped too.
Suppose a peer always sends blocks in this form. Would its SACKs then
always be ignored? The cumulative ack would never move, and the
association would eventually fail on the T3-rtx retransmission limits.
Before this patch, sctp_check_transmitted() and sctp_acked() matched each
block on its own, so these SACKs were still processed.
The out-of-order cumulative ack check just above returns
SCTP_DISPOSITION_DISCARD, which drops only this chunk. Would that, or
skipping the bad block, fit better here?
The commit message says the patch "discards zero, inverted, overlapping,
or out-of-order ranges". In practice the whole packet is dropped. RFC
9260 Section 3.3.4 also seems to say only that Gap Ack Blocks SHOULD be
isolated. Is strict ascending, non-overlapping order actually required?
> + if (end > max_offset)
> + return sctp_sf_abort_violation(net, ep, asoc, chunk,
> + commands, err_str,
> + sizeof(err_str));
> +
> + last_end = end;
> + }
> +
> /* Return this SACK for further processing. */
> sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_SACK, SCTP_CHUNK(chunk));
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/1796…%40163.com