Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Move address hashing from init_main.c to kern_sysctl.c.
details: https://anonhg.NetBSD.org/src/rev/38ec39d17fa4
branches: trunk
changeset: 1013381:38ec39d17fa4
user: riastradh <riastradh%NetBSD.org@localhost>
date: Thu Aug 27 14:01:36 2020 +0000
description:
Move address hashing from init_main.c to kern_sysctl.c.
This way rump gets it automatically. Make sure blake2s is in
librumpkern.so, not just in librumpkern_crypto.so, for this to work.
diffstat:
sys/kern/init_main.c | 24 ++----------------------
sys/kern/kern_sysctl.c | 26 ++++++++++++++++++++++++--
sys/rump/kern/lib/libcrypto/Makefile | 6 +-----
sys/rump/librump/rumpkern/Makefile.rumpkern | 7 ++++++-
4 files changed, 33 insertions(+), 30 deletions(-)
diffs (163 lines):
diff -r a4d289b6c72c -r 38ec39d17fa4 sys/kern/init_main.c
--- a/sys/kern/init_main.c Thu Aug 27 14:00:01 2020 +0000
+++ b/sys/kern/init_main.c Thu Aug 27 14:01:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.528 2020/08/26 22:56:55 christos Exp $ */
+/* $NetBSD: init_main.c,v 1.529 2020/08/27 14:01:36 riastradh Exp $ */
/*-
* Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.528 2020/08/26 22:56:55 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.529 2020/08/27 14:01:36 riastradh Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@@ -228,8 +228,6 @@
#include <prop/proplib.h>
-#include <crypto/blake2/blake2s.h>
-
#include <sys/userconf.h>
extern struct lwp lwp0;
@@ -732,24 +730,6 @@
/* NOTREACHED */
}
-static uint8_t address_key[32]; /* key used in address hashing */
-static ONCE_DECL(random_inithook);
-
-static int
-random_address_init(void)
-{
- cprng_strong(kern_cprng, address_key, sizeof(address_key), 0);
- return 0;
-}
-
-void
-hash_value(void *d, size_t ds, const void *s, size_t ss)
-{
-
- RUN_ONCE(&random_inithook, random_address_init);
- blake2s(d, ds, address_key, sizeof(address_key), s, ss);
-}
-
/*
* Configure the system's hardware.
*/
diff -r a4d289b6c72c -r 38ec39d17fa4 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c Thu Aug 27 14:00:01 2020 +0000
+++ b/sys/kern/kern_sysctl.c Thu Aug 27 14:01:36 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.264 2019/07/03 17:31:32 maxv Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.265 2020/08/27 14:01:36 riastradh Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.264 2019/07/03 17:31:32 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.265 2020/08/27 14:01:36 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_defcorename.h"
@@ -84,11 +84,15 @@
#include <sys/ksyms.h>
#include <sys/malloc.h>
#include <sys/mount.h>
+#include <sys/cprng.h>
+#include <sys/once.h>
#include <sys/syscallargs.h>
#include <sys/kauth.h>
#include <sys/ktrace.h>
#include <sys/rndsource.h>
+#include <crypto/blake2/blake2s.h>
+
#define MAXDESCLEN 1024
MALLOC_DEFINE(M_SYSCTLNODE, "sysctlnode", "sysctl node structures");
MALLOC_DEFINE(M_SYSCTLDATA, "sysctldata", "misc sysctl data");
@@ -2816,3 +2820,21 @@
return (0);
}
+
+static uint8_t address_key[32]; /* key used in address hashing */
+static ONCE_DECL(random_inithook);
+
+static int
+random_address_init(void)
+{
+ cprng_strong(kern_cprng, address_key, sizeof(address_key), 0);
+ return 0;
+}
+
+void
+hash_value(void *d, size_t ds, const void *s, size_t ss)
+{
+
+ RUN_ONCE(&random_inithook, random_address_init);
+ blake2s(d, ds, address_key, sizeof(address_key), s, ss);
+}
diff -r a4d289b6c72c -r 38ec39d17fa4 sys/rump/kern/lib/libcrypto/Makefile
--- a/sys/rump/kern/lib/libcrypto/Makefile Thu Aug 27 14:00:01 2020 +0000
+++ b/sys/rump/kern/lib/libcrypto/Makefile Thu Aug 27 14:01:36 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.20 2020/08/26 15:49:56 riastradh Exp $
+# $NetBSD: Makefile,v 1.21 2020/08/27 14:01:36 riastradh Exp $
#
SODIUM_IMPORTDIR=${.CURDIR}/../../../../external/isc/libsodium
@@ -6,7 +6,6 @@
.PATH: ${.CURDIR}/../../../../crypto/adiantum \
${.CURDIR}/../../../../crypto/aes \
- ${.CURDIR}/../../../../crypto/blake2 \
${.CURDIR}/../../../../crypto/blowfish \
${.CURDIR}/../../../../crypto/camellia \
${.CURDIR}/../../../../crypto/cast128 \
@@ -57,9 +56,6 @@
# skipjack
SRCS+= skipjack.c
-# BLAKE2
-SRCS+= blake2s.c
-
# libsodium
SODIUM_CPPFLAGS+= -I${SODIUM_IMPORTDIR}/include
SODIUM_CPPFLAGS+= -I${SODIUM_IMPORTDIR}/dist/src/libsodium/include/sodium
diff -r a4d289b6c72c -r 38ec39d17fa4 sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern Thu Aug 27 14:00:01 2020 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern Thu Aug 27 14:01:36 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.rumpkern,v 1.185 2020/08/14 00:53:16 riastradh Exp $
+# $NetBSD: Makefile.rumpkern,v 1.186 2020/08/27 14:01:36 riastradh Exp $
#
IOCONFDIR:= ${.PARSEDIR}
@@ -16,6 +16,7 @@
${RUMPTOP}/../conf \
${RUMPTOP}/../dev \
${RUMPTOP}/../crypto/nist_hash_drbg \
+ ${RUMPTOP}/../crypto/blake2 \
${RUMPTOP}/../crypto/cprng_fast \
${RUMPTOP}/../crypto/chacha \
${RUMPTOP}/../secmodel \
@@ -162,6 +163,10 @@
SRCS+= chacha_ref.c
SRCS+= chacha_selftest.c
+# BLAKE2
+# for hash_address
+SRCS+= blake2s.c
+
.include "${RUMPTOP}/Makefile.rump"
.include <bsd.own.mk>
Home |
Main Index |
Thread Index |
Old Index