net: sctp: fix KMSAN uninit-value in sctp_inq_pop
Subsystems (3)
PATCH v2 1/1 net: sctp: fix KMSAN uninit-value in sctp_inq_pop
Fix an issue detected by syzbot:
KMSAN reported an uninitialized-value access in sctp_inq_pop
BUG: KMSAN: uninit-value in sctp_inq_pop
The issue is actually caused by skb trimming via sk_filter() in sctp_rcv(). In the reproducer, skb->len becomes 1 after sk_filter(), which bypassed the original check:
if (skb->len < sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr) +
skb_transport_offset(skb))To handle this safely, a new check should be performed after sk_filter().
---
KMSAN reported an uninitialized-value access in sctp_inq_pop
---
Changes in v2:
- changes in commit message as per the code changes.
- fixed as per the suggestion.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- net/sctp/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/input.c +1 -1
@@ -190,7 +190,7 @@ int sctp_rcv(struct sk_buff *skb) goto discard_release;nf_reset_ct (skb); -if (sk_filter (sk, skb)) +if (sk_filter (sk, skb) || skb->len <sizeof (struct sctp_chunkhdr )) goto discard_release;/* Create an SCTP packet structure. */
---
base-commit: 43e9ad0c55a369ecc84a4788d06a8a6bfa634f1c
change-id: 20251023-kmsan_fix-78d527b9960b
Best regards,
Signature · 1 line
Ranganath V N <[email protected]>
Quoted 12 lines · Ranganath V N
Fix an issue detected by syzbot:
KMSAN reported an uninitialized-value access in
sctp_inq_popBUG: KMSAN: uninit-value in sctp_inq_popThe issue is actually caused by skb trimming via
sk_filter()insctp_rcv(). In the reproducer,skb->lenbecomes 1 aftersk_filter(), which bypassed the original check:if (skb->len < sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr) + skb_transport_offset(skb))
Quoted 7 lines
To handle this safely, a new check should be performed after
sk_filter().Reported-by [email protected]Tested-by [email protected]Suggested-by Xin Long <[email protected]>Signed-off-by Ranganath V N <[email protected]>
Thanks for the follow up.
Simon Horman
reviewerQuoted 9 lines · Ranganath V N
Fix an issue detected by syzbot:
KMSAN reported an uninitialized-value access in
sctp_inq_popBUG: KMSAN: uninit-value in sctp_inq_popThe issue is actually caused by skb trimming via
sk_filter()insctp_rcv(). In the reproducer,skb->lenbecomes 1 aftersk_filter(), which bypassed the original check:
Quoted 7 lines
if (skb->len < sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr) + skb_transport_offset(skb))To handle this safely, a new check should be performed after
sk_filter().Reported-by [email protected]Tested-by [email protected]
Hi,
Thanks for your patch.
Unfortunately, this is not the correct format for a fixes tag. A fixes tag should reference the commit where the bug was introduced into the tree. In this case, perhaps that is the beginning of git history. If so:
I think the URL you provide is appropriate for a Closed tag.
See https://docs.kernel.org/process/submitting-patches.html
Quoted 9 lines
Suggested-by Xin Long <[email protected]>Signed-off-by Ranganath V N <[email protected]>---
KMSAN reported an uninitialized-value access insctp_inq_pop
---
Changes in v2:
- changes in commit message as per the code changes.
- fixed as per the suggestion.
- Link to v1: https://lore.kernel.org/r/[email protected]
...