diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-03-31 14:01:29 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-03-31 14:01:29 +0000 |
commit | 36216e9a9641b39c6716095e1f00c9f523b6c959 (patch) | |
tree | bae5d20fecd7b10dd395b9f367bcb0c4d510bf84 /sys/kern | |
parent | 85ba99673a1a61f19fe34c8d73f813e102afc5d1 (diff) |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_socket.c | 10 |
1 files changed, 9 insertions, 1 deletions
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)) |