From: Andrew Deason Date: Mon, 2 Mar 2020 22:17:55 +0000 (-0600) Subject: LINUX: Avoid building rand-fortuna-kernel.o X-Git-Tag: openafs-devel-1_9_0~139 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=b8088b49dec23da19406fcb014e7100695dc8322 LINUX: Avoid building rand-fortuna-kernel.o Currently, we build rand-fortuna-kernel.o for libafs on all platforms, even though we only use the fortuna RNG on AIX, DragonFlyBSD, HP-UX, and Irix. Everywhere else, our RAND_bytes() in src/crypto/hcrypto/kernel/rand.c uses osi_readRandom() instead of going through heimdal. Building rand-fortuna.c causes occasional build headaches for the kernel on Linux (see cc7f942, "LINUX: Disable kernel fortuna large frame errors"). The most recent instance of this is that Linux 5.6 removes the definition for struct timeval, which is referenced in rand-fortuna.c. The Linux kernel is constantly changing, and so trying to keep rand-fortuna.c building on Linux seems like a waste of ongoing effort. So, just stop building rand-fortuna-kernel.o on Linux. The original intent of building this file on all platforms was to avoid bitrot, so still keep building rand-fortuna-kernel.o on all other platforms even when it's not used; just avoid it on Linux specifically, the platform that requires the most effort. To accomplish this, move rand-fortuna-kernel.o from AFSAOBJS to AFS_OS_OBJS, and remove it from the Linux-only AFSPAGOBJS. Also remove our configure tests for -Wno-error=frame-larger-than=, since they're no longer used by anything. Change-Id: I0d5f14f9f6ba2bdd7391391180d32383b4da89ed Reviewed-on: https://gerrit.openafs.org/14084 Reviewed-by: Cheyenne Wills Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/cf/linux-checks.m4 b/src/cf/linux-checks.m4 index 0fc9c4d..d4a6c97 100644 --- a/src/cf/linux-checks.m4 +++ b/src/cf/linux-checks.m4 @@ -51,8 +51,6 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*) OPENAFS_LINUX_KERNEL_PACKAGING_CHECKS OPENAFS_LINUX_KERNEL_SYSCALL_PROBE_CHECKS OPENAFS_LINUX_KERNEL_MORE_ASSORTED_CHECKS - - OPENAFS_GCC_SUPPORTS_WNO_ERROR_FRAME_LARGER_THAN fi OPENAFS_LINUX_MISC_DEFINES esac diff --git a/src/cf/linux-test5.m4 b/src/cf/linux-test5.m4 index da0d363..59bdbfc 100644 --- a/src/cf/linux-test5.m4 +++ b/src/cf/linux-test5.m4 @@ -86,24 +86,3 @@ AC_DEFUN([OPENAFS_GCC_SUPPORTS_PIPE], [ AS_IF([test x$openafs_cv_gcc_supports_pipe = xyes], [LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -pipe"]) ]) - -AC_DEFUN([OPENAFS_GCC_SUPPORTS_WNO_ERROR_FRAME_LARGER_THAN], [ - AC_CACHE_CHECK([if $CC supports -Wno-error=frame-larger-than=], - [openafs_cv_gcc_supports_wno_error_frame_larger_than], - [save_CFLAGS="$CFLAGS" - CFLAGS="-Wno-error=frame-larger-than=" - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[]], - [[int x;]])], - [openafs_cv_gcc_supports_wno_error_frame_larger_than=yes], - [openafs_cv_gcc_supports_wno_error_frame_larger_than=no]) - CFLAGS="$save_CFLAGS" - ]) - AS_IF([test x$openafs_cv_gcc_supports_wno_error_frame_larger_than = xyes && test x"$CFLAGS_NOERROR" != x], - dnl Only use -Wno-error=frame-larger-than= if gcc supports it, and if - dnl CFLAGS_NOERROR is nonempty (so if --enable-checking=all is used, we - dnl don't pass -Wno-error=frame-larger-than=) - [CFLAGS_WNOERROR_FRAME_LARGER_THAN="-Wno-error=frame-larger-than="]) - AC_SUBST([CFLAGS_WNOERROR_FRAME_LARGER_THAN]) -]) diff --git a/src/crypto/hcrypto/kernel/rand.c b/src/crypto/hcrypto/kernel/rand.c index 8106486..72cc418 100644 --- a/src/crypto/hcrypto/kernel/rand.c +++ b/src/crypto/hcrypto/kernel/rand.c @@ -15,6 +15,15 @@ */ afs_kmutex_t hckernel_mutex; +/* + * For these platforms, we use the fortuna RNG from heimdal (seeded from afsd + * userspace on startup). Otherwise, we rely on osi_readRandom() as the source + * of random data. + */ +#if defined(AFS_AIX_ENV) || defined(AFS_DFBSD_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SGI_ENV) +# define USE_FORTUNA +#endif + /* Called from osi_Init(); will only run once. */ void init_hckernel_mutex(void) @@ -25,8 +34,10 @@ init_hckernel_mutex(void) void RAND_seed(const void *indata, size_t size) { +#ifdef USE_FORTUNA const RAND_METHOD *m = RAND_fortuna_method(); m->seed(indata, size); +#endif } int @@ -34,7 +45,7 @@ RAND_bytes(void *outdata, size_t size) { if (size == 0) return 0; -#if defined(AFS_AIX_ENV) || defined(AFS_DFBSD_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SGI_ENV) +#ifdef USE_FORTUNA const RAND_METHOD *m = RAND_fortuna_method(); return m->bytes(outdata, size); #else diff --git a/src/libafs/Makefile.common.in b/src/libafs/Makefile.common.in index a72d394..1a958f1 100644 --- a/src/libafs/Makefile.common.in +++ b/src/libafs/Makefile.common.in @@ -68,7 +68,6 @@ depsrcs: AFSAOBJS = \ sha256-kernel.o \ - rand-fortuna-kernel.o \ rand-timer-kernel.o \ afs_atomlist.o \ afs_lhash.o \ @@ -212,7 +211,6 @@ AFSNONFSOBJS = \ # init daemons call pioctl AFSPAGOBJS = \ sha256-kernel.o \ - rand-fortuna-kernel.o \ rand-timer-kernel.o \ md5.o \ evp.o \ diff --git a/src/libafs/MakefileProto.AIX.in b/src/libafs/MakefileProto.AIX.in index 5c2b746..697ba7a 100644 --- a/src/libafs/MakefileProto.AIX.in +++ b/src/libafs/MakefileProto.AIX.in @@ -24,7 +24,8 @@ AFS_OS_OBJS = \ osi_sleep.o \ osi_timeout.o \ osi_vcache.o \ - osi_vm.o + osi_vm.o \ + rand-fortuna-kernel.o AFSNOIAUTHOBJS = \ afs_call.o \ diff --git a/src/libafs/MakefileProto.DARWIN.in b/src/libafs/MakefileProto.DARWIN.in index 0592913..fc09454 100644 --- a/src/libafs/MakefileProto.DARWIN.in +++ b/src/libafs/MakefileProto.DARWIN.in @@ -28,8 +28,8 @@ AFS_OS_OBJS = \ osi_vcache.o \ osi_vm.o \ osi_vnodeops.o \ - osi_module.o - + osi_module.o \ + rand-fortuna-kernel.o #AFS_OS_NFSOBJS = osi_vfsops_nfs.o diff --git a/src/libafs/MakefileProto.DFBSD.in b/src/libafs/MakefileProto.DFBSD.in index 41e1b51..9c06a50 100644 --- a/src/libafs/MakefileProto.DFBSD.in +++ b/src/libafs/MakefileProto.DFBSD.in @@ -20,7 +20,8 @@ AFS_OS_OBJS = \ osi_vcache.o \ osi_vm.o \ osi_vnodeops.o \ - osi_module.o + osi_module.o \ + rand-fortuna-kernel.o #AFS_OS_NFSOBJS = \ # osi_vfsops_nfs.o diff --git a/src/libafs/MakefileProto.FBSD.in b/src/libafs/MakefileProto.FBSD.in index 4cdec2d..ee34518 100644 --- a/src/libafs/MakefileProto.FBSD.in +++ b/src/libafs/MakefileProto.FBSD.in @@ -31,6 +31,9 @@ SRCS+= \ osi_vnodeops.c \ osi_module.c +AFS_OS_OBJS = \ + rand-fortuna-kernel.o + #AFS_OS_NFSOBJS = \ # osi_vfsops_nfs.o diff --git a/src/libafs/MakefileProto.HPUX.in b/src/libafs/MakefileProto.HPUX.in index 929884e..0925a3f 100644 --- a/src/libafs/MakefileProto.HPUX.in +++ b/src/libafs/MakefileProto.HPUX.in @@ -24,7 +24,8 @@ AFS_OS_OBJS = \ osi_sleep.o \ osi_vcache.o \ osi_vnodeops.o \ - osi_vm.o + osi_vm.o \ + rand-fortuna-kernel.o AFS_OS_NFSOBJS = \ diff --git a/src/libafs/MakefileProto.IRIX.in b/src/libafs/MakefileProto.IRIX.in index 310db13..4142b41 100644 --- a/src/libafs/MakefileProto.IRIX.in +++ b/src/libafs/MakefileProto.IRIX.in @@ -26,7 +26,8 @@ AFS_OS_OBJS = \ osi_sleep.o \ osi_vcache.o \ osi_vm.o \ - osi_vnodeops.o + osi_vnodeops.o \ + rand-fortuna-kernel.o AFS_OS_NFSOBJS = \ osi_vfsops_nfs.o diff --git a/src/libafs/MakefileProto.LINUX.in b/src/libafs/MakefileProto.LINUX.in index b64c993..7dd1f3b 100644 --- a/src/libafs/MakefileProto.LINUX.in +++ b/src/libafs/MakefileProto.LINUX.in @@ -82,7 +82,6 @@ CFLAGS_evp.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto \ -DHAVE_CONFIG_H CFLAGS_evp-algs.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto CFLAGS_evp-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto -CFLAGS_rand-fortuna-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto @CFLAGS_WNOERROR_FRAME_LARGER_THAN@ CFLAGS_rand-timer-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto CFLAGS_rand-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto CFLAGS_aes.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto diff --git a/src/libafs/MakefileProto.NBSD.in b/src/libafs/MakefileProto.NBSD.in index 892dea2..f166933 100644 --- a/src/libafs/MakefileProto.NBSD.in +++ b/src/libafs/MakefileProto.NBSD.in @@ -24,7 +24,8 @@ AFS_OS_OBJS = \ osi_sleep.o \ osi_vcache.o \ osi_vm.o \ - osi_vnodeops.o + osi_vnodeops.o \ + rand-fortuna-kernel.o AFS_OS_NFSOBJS = \ osi_vfsops_nfs.o diff --git a/src/libafs/MakefileProto.OBSD.in b/src/libafs/MakefileProto.OBSD.in index 3e3beaa..69871cc 100644 --- a/src/libafs/MakefileProto.OBSD.in +++ b/src/libafs/MakefileProto.OBSD.in @@ -44,7 +44,8 @@ AFS_OS_OBJS = \ osi_sleep.o \ osi_vcache.o \ osi_vm.o \ - osi_vnodeops.o + osi_vnodeops.o \ + rand-fortuna-kernel.o #AFS_OS_NFSOBJS = osi_vfsops_nfs.o diff --git a/src/libafs/MakefileProto.SOLARIS.in b/src/libafs/MakefileProto.SOLARIS.in index a3d102d..ca43664 100644 --- a/src/libafs/MakefileProto.SOLARIS.in +++ b/src/libafs/MakefileProto.SOLARIS.in @@ -26,7 +26,8 @@ AFS_OS_OBJS = \ osi_sleep.o \ osi_vcache.o \ osi_vm.o \ - osi_vnodeops.o + osi_vnodeops.o \ + rand-fortuna-kernel.o AFS_OS_NFSOBJS = \ osi_vfsops_nfs.o