Module Name: src
Committed By: maxv
Date: Mon Apr 8 18:38:45 UTC 2019
Modified Files:
src/sys/kern: uipc_socket.c
Log Message:
Reset so_cred to NULL after freeing it, because close() may leave the PCB
in pcblist, and we don't want a future lookup (via eg netstat) to read
freed data.
Detected by KASAN, reported by Alexander Nasonov.
To generate a diff of this commit:
cvs rdiff -u -r1.272 -r1.273 src/sys/kern/uipc_socket.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/uipc_socket.c
diff -u src/sys/kern/uipc_socket.c:1.272 src/sys/kern/uipc_socket.c:1.273
--- src/sys/kern/uipc_socket.c:1.272 Sun Mar 31 19:54:36 2019
+++ src/sys/kern/uipc_socket.c Mon Apr 8 18:38:45 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: uipc_socket.c,v 1.272 2019/03/31 19:54:36 maxv Exp $ */
+/* $NetBSD: uipc_socket.c,v 1.273 2019/04/08 18:38:45 maxv Exp $ */
/*
* Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.272 2019/03/31 19:54:36 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.273 2019/04/08 18:38:45 maxv Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -749,6 +749,7 @@ soclose(struct socket *so)
discard:
KASSERT((so->so_state & SS_NOFDREF) == 0);
kauth_cred_free(so->so_cred);
+ so->so_cred = NULL;
so->so_state |= SS_NOFDREF;
sofree(so);
return error;