Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/netinet PR/48098: Brian Marcotte: Avoid kernel assertion...
details: https://anonhg.NetBSD.org/src/rev/ba5cbc3ee7a0
branches: trunk
changeset: 790363:ba5cbc3ee7a0
user: christos <christos%NetBSD.org@localhost>
date: Fri Oct 04 16:20:35 2013 +0000
description:
PR/48098: Brian Marcotte: Avoid kernel assertion for embryonic sockets that
don't have credentials yet.
XXX: pullup-6
diffstat:
sys/netinet/tcp_usrreq.c | 22 ++++++++++++----------
1 files changed, 12 insertions(+), 10 deletions(-)
diffs (47 lines):
diff -r 122c79e8c66c -r ba5cbc3ee7a0 sys/netinet/tcp_usrreq.c
--- a/sys/netinet/tcp_usrreq.c Fri Oct 04 15:24:44 2013 +0000
+++ b/sys/netinet/tcp_usrreq.c Fri Oct 04 16:20:35 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tcp_usrreq.c,v 1.167 2013/09/15 14:45:50 martin Exp $ */
+/* $NetBSD: tcp_usrreq.c,v 1.168 2013/10/04 16:20:35 christos Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -95,7 +95,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.167 2013/09/15 14:45:50 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_usrreq.c,v 1.168 2013/10/04 16:20:35 christos Exp $");
#include "opt_inet.h"
#include "opt_ipsec.h"
@@ -1164,18 +1164,20 @@
static inline int
copyout_uid(struct socket *sockp, void *oldp, size_t *oldlenp)
{
- size_t sz;
- int error;
- uid_t uid;
+ if (oldp) {
+ size_t sz;
+ uid_t uid;
+ int error;
- uid = kauth_cred_geteuid(sockp->so_cred);
- if (oldp) {
+ if (sockp->so_cred == NULL)
+ return EPERM;
+
+ uid = kauth_cred_geteuid(sockp->so_cred);
sz = MIN(sizeof(uid), *oldlenp);
- error = copyout(&uid, oldp, sz);
- if (error)
+ if ((error = copyout(&uid, oldp, sz)) != 0)
return error;
}
- *oldlenp = sizeof(uid);
+ *oldlenp = sizeof(uid_t);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index