Skip to content

Commit 636d25d

Browse files
lxindavem330
authored andcommitted
sctp: not copy sctp_sock pd_lobby in sctp_copy_descendant
Now sctp_copy_descendant() copies pd_lobby from old sctp scok to new sctp sock. If sctp_sock_migrate() returns error, it will panic when releasing new sock and trying to purge pd_lobby due to the incorrect pointers in pd_lobby. [ 120.485116] kasan: CONFIG_KASAN_INLINE enabled [ 120.486270] kasan: GPF could be caused by NULL-ptr deref or user [ 120.509901] Call Trace: [ 120.510443] sctp_ulpevent_free+0x1e8/0x490 [sctp] [ 120.511438] sctp_queue_purge_ulpevents+0x97/0xe0 [sctp] [ 120.512535] sctp_close+0x13a/0x700 [sctp] [ 120.517483] inet_release+0xdc/0x1c0 [ 120.518215] __sock_release+0x1d2/0x2a0 [ 120.519025] sctp_do_peeloff+0x30f/0x3c0 [sctp] We fix it by not copying sctp_sock pd_lobby in sctp_copy_descendan(), and skb_queue_head_init() can also be removed in sctp_sock_migrate(). Reported-by: syzbot+85e0b422ff140b03672a@syzkaller.appspotmail.com Fixes: 89664c6 ("sctp: sctp_sock_migrate() returns error if sctp_bind_addr_dup() fails") Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 273160f commit 636d25d

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

net/sctp/socket.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9169,7 +9169,7 @@ static inline void sctp_copy_descendant(struct sock *sk_to,
91699169
{
91709170
int ancestor_size = sizeof(struct inet_sock) +
91719171
sizeof(struct sctp_sock) -
9172-
offsetof(struct sctp_sock, auto_asconf_list);
9172+
offsetof(struct sctp_sock, pd_lobby);
91739173

91749174
if (sk_from->sk_family == PF_INET6)
91759175
ancestor_size += sizeof(struct ipv6_pinfo);
@@ -9253,7 +9253,6 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
92539253
* 2) Peeling off partial delivery; keep pd_lobby in new pd_lobby.
92549254
* 3) Peeling off non-partial delivery; move pd_lobby to receive_queue.
92559255
*/
9256-
skb_queue_head_init(&newsp->pd_lobby);
92579256
atomic_set(&sctp_sk(newsk)->pd_mode, assoc->ulpq.pd_mode);
92589257

92599258
if (atomic_read(&sctp_sk(oldsk)->pd_mode)) {

0 commit comments

Comments
 (0)