Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add credentials to to sockets.
details: https://anonhg.NetBSD.org/src/rev/fde725791949
branches: trunk
changeset: 750373:fde725791949
user: elad <elad%NetBSD.org@localhost>
date: Tue Dec 29 04:23:43 2009 +0000
description:
Add credentials to to sockets.
We don't need any deferred free etc. because we no longer free the
credentials in interrupt context.
Tons of help from matt@, thanks!
diffstat:
sys/kern/uipc_socket.c | 6 ++++--
sys/kern/uipc_syscalls.c | 7 +++++--
sys/sys/socketvar.h | 3 ++-
3 files changed, 11 insertions(+), 5 deletions(-)
diffs (89 lines):
diff -r a39448782f1f -r fde725791949 sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c Tue Dec 29 03:48:18 2009 +0000
+++ b/sys/kern/uipc_socket.c Tue Dec 29 04:23:43 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.197 2009/12/29 03:48:18 elad Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.198 2009/12/29 04:23:43 elad Exp $ */
/*-
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.197 2009/12/29 03:48:18 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.198 2009/12/29 04:23:43 elad Exp $");
#include "opt_compat_netbsd.h"
#include "opt_sock_counters.h"
@@ -582,6 +582,7 @@
sofree(so);
return error;
}
+ so->so_cred = kauth_cred_dup(l->l_cred);
sounlock(so);
*aso = so;
return 0;
@@ -771,6 +772,7 @@
discard:
if (so->so_state & SS_NOFDREF)
panic("soclose: NOFDREF");
+ kauth_cred_free(so->so_cred);
so->so_state |= SS_NOFDREF;
sofree(so);
return (error);
diff -r a39448782f1f -r fde725791949 sys/kern/uipc_syscalls.c
--- a/sys/kern/uipc_syscalls.c Tue Dec 29 03:48:18 2009 +0000
+++ b/sys/kern/uipc_syscalls.c Tue Dec 29 04:23:43 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_syscalls.c,v 1.138 2009/12/20 09:36:06 dsl Exp $ */
+/* $NetBSD: uipc_syscalls.c,v 1.139 2009/12/29 04:23:43 elad Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.138 2009/12/20 09:36:06 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_syscalls.c,v 1.139 2009/12/29 04:23:43 elad Exp $");
#include "opt_pipe.h"
@@ -80,6 +80,7 @@
#include <sys/un.h>
#include <sys/ktrace.h>
#include <sys/event.h>
+#include <sys/kauth.h>
#include <sys/mount.h>
#include <sys/syscallargs.h>
@@ -228,9 +229,11 @@
fp2->f_ops = &socketops;
fp2->f_data = so2;
error = soaccept(so2, nam);
+ so2->so_cred = kauth_cred_dup(so->so_cred);
sounlock(so);
if (error) {
/* an error occurred, free the file descriptor and mbuf */
+ kauth_cred_free(so2->so_cred);
m_freem(nam);
mutex_enter(&fp2->f_lock);
fp2->f_count++;
diff -r a39448782f1f -r fde725791949 sys/sys/socketvar.h
--- a/sys/sys/socketvar.h Tue Dec 29 03:48:18 2009 +0000
+++ b/sys/sys/socketvar.h Tue Dec 29 04:23:43 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: socketvar.h,v 1.123 2009/12/20 09:36:06 dsl Exp $ */
+/* $NetBSD: socketvar.h,v 1.124 2009/12/29 04:23:43 elad Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -177,6 +177,7 @@
void *so_accept_filter_arg; /* saved filter args */
char *so_accept_filter_str; /* saved user args */
} *so_accf;
+ kauth_cred_t so_cred; /* socket credentials */
};
#define SB_EMPTY_FIXUP(sb) \
Home |
Main Index |
Thread Index |
Old Index