aboutsummaryrefslogtreecommitdiffstats
path: root/testing/zfs-grsec/musl-fixes.patch
blob: 538274ee5ba64fb0c27c29124909557d5baf9154 (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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
diff -urw src/zfs-0.6.3/cmd/mount_zfs/Makefile.am src.new/cmd/mount_zfs/Makefile.am
--- src/zfs-0.6.3/cmd/mount_zfs/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/mount_zfs/Makefile.am	2014-09-13 18:40:03.625178898 +0000
@@ -19,4 +19,5 @@
 	$(top_builddir)/lib/libuutil/libuutil.la \
 	$(top_builddir)/lib/libzpool/libzpool.la \
 	$(top_builddir)/lib/libzfs/libzfs.la \
-	$(top_builddir)/lib/libzfs_core/libzfs_core.la
+	$(top_builddir)/lib/libzfs_core/libzfs_core.la \
+	$(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/cmd/mount_zfs/mount_zfs.c src.new/cmd/mount_zfs/mount_zfs.c
--- src/zfs-0.6.3/cmd/mount_zfs/mount_zfs.c	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/mount_zfs/mount_zfs.c	2014-09-13 18:40:03.625178898 +0000
@@ -31,6 +31,7 @@
 #include <sys/stat.h>
 #include <libzfs.h>
 #include <locale.h>
+#include <fcntl.h>
 
 libzfs_handle_t *g_zfs;
 
diff -urw src/zfs-0.6.3/cmd/zdb/Makefile.am src.new/cmd/zdb/Makefile.am
--- src/zfs-0.6.3/cmd/zdb/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zdb/Makefile.am	2014-09-13 18:40:03.679346705 +0000
@@ -17,4 +17,4 @@
 	$(top_builddir)/lib/libzfs/libzfs.la \
 	$(top_builddir)/lib/libzfs_core/libzfs_core.la
 
-zdb_LDADD += $(ZLIB)
+zdb_LDADD += $(ZLIB) $(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/cmd/zed/Makefile.am src.new/cmd/zed/Makefile.am
--- src/zfs-0.6.3/cmd/zed/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zed/Makefile.am	2014-09-13 18:40:03.585455839 +0000
@@ -26,7 +26,8 @@
 	$(top_builddir)/lib/libavl/libavl.la \
 	$(top_builddir)/lib/libnvpair/libnvpair.la \
 	$(top_builddir)/lib/libspl/libspl.la \
-	$(top_builddir)/lib/libzfs/libzfs.la
+	$(top_builddir)/lib/libzfs/libzfs.la \
+	$(TIRPC_LIBS)
 
 zedconfdir = $(sysconfdir)/zfs/zed.d
 
diff -urw src/zfs-0.6.3/cmd/zfs/Makefile.am src.new/cmd/zfs/Makefile.am
--- src/zfs-0.6.3/cmd/zfs/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zfs/Makefile.am	2014-09-13 18:40:03.701013827 +0000
@@ -19,5 +19,5 @@
 	$(top_builddir)/lib/libzfs/libzfs.la \
 	$(top_builddir)/lib/libzfs_core/libzfs_core.la
 
-zfs_LDADD += $(ZLIB)
+zfs_LDADD += $(ZLIB)  $(TIRPC_LIBS)
 zfs_LDFLAGS = -pthread
diff -urw src/zfs-0.6.3/cmd/zhack/Makefile.am src.new/cmd/zhack/Makefile.am
--- src/zfs-0.6.3/cmd/zhack/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zhack/Makefile.am	2014-09-13 18:40:03.679346705 +0000
@@ -16,4 +16,4 @@
 	$(top_builddir)/lib/libzfs/libzfs.la \
 	$(top_builddir)/lib/libzfs_core/libzfs_core.la
 
-zhack_LDADD += $(ZLIB)
+zhack_LDADD += $(ZLIB) $(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/cmd/zinject/Makefile.am src.new/cmd/zinject/Makefile.am
--- src/zfs-0.6.3/cmd/zinject/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zinject/Makefile.am	2014-09-13 18:40:03.679346705 +0000
@@ -16,4 +16,5 @@
 	$(top_builddir)/lib/libuutil/libuutil.la \
 	$(top_builddir)/lib/libzpool/libzpool.la \
 	$(top_builddir)/lib/libzfs/libzfs.la \
-	$(top_builddir)/lib/libzfs_core/libzfs_core.la
+	$(top_builddir)/lib/libzfs_core/libzfs_core.la \
+	$(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/cmd/zpool/Makefile.am src.new/cmd/zpool/Makefile.am
--- src/zfs-0.6.3/cmd/zpool/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zpool/Makefile.am	2014-09-13 18:40:03.679346705 +0000
@@ -19,4 +19,4 @@
 	$(top_builddir)/lib/libzpool/libzpool.la \
 	$(top_builddir)/lib/libzfs/libzfs.la \
 	$(top_builddir)/lib/libzfs_core/libzfs_core.la \
-	$(LIBBLKID)
+	$(LIBBLKID) $(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/cmd/zstreamdump/Makefile.am src.new/cmd/zstreamdump/Makefile.am
--- src/zfs-0.6.3/cmd/zstreamdump/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/zstreamdump/Makefile.am	2014-09-13 18:40:03.581844652 +0000
@@ -16,4 +16,4 @@
 	$(top_builddir)/lib/libzfs/libzfs.la \
 	$(top_builddir)/lib/libzfs_core/libzfs_core.la
 
-zstreamdump_LDADD += $(ZLIB)
+zstreamdump_LDADD += $(ZLIB) $(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/cmd/ztest/Makefile.am src.new/cmd/ztest/Makefile.am
--- src/zfs-0.6.3/cmd/ztest/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/cmd/ztest/Makefile.am	2014-09-13 18:40:03.679346705 +0000
@@ -18,4 +18,4 @@
 	$(top_builddir)/lib/libzfs/libzfs.la \
 	$(top_builddir)/lib/libzfs_core/libzfs_core.la
 
-ztest_LDADD += -lm -ldl
+ztest_LDADD += -lm -ldl $(TIRPC_LIBS)
diff -urw src/zfs-0.6.3/config/user.m4 src.new/config/user.m4
--- src/zfs-0.6.3/config/user.m4	2014-06-12 20:58:09.000000000 +0000
+++ src.new/config/user.m4	2014-09-13 18:40:03.766015196 +0000
@@ -13,6 +13,7 @@
 	ZFS_AC_CONFIG_USER_LIBBLKID
 	ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN
 	ZFS_AC_CONFIG_USER_RUNSTATEDIR
+	ZFS_AC_CONFIG_USER_MUSL
 dnl #
 dnl #	Checks for library functions
 	AC_CHECK_FUNCS([mlockall])
diff -urw src/zfs-0.6.3/include/sys/nvpair.h src.new/include/sys/nvpair.h
--- src/zfs-0.6.3/include/sys/nvpair.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/include/sys/nvpair.h	2014-09-13 18:40:03.802127067 +0000
@@ -132,7 +132,7 @@
 } nv_alloc_t;
 
 struct nv_alloc_ops {
-	int (*nv_ao_init)(nv_alloc_t *, __va_list);
+	int (*nv_ao_init)(nv_alloc_t *, va_list);
 	void (*nv_ao_fini)(nv_alloc_t *);
 	void *(*nv_ao_alloc)(nv_alloc_t *, size_t);
 	void (*nv_ao_free)(nv_alloc_t *, void *, size_t);
diff -urw src/zfs-0.6.3/include/sys/zfs_context.h src.new/include/sys/zfs_context.h
--- src/zfs-0.6.3/include/sys/zfs_context.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/include/sys/zfs_context.h	2014-09-13 18:40:03.809349441 +0000
@@ -118,6 +118,10 @@
 #include <sys/sunddi.h>
 #include <sys/debug.h>
 
+#ifndef RLIM64_INFINITY
+#define RLIM64_INFINITY (~0ULL)
+#endif 
+
 /*
  * Stack
  */
@@ -148,9 +152,9 @@
 extern void __dprintf(const char *file, const char *func,
     int line, const char *fmt, ...);
 extern void cmn_err(int, const char *, ...);
-extern void vcmn_err(int, const char *, __va_list);
+extern void vcmn_err(int, const char *, va_list);
 extern void panic(const char *, ...);
-extern void vpanic(const char *, __va_list);
+extern void vpanic(const char *, va_list);
 
 #define	fm_panic	panic
 
@@ -614,7 +618,11 @@
 #define	minclsyspri	60
 #define	maxclsyspri	99
 
+#ifdef HAVE_MUSL
+#define	CPU_SEQID	((uintptr_t)pthread_self() & (max_ncpus - 1))
+#else
 #define	CPU_SEQID	(pthread_self() & (max_ncpus - 1))
+#endif
 
 #define	kcred		NULL
 #define	CRED()		NULL
diff -urw src/zfs-0.6.3/lib/libnvpair/Makefile.am src.new/lib/libnvpair/Makefile.am
--- src/zfs-0.6.3/lib/libnvpair/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libnvpair/Makefile.am	2014-09-13 18:40:03.711847389 +0000
@@ -1,6 +1,6 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(TIRPC_CFLAGS)
 
 DEFAULT_INCLUDES += \
 	-I$(top_srcdir)/include \
diff -urw src/zfs-0.6.3/lib/libspl/Makefile.am src.new/lib/libspl/Makefile.am
--- src/zfs-0.6.3/lib/libspl/Makefile.am	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/Makefile.am	2014-09-13 18:40:03.722680950 +0000
@@ -1,12 +1,12 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(TIRPC_CFLAGS)
 
 SUBDIRS = include $(TARGET_ASM_DIR)
 DIST_SUBDIRS = include asm-generic asm-i386 asm-x86_64
 
 DEFAULT_INCLUDES += \
-	-I$(top_srcdir)/lib/libspl/include
+	-I$(top_srcdir)/lib/libspl/include $(TIRPC_CFLAGS)
 
 AM_CCASFLAGS = \
 	-I$(top_srcdir)/lib/libspl/include
@@ -30,4 +30,4 @@
 	$(top_srcdir)/lib/libspl/include/sys/list.h \
 	$(top_srcdir)/lib/libspl/include/sys/list_impl.h
 
-libspl_la_LIBADD = -lrt
+libspl_la_LIBADD = -lrt $(TIRPC_LDFLAGS)
diff -urw src/zfs-0.6.3/lib/libspl/include/assert.h src.new/lib/libspl/include/assert.h
--- src/zfs-0.6.3/lib/libspl/include/assert.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/assert.h	2014-09-13 18:40:03.755181634 +0000
@@ -42,6 +42,12 @@
 }
 #endif  /* __assert_c99 */
 
+#ifndef __assert
+#define __assert(expr, file, line) abort()
+#else
+extern void __assert(const char *, const char *, int);
+#endif
+
 #ifndef verify
 #if defined(__STDC__)
 #if __STDC_VERSION__ - 0 >= 199901L
@@ -61,8 +67,6 @@
 #define	VERIFY	verify
 #define	ASSERT	assert
 
-extern void __assert(const char *, const char *, int);
-
 /* BEGIN CSTYLED */
 #define	VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
 	const TYPE __left = (TYPE)(LEFT); \
diff -urw src/zfs-0.6.3/lib/libspl/include/devid.h src.new/lib/libspl/include/devid.h
--- src/zfs-0.6.3/lib/libspl/include/devid.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/devid.h	2014-09-13 18:40:03.722680950 +0000
@@ -28,6 +28,7 @@
 #define	_LIBSPL_DEVID_H
 
 #include <stdlib.h>
+#include <sys/types.h>
 
 typedef int ddi_devid_t;
 
diff -urw src/zfs-0.6.3/lib/libspl/include/rpc/xdr.h src.new/lib/libspl/include/rpc/xdr.h
--- src/zfs-0.6.3/lib/libspl/include/rpc/xdr.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/rpc/xdr.h	2014-09-13 18:40:03.737125699 +0000
@@ -60,6 +60,8 @@
 #define	XDR_RDMAGET	4
 #define	XDR_RDMASET	5
 
+#ifndef HAVE_TIRPC
 extern bool_t xdr_control(XDR *xdrs, int request, void *info);
+#endif
 
 #endif
diff -urw src/zfs-0.6.3/lib/libspl/include/sys/inttypes.h src.new/lib/libspl/include/sys/inttypes.h
--- src/zfs-0.6.3/lib/libspl/include/sys/inttypes.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/sys/inttypes.h	2014-09-13 18:40:03.751570447 +0000
@@ -31,4 +31,8 @@
 
 #define	_INT64_TYPE
 
+#ifndef RLIM64_INFINITY
+#define RLIM64_INFINITY		(~0ULL)
+#endif
+
 #endif
diff -urw src/zfs-0.6.3/lib/libspl/include/sys/param.h src.new/lib/libspl/include/sys/param.h
--- src/zfs-0.6.3/lib/libspl/include/sys/param.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/sys/param.h	2014-09-13 18:40:03.755181634 +0000
@@ -57,6 +57,12 @@
 #define	MAXUID		UINT32_MAX	/* max user id */
 #define	MAXPROJID	MAXUID		/* max project id */
 
-#define	PAGESIZE	(sysconf(_SC_PAGESIZE))
+#ifndef	PAGESIZE
+#define	PAGESIZE	PAGE_SIZE
+#endif
+
+#ifndef HZ
+#define HZ 100
+#endif
 
 #endif
diff -urw src/zfs-0.6.3/lib/libspl/include/sys/time.h src.new/lib/libspl/include/sys/time.h
--- src/zfs-0.6.3/lib/libspl/include/sys/time.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/sys/time.h	2014-09-13 18:40:03.755181634 +0000
@@ -58,6 +58,11 @@
 #define	NSEC2MSEC(n)    ((n) / (NANOSEC / MILLISEC))
 #endif
 
+#ifndef HAVE_HR_TYPES
+typedef long long	longlong_t;
+typedef longlong_t	hrtime_t;
+typedef struct timespec	timestruc_t;
+#endif
 extern hrtime_t gethrtime(void);
 extern void gethrestime(timestruc_t *);
 
diff -urw src/zfs-0.6.3/lib/libspl/include/sys/types.h src.new/lib/libspl/include/sys/types.h
--- src/zfs-0.6.3/lib/libspl/include/sys/types.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/sys/types.h	2014-09-13 18:40:03.751570447 +0000
@@ -30,7 +30,6 @@
 #include <sys/isa_defs.h>
 #include <sys/feature_tests.h>
 #include_next <sys/types.h>
-#include <sys/param.h> /* for NBBY */
 #include <sys/types32.h>
 #include <sys/va_list.h>
 
@@ -60,6 +59,7 @@
 typedef longlong_t	hrtime_t;
 typedef struct timespec	timestruc_t;
 typedef struct timespec timespec_t;
+#define HAVE_HR_TYPES
 
 typedef short		pri_t;
 
@@ -96,4 +96,6 @@
 } lloff_t;
 #endif
 
+#include <sys/param.h> /* for NBBY */
+
 #endif
diff -urw src/zfs-0.6.3/lib/libspl/include/sys/va_list.h src.new/lib/libspl/include/sys/va_list.h
--- src/zfs-0.6.3/lib/libspl/include/sys/va_list.h	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/include/sys/va_list.h	2014-09-13 18:40:03.751570447 +0000
@@ -29,8 +29,4 @@
 
 #include <stdarg.h>
 
-#ifndef __va_list
-typedef __gnuc_va_list __va_list;
-#endif
-
 #endif
diff -urw src/zfs-0.6.3/lib/libspl/timestamp.c src.new/lib/libspl/timestamp.c
--- src/zfs-0.6.3/lib/libspl/timestamp.c	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/timestamp.c	2014-09-13 18:40:03.722680950 +0000
@@ -28,6 +28,10 @@
 #include <langinfo.h>
 #include "statcommon.h"
 
+#ifndef _DATE_FMT
+#define _DATE_FMT "%+"
+#endif
+
 /*
  * Print timestamp as decimal reprentation of time_t value (-T u was specified)
  * or in date(1) format (-T d was specified).
diff -urw src/zfs-0.6.3/lib/libspl/xdr.c src.new/lib/libspl/xdr.c
--- src/zfs-0.6.3/lib/libspl/xdr.c	2014-06-12 20:58:09.000000000 +0000
+++ src.new/lib/libspl/xdr.c	2014-09-13 18:40:03.722680950 +0000
@@ -29,6 +29,7 @@
  * under license from the Regents of the University of California.
  */
 
+#ifndef HAVE_TIRPC
 #include <rpc/xdr.h>
 
 /*
@@ -76,3 +77,4 @@
 	}
 	return (FALSE);
 }
+#endif
diff -urw src/zfs-0.6.3/module/nvpair/nvpair.c src.new/module/nvpair/nvpair.c
--- src/zfs-0.6.3/module/nvpair/nvpair.c	2014-06-12 20:58:09.000000000 +0000
+++ src.new/module/nvpair/nvpair.c	2014-09-13 18:40:03.491564974 +0000
@@ -3251,8 +3251,12 @@
 			return (0);
 
 		/* sanity check the size parameter */
+#ifndef HAVE_TIRPC
 		if (!xdr_control(xdr, XDR_GET_BYTES_AVAIL, &bytesrec))
 			return (EFAULT);
+#else
+		xdr_control(xdr, XDR_GET_BYTES_AVAIL, &bytesrec);
+#endif
 
 		if (*size > NVS_XDR_MAX_LEN(bytesrec.xc_num_avail))
 			return (EFAULT);
diff -urw src/zfs-0.6.3/module/zcommon/zfs_uio.c src.new/module/zcommon/zfs_uio.c
--- src/zfs-0.6.3/module/zcommon/zfs_uio.c	2014-06-12 20:58:09.000000000 +0000
+++ src.new/module/zcommon/zfs_uio.c	2014-09-13 18:40:03.509620910 +0000
@@ -44,6 +44,7 @@
  */
 #ifdef _KERNEL
 
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/uio_impl.h>
 
diff --git a/config/musl.m4 b/config/musl.m4
new file mode 100644
index 0000000..fb4d2c4
--- /dev/null	2014-06-12 20:58:09.000000000 +0000
+++ src.new/config/musl.m4	2014-08-16 14:27:37.866666884 +0000
@@ -0,0 +1,19 @@
+dnl
+dnl musl support
+dnl
+
+AC_DEFUN([ZFS_AC_CONFIG_USER_MUSL], [
+AH_TEMPLATE([HAVE_MUSL],
+  [Define to 1 if musl is being used as the C library])
+AH_TEMPLATE([HAVE_TIRPC],
+  [Define to 1 if libtirpc is being used as the RPC library])
+AC_ARG_ENABLE(musl,
+AC_HELP_STRING([--enable-musl], [compile with musl as the C library]),
+[if test x$enableval = xyes; then
+  AC_DEFINE([HAVE_MUSL], 1, [Define if you have musl])
+  PKG_CHECK_MODULES([TIRPC],[libtirpc])
+  AC_DEFINE([HAVE_TIRPC], 1, [Define if you have libtirpc])
+  AC_SUBST(TIRPC_CFLAGS)
+  AC_SUBST(TIRPC_LIBS)
+fi])
+])