From 36216e9a9641b39c6716095e1f00c9f523b6c959 Mon Sep 17 00:00:00 2001 From: Vitaliy Makkoveev Date: Sun, 31 Mar 2024 14:01:29 +0000 Subject: 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 --- sys/kern/uipc_socket.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'sys/kern') 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)) -- cgit v1.2.3