Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys timespec_to_timespec50 - don't leak kernel memory in str...
details: https://anonhg.NetBSD.org/src/rev/1ad162bdf0b1
branches: trunk
changeset: 833180:1ad162bdf0b1
user: uwe <uwe%NetBSD.org@localhost>
date: Thu Jun 14 10:30:55 2018 +0000
description:
timespec_to_timespec50 - don't leak kernel memory in struct padding.
On 64-bit machines struct timespec50 has padding between 32-bit tv_sec
and long tv_nsec that is not affected by normal assignment. Scrub it.
The result is most likely about to be passed to the user space by the
caller, so do it here to take care of them all.
diffstat:
sys/compat/sys/time_types.h | 5 ++++-
sys/dev/wscons/wsevent.c | 7 ++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diffs (47 lines):
diff -r b21874167d48 -r 1ad162bdf0b1 sys/compat/sys/time_types.h
--- a/sys/compat/sys/time_types.h Thu Jun 14 10:14:39 2018 +0000
+++ b/sys/compat/sys/time_types.h Thu Jun 14 10:30:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: time_types.h,v 1.1 2009/11/05 16:59:01 pooka Exp $ */
+/* $NetBSD: time_types.h,v 1.2 2018/06/14 10:30:55 uwe Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -89,6 +89,9 @@
static __inline void timespec_to_timespec50(const struct timespec *ts,
struct timespec50 *ts50)
{
+#if INT32_MAX < LONG_MAX /* scrub padding */
+ memset(ts50, 0, offsetof(struct timespec50, tv_nsec));
+#endif
ts50->tv_sec = (int32_t)ts->tv_sec;
ts50->tv_nsec = ts->tv_nsec;
}
diff -r b21874167d48 -r 1ad162bdf0b1 sys/dev/wscons/wsevent.c
--- a/sys/dev/wscons/wsevent.c Thu Jun 14 10:14:39 2018 +0000
+++ b/sys/dev/wscons/wsevent.c Thu Jun 14 10:30:55 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: wsevent.c,v 1.38 2018/06/13 02:09:09 uwe Exp $ */
+/* $NetBSD: wsevent.c,v 1.39 2018/06/14 10:30:55 uwe Exp $ */
/*-
* Copyright (c) 2006, 2008 The NetBSD Foundation, Inc.
@@ -104,7 +104,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.38 2018/06/13 02:09:09 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.39 2018/06/14 10:30:55 uwe Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -202,9 +202,6 @@
ev50.type = ev->type;
ev50.value = ev->value;
-#if INT32_MAX < LONG_MAX /* scrub padding */
- memset(&ev50.time, 0, offsetof(struct timespec50, tv_nsec));
-#endif
timespec_to_timespec50(&ev->time, &ev50.time);
error = uiomove(&ev50, sizeof(ev50), uio);
Home |
Main Index |
Thread Index |
Old Index