Skip to content

Commit de31c39

Browse files
akodanevgregkh
authored andcommitted
dccp: check sk for closed state in dccp_sendmsg()
[ Upstream commit 67f93df ] dccp_disconnect() sets 'dp->dccps_hc_tx_ccid' tx handler to NULL, therefore if DCCP socket is disconnected and dccp_sendmsg() is called after it, it will cause a NULL pointer dereference in dccp_write_xmit(). This crash and the reproducer was reported by syzbot. Looks like it is reproduced if commit 69c6486 ("dccp: CVE-2017-8824: use-after-free in DCCP code") is applied. Reported-by: syzbot+f99ab3887ab65d70f816@syzkaller.appspotmail.com Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 51b4111 commit de31c39

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

net/dccp/proto.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,11 @@ int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
789789
if (skb == NULL)
790790
goto out_release;
791791

792+
if (sk->sk_state == DCCP_CLOSED) {
793+
rc = -ENOTCONN;
794+
goto out_discard;
795+
}
796+
792797
skb_reserve(skb, sk->sk_prot->max_header);
793798
rc = memcpy_from_msg(skb_put(skb, len), msg, len);
794799
if (rc != 0)

0 commit comments

Comments
 (0)