Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern In unp_externalize, don't do anything if an SCM_RIG...
details: https://anonhg.NetBSD.org/src/rev/084869d0146a
branches: trunk
changeset: 788979:084869d0146a
user: drochner <drochner%NetBSD.org@localhost>
date: Thu Aug 01 19:33:21 2013 +0000
description:
In unp_externalize, don't do anything if an SCM_RIGHTS control message
was sent with zero file descriptors in it. Otherwise, a zero-length
temporary storage would be allocated which triggers panic on DIAGNOSTIC
kernels (but is harmless for release kernels).
reviewed by Taylor R Campbell
diffstat:
sys/kern/uipc_usrreq.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diffs (47 lines):
diff -r e78c6d8a632e -r 084869d0146a sys/kern/uipc_usrreq.c
--- a/sys/kern/uipc_usrreq.c Thu Aug 01 13:42:52 2013 +0000
+++ b/sys/kern/uipc_usrreq.c Thu Aug 01 19:33:21 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_usrreq.c,v 1.142 2013/06/27 18:54:31 christos Exp $ */
+/* $NetBSD: uipc_usrreq.c,v 1.143 2013/08/01 19:33:21 drochner Exp $ */
/*-
* Copyright (c) 1998, 2000, 2004, 2008, 2009 The NetBSD Foundation, Inc.
@@ -96,7 +96,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.142 2013/06/27 18:54:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_usrreq.c,v 1.143 2013/08/01 19:33:21 drochner Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1242,6 +1242,8 @@
const size_t nfds = (cm->cmsg_len - CMSG_ALIGN(sizeof(*cm))) /
sizeof(file_t *);
+ if (nfds == 0)
+ goto noop;
int * const fdp = kmem_alloc(nfds * sizeof(int), KM_SLEEP);
rw_enter(&p->p_cwdi->cwdi_lock, RW_READER);
@@ -1346,16 +1348,16 @@
cm->cmsg_len = CMSG_LEN(0);
rights->m_len = CMSG_SPACE(0);
}
+ rw_exit(&p->p_cwdi->cwdi_lock);
+ kmem_free(fdp, nfds * sizeof(int));
+ noop:
/*
* Don't disclose kernel memory in the alignment space.
*/
KASSERT(cm->cmsg_len <= rights->m_len);
memset(&mtod(rights, char *)[cm->cmsg_len], 0, rights->m_len -
cm->cmsg_len);
-
- rw_exit(&p->p_cwdi->cwdi_lock);
- kmem_free(fdp, nfds * sizeof(int));
return error;
}
Home |
Main Index |
Thread Index |
Old Index