summarylogtreecommitdiffstats
path: root/0001-LINUX-Avoid-building-rand-fortuna-kernel.o.patch
blob: e4a2acad244bdc3b13f108b558a7de645f2e816f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
From 355ea43f0d1b7feae1b3af58bc33af12838db7c3 Mon Sep 17 00:00:00 2001
From: Andrew Deason <adeason@sinenomine.net>
Date: Mon, 2 Mar 2020 16:17:55 -0600
Subject: [PATCH 1/5] 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.

[1.8.x: The 1.8 branch does not contain the commits that introduced
-Wno-error=frame-larger-than= (cc7f942a and 54150f38), so we can skip
removing the references to -Wno-error=frame-larger-than=.]

Reviewed-on: https://gerrit.openafs.org/14084
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
(cherry picked from commit b8088b49dec23da19406fcb014e7100695dc8322)

Change-Id: Iad0d1af5ffd79c576ddbc253b0037b9772187350
Reviewed-on: https://gerrit.openafs.org/14094
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
---
 src/crypto/hcrypto/kernel/rand.c    | 13 ++++++++++++-
 src/libafs/Makefile.common.in       |  2 --
 src/libafs/MakefileProto.AIX.in     |  3 ++-
 src/libafs/MakefileProto.DARWIN.in  |  4 ++--
 src/libafs/MakefileProto.DFBSD.in   |  3 ++-
 src/libafs/MakefileProto.FBSD.in    |  3 +++
 src/libafs/MakefileProto.HPUX.in    |  3 ++-
 src/libafs/MakefileProto.IRIX.in    |  3 ++-
 src/libafs/MakefileProto.LINUX.in   |  1 -
 src/libafs/MakefileProto.NBSD.in    |  3 ++-
 src/libafs/MakefileProto.OBSD.in    |  3 ++-
 src/libafs/MakefileProto.SOLARIS.in |  3 ++-
 12 files changed, 31 insertions(+), 13 deletions(-)

diff --git a/src/crypto/hcrypto/kernel/rand.c b/src/crypto/hcrypto/kernel/rand.c
index 81064863b..72cc41877 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 0b8505a0f..b4e00166a 100644
--- a/src/libafs/Makefile.common.in
+++ b/src/libafs/Makefile.common.in
@@ -72,7 +72,6 @@ depsrcs:
 
 AFSAOBJS = \
 	sha256-kernel.o \
-	rand-fortuna-kernel.o \
 	rand-timer-kernel.o \
 	afs_atomlist.o \
 	afs_lhash.o \
@@ -217,7 +216,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 5c2b7467c..697ba7aa9 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 0592913c1..fc0945480 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 41e1b5140..9c06a50a7 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 4c3c0cd8e..e0616afad 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 929884e23..0925a3f96 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 = \
 <ia64_hpux1123 hp_ux1123>
diff --git a/src/libafs/MakefileProto.IRIX.in b/src/libafs/MakefileProto.IRIX.in
index 310db13fb..4142b413f 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 ed687f1ec..d98fa05ad 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_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 892dea2e9..f1669339e 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 3e3beaae7..69871cc37 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 602fed543..5d7e07037 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
-- 
2.26.0