aports/testing/zfs-grsec/musl-fixes.patch
2014-09-21 18:12:05 +02:00

408 lines
14 KiB
Diff

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])
+])