Skip to contentSkip to conversation

sctp: fix null deref in sctp_sf_do_5_1D_ce()

PATCH In review Alexey Simakov 2 participants 2 messages Sep 22, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sctp: fix null deref in sctp_sf_do_5_1D_ce()

The check of new_asoc->peer.adaptation_ind can fail, leaving ai_ev uninitialized. In that case, the code can jump to the nomem_authdev label and later call sctp_ulpevent_free() with a null ai_ev pointer. Leading to a potential null dereference.

Add check of ai_ev pointer before call of
sctp_ulpevent_free function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 30f6ebf65bc4 ("sctp: add SCTP_AUTH_NO_AUTH type for AUTHENTICATION_EVENT")
---
 net/sctp/sm_statefuns.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/sm_statefuns.c +2 -1
index a0524ba8d787..93cac73472c7 100644
@@ -885,7 +885,8 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
        return SCTP_DISPOSITION_CONSUME;
 
 nomem_authev:
-       sctp_ulpevent_free(ai_ev);
+       if (ai_ev)
+               sctp_ulpevent_free(ai_ev);
 nomem_aiev:
        sctp_ulpevent_free(ev);
 nomem_ev:

--
2.34.1

Заявление о конфиденциальности

Данное электронное письмо и любые приложения к нему являются конфиденциальными и предназначены исключительно для адресата. Если Вы не являетесь адресатом данного письма, пожалуйста, уведомите немедленно отправителя, не раскрывайте содержание другим лицам, не используйте его в каких-либо целях, не храните и не копируйте информацию любым способом.

maintainer
#1 lore raw
Quoted 23 lines · Alexey Simakov

The check of new_asoc->peer.adaptation_ind can fail, leaving ai_ev uninitialized. In that case, the code can jump to the nomem_authdev label and later call sctp_ulpevent_free() with a null ai_ev pointer. Leading to a potential null dereference.

Add check of ai_ev pointer before call of
sctp_ulpevent_free function.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 30f6ebf65bc4 ("sctp: add SCTP_AUTH_NO_AUTH type for AUTHENTICATION_EVENT")
---
 net/sctp/sm_statefuns.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/sctp/sm_statefuns.c +0 -0
index a0524ba8d787..93cac73472c7 100644

net/sctp/sm_statefuns.c enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net, · line 889

Quoted 6 lines
net/sctp/sm_statefuns.c +2 -1
@@ -885,7 +885,8 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
        return SCTP_DISPOSITION_CONSUME;
 
 nomem_authev:
-       sctp_ulpevent_free(ai_ev);
+       if (ai_ev)
+               sctp_ulpevent_free(ai_ev);

The patch can not be applied. It seems these 3 lines start with spaces? You may run ./scripts/checkpatch.pl against it.

Thanks.

Quoted 9 lines
net/sctp/sm_statefuns.c +0 -1
 nomem_aiev:
        sctp_ulpevent_free(ev);
 nomem_ev:
--

2.34.1

Заявление о конфиденциальности

Данное электронное письмо и любые приложения к нему являются конфиденциальными и предназначены исключительно для адресата. Если Вы не являетесь адресатом данного письма, пожалуйста, уведомите немедленно отправителя, не раскрывайте содержание другим лицам, не используйте его в каких-либо целях, не храните и не копируйте информацию любым способом.