From: mvs Date: Sun, 31 Mar 2024 14:01:28 +0000 (+0000) Subject: Allow listen(2) only on sockets of type SOCK_STREAM or SOCK_SEQPACKET. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e679c1f37540f33b0f453b541fa1dec5a197c14a;p=openbsd Allow listen(2) only on sockets of type SOCK_STREAM or SOCK_SEQPACKET. listen(2) man(1) page clearly prohibits sockets of other types. Reported-by: syzbot+00450333592fcd38c6fe@syzkaller.appspotmail.com ok bluhm --- diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index a904ac02a83..35f75a014d9 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.324 2024/03/31 13:50:00 mvs Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.325 2024/03/31 14:01:28 mvs Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -233,6 +233,14 @@ solisten(struct socket *so, int backlog) int sominconn_local = READ_ONCE(sominconn); int error; + switch (so->so_type) { + case SOCK_STREAM: + case SOCK_SEQPACKET: + break; + default: + return (EOPNOTSUPP); + } + soassertlocked(so); if (so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING|SS_ISDISCONNECTING))