On Sat, Nov 28, 2026 at 10:11 AM <netd…@kernel.org> wrote:
>
> Thank you for your contribution! Sashiko AI review found 2 potential
> issue(s) to consider.
>
> Critical: 0 · High: 0 · Medium: 2 · Low: 0
>
> 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 patch makes data buffers exclusive only for GSO skbs, but
> the commit message's reason for doing so applies just as much to non-…
> - [Medium] sctp: short GSO frag_list segment read in sctp_inq_pop() after
> unshare
>
> --
>
> sctp: unshare GSO skb frag_list members instead of linearizing
>
> The patch stops linearizing SCTP GSO packets in sctp_rcv(). It adds
> sctp_gso_unshare(), which unclones the outer skb and takes exclusive
> ownership of each frag_list member, using pskb_copy() for shared members
> and skb_unclone() for the others. The stated goal is to keep data
> exclusive, so that sctp_sf_authenticate() can rewrite the HMAC digest in
> place without corrupting other readers.
>
> > diff --git a/net/sctp/input.c b/net/sctp/input.c
> > index 9494cfa51106c..89599fe4c2f1a 100644
> > --- a/net/sctp/input.c
> > +++ b/net/sctp/input.c
>
> [ ... ]
>
> > @@ -117,8 +153,14 @@ int sctp_rcv(struct sk_buff *skb)
> > * it's better to just linearize it otherwise crc computing
> > * takes longer.
> > */
> > - if (((!is_gso || skb_cloned(skb)) && skb_linearize(skb)) ||
> > - !pskb_may_pull(skb, sizeof(struct sctphdr)))
> > + if (!is_gso) {
> > + if (skb_linearize(skb))
> > + goto discard_it;
> > + } else if (sctp_gso_unshare(skb)) {
> > + goto discard_it;
> > + }
>
> [Severity: Medium]
> Can a trimmed trailing frag_list member end up being parsed as a
> chunk header with fewer than four valid bytes behind it?
>
> Both length checks in sctp_rcv() look only at the aggregate skb->len.
> One runs before the linearize/unshare step and the other after
> sk_filter(). Suppose ___pskb_trim() cuts a multi-segment GSO skb so
> that the last frag_list member keeps only 1 to 3 bytes. The total
> length still passes both checks, but that member cannot hold a struct
> sctp_chunkhdr.
>
> Before this patch, a cloned GSO skb in that state was linearized.
> sctp_inq_pop() only treats the remaining bytes as another chunk when
> chunk->chunk_end + sizeof(*ch) <= skb_tail_pointer(chunk->skb), so the
> short tail was ignored.
>
> Now the frag_list is kept. If the member was trimmed before
> sctp_gso_unshare() runs, pskb_copy() and skb_unclone() (through
> pskb_expand_head()) both allocate a new head and copy only up to the
> tail, which is p->len bytes. The bytes after that, up to
> sizeof(struct sctp_chunkhdr), are uninitialized.
>
> sctp_inq_pop() then moves on to that member with
> chunk->skb = chunk->skb->next and jumps to new_skb, which does:
>
> ch = (struct sctp_chunkhdr *)chunk->skb->data;
> ...
> chunk->chunk_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
> skb_pull(chunk->skb, sizeof(*ch));
>
> Nothing checks chunk->skb->len against sizeof(*ch) first, so a few
> things follow:
>
> - ch->length is read from the uninitialized part of the new buffer,
> which KMSAN would report.
>
> - skb_pull() returns NULL without advancing data.
>
> - If the chunk is then rejected for its length,
> sctp_make_abort_violation() copies chunk->chunk_hdr->length into the
> ABORT it sends. Two bytes of uninitialized heap go out on the wire,
> and the association is torn down.
>
> Trimming a shared or cloned GSO skb before sctp_rcv() needs
> CAP_NET_ADMIN in some namespace, for example tc, netfilter, or TEE
> combined with AF_PACKET.
>
> A socket filter attached with SO_ATTACH_FILTER can produce the same
> short member from sk_filter(). That happens after sctp_gso_unshare(),
> so the bytes past the tail are stale rather than uninitialized. The
> header read past the member's len is still there in that case.
>
> Should sctp_gso_unshare() drop a GSO skb whose frag_list members are
> shorter than sizeof(struct sctp_chunkhdr)? Or should sctp_inq_pop()
> check chunk->skb->len at new_skb and discard that segment? The second
> option would also cover a trim done by sk_filter() after the unshare.
>
I didn't expect BPF to change the SCTP GSO skb structure.
The similar issue is also reported on:
https://lore.kernel.org/netdev/2026…@mails.ucas.ac.cn/
I may drop a SCTP GSO skb if it ever pulled some data from the frag_list.
> [Severity: Medium]
> Can the non-GSO path still write into a shared data buffer? The commit
> message gives this reason for the change:
>
> "Data exclusivity matters because sctp_sf_authenticate() zeroes the
> digest and writes the computed HMAC in place; shared data would corrupt
> AF_PACKET readers or let a crafted packet pass AUTH on a second copy."
>
> On the !is_gso branch, only skb_linearize() runs. It returns 0 right away
> when !skb_is_nonlinear(skb). A cloned linear skb (dataref > 1) therefore
> reaches the AUTH handling still sharing its data with the other clone.
>
> Later, in sctp_sf_authenticate() in net/sctp/sm_statefuns.c:
>
> memset(digest, 0, sig_len);
>
> if (sctp_auth_calculate_hmac(asoc, chunk->skb,
> (struct sctp_auth_chunk *)chunk->chunk_hdr,
> sh_key, GFP_ATOMIC)) {
>
> sctp_auth_calculate_hmac() in net/sctp/auth.c then writes the computed
> HMAC to digest = (u8 *)(&auth->auth_hdr + 1). Both writes go into the
> shared data area.
>
> This state looks common on ingress. With an AF_PACKET tap active:
>
> __netif_receive_skb_core()->deliver_skb() (refcount_inc(&skb->users))
> packet_rcv() (skb_shared(skb), so it queues skb_clone(skb))
> ip_rcv()->...->sctp_rcv() (original arrives with cloned=1)
>
> A tc mirred mirror produces the same state through skb_clone().
>
> In that case, the AF_PACKET reader would see the digest field zeroed or
> replaced by the HMAC the receiver computed. If two clones of a forged
> packet reach the same association, the first fails AUTH but leaves a valid
> HMAC in the shared data, and the second one could pass.
>
> The non-GSO behaviour existed before this patch. Since the commit message
> gives this exact hazard as its reason, should the non-GSO branch also call
> skb_unclone(), or something equivalent, before AUTH can write in place?
>
A legit one, although it's a pre-existing issue for non-GSO packets.
I will address it together in the next post by moving skb_unclone() to
sctp_rcv().
Thanks.
pw-bot: cr