diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2018-11-12 06:35:38 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2018-11-12 06:35:38 +0000 |
commit | 850d36efb2ae248d4c7415508dac8f62dcc93a7b (patch) | |
tree | 4a917862bf370c442da9334ef15d5e8076ac990c /sys | |
parent | 1c0d8783e27e3532c99a15f2704a280fe5b77415 (diff) |
limit the number of interface units to the number of device minors
this prevents creation of tap and tun devices that you cannot open
from userland because of the limit on the number of dev_t minor
numbers.
the lack of limit was pointed out by Greg Steuck
ok deraadt@ guenther@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_tun.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 33f97655d53..e08bb61a52d 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.181 2018/02/24 07:20:04 dlg Exp $ */ +/* $OpenBSD: if_tun.c,v 1.182 2018/11/12 06:35:37 dlg Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -193,6 +193,9 @@ tun_create(struct if_clone *ifc, int unit, int flags) struct tun_softc *tp; struct ifnet *ifp; + if (unit > minor(~0U)) + return (ENXIO); + tp = malloc(sizeof(*tp), M_DEVBUF, M_WAITOK|M_ZERO); tp->tun_unit = unit; tp->tun_flags = TUN_INITED|TUN_STAYUP; |