]> git.baikalelectronics.ru Git - kernel.git/commit
sctp: set stream ext to NULL after freeing it in sctp_stream_outq_migrate
authorXin Long <lucien.xin@gmail.com>
Tue, 12 Feb 2019 10:51:01 +0000 (18:51 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 14 Feb 2019 00:33:44 +0000 (19:33 -0500)
commit59d5c6a338c2974ab5043b8c76761295d65f0f21
tree2e01aba5c4306cb8f617ef4deb583824c021d7a8
parent1ff07d498c8ed512d9869693b5340e9f73235448
sctp: set stream ext to NULL after freeing it in sctp_stream_outq_migrate

In sctp_stream_init(), after sctp_stream_outq_migrate() freed the
surplus streams' ext, but sctp_stream_alloc_out() returns -ENOMEM,
stream->outcnt will not be set to 'outcnt'.

With the bigger value on stream->outcnt, when closing the assoc and
freeing its streams, the ext of those surplus streams will be freed
again since those stream exts were not set to NULL after freeing in
sctp_stream_outq_migrate(). Then the invalid-free issue reported by
syzbot would be triggered.

We fix it by simply setting them to NULL after freeing.

Fixes: d5f9a5945926 ("sctp: introduce stream scheduler foundations")
Reported-by: syzbot+58e480e7b28f2d890bfd@syzkaller.appspotmail.com
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sctp/stream.c