Module Name:    src
Committed By:   chs
Date:           Tue Aug  3 20:27:08 UTC 2021

Modified Files:
        src/sys/kern: uipc_socket.c

Log Message:
in sbsavetimestamp(), initialize struct timeval to 0 with memset() so that
the implicit padding is initialized.  this avoids later copying uninitialized
memory out to user space.  detected by KMSAN.


To generate a diff of this commit:
cvs rdiff -u -r1.294 -r1.295 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.294 src/sys/kern/uipc_socket.c:1.295
--- src/sys/kern/uipc_socket.c:1.294	Fri Dec 11 03:00:09 2020
+++ src/sys/kern/uipc_socket.c	Tue Aug  3 20:27:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uipc_socket.c,v 1.294 2020/12/11 03:00:09 thorpej Exp $	*/
+/*	$NetBSD: uipc_socket.c,v 1.295 2021/08/03 20:27:08 chs 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.294 2020/12/11 03:00:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.295 2021/08/03 20:27:08 chs Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2432,6 +2432,7 @@ sbsavetimestamp(int opt, struct mbuf **m
 	struct timeval tv;
 	int error;
 
+	memset(&tv, 0, sizeof(tv));
 	microtime(&tv);
 
 	MODULE_HOOK_CALL(uipc_socket_50_sbts_hook, (opt, &mp), enosys(), error);

Reply via email to