summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2012-04-11 14:08:28 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2012-04-11 14:08:28 +0000
commita35c168fa1b9d49800920f96c7cfc1a779280c82 (patch)
tree5897f217ed6ed3dfce4692aff4b2987dbb4057c8 /sys/kern
parent81fc3d7b42a7d705fd1a219b16dacad1c917c80c (diff)
In sendmsg() permit at most 10% of maxfiles to be in-flight
during CMSG_DATA SCM_RIGHTS fd transfers. If this is exceeded, return EMFILE. ok claudio guenther gilles
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/uipc_usrreq.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index b7b26095106..4714a386c8e 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.55 2011/07/06 06:31:38 matthew Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.56 2012/04/11 14:08:27 deraadt Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -775,6 +775,9 @@ unp_internalize(struct mbuf *control, struct proc *p)
return (EINVAL);
nfds = (cm->cmsg_len - CMSG_ALIGN(sizeof(*cm))) / sizeof (int);
+ if (unp_rights + nfds > maxfiles / 10)
+ return (EMFILE);
+
/* Make sure we have room for the struct file pointers */
morespace:
neededspace = CMSG_SPACE(nfds * sizeof(struct file *)) -