]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
sctp: check asoc strreset_chunk in sctp_generate_reconf_event
authorXin Long <lucien.xin@gmail.com>
Wed, 20 Apr 2022 20:52:41 +0000 (16:52 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Jun 2022 12:22:49 +0000 (14:22 +0200)
commit4030602afc3581b9e603153cbdafa409c81b37c2
tree0308dc2ba07a1604c2b02ddd4fab3ebf79d5a161
parent6f565d4887bd4f70175172fde704216f329d0ccd
sctp: check asoc strreset_chunk in sctp_generate_reconf_event

BugLink: https://bugs.launchpad.net/bugs/1978234
[ Upstream commit 165e3e17fe8fe6a8aab319bc6e631a2e23b9a857 ]

A null pointer reference issue can be triggered when the response of a
stream reconf request arrives after the timer is triggered, such as:

  send Incoming SSN Reset Request --->
  CPU0:
   reconf timer is triggered,
   go to the handler code before hold sk lock
                            <--- reply with Outgoing SSN Reset Request
  CPU1:
   process Outgoing SSN Reset Request,
   and set asoc->strreset_chunk to NULL
  CPU0:
   continue the handler code, hold sk lock,
   and try to hold asoc->strreset_chunk, crash!

In Ying Xu's testing, the call trace is:

  [ ] BUG: kernel NULL pointer dereference, address: 0000000000000010
  [ ] RIP: 0010:sctp_chunk_hold+0xe/0x40 [sctp]
  [ ] Call Trace:
  [ ]  <IRQ>
  [ ]  sctp_sf_send_reconf+0x2c/0x100 [sctp]
  [ ]  sctp_do_sm+0xa4/0x220 [sctp]
  [ ]  sctp_generate_reconf_event+0xbd/0xe0 [sctp]
  [ ]  call_timer_fn+0x26/0x130

This patch is to fix it by returning from the timer handler if asoc
strreset_chunk is already set to NULL.

Fixes: 7b9438de0cd4 ("sctp: add stream reconf timer")
Reported-by: Ying Xu <yinxu@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/sctp/sm_sideeffect.c