diff options
author | Gvozden Neskovic <[email protected]> | 2016-08-31 10:12:08 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-09-29 15:55:41 -0700 |
commit | 031d7c2fe6afaa78943bd0a563b91fc84ace42d7 (patch) | |
tree | e30c20bc233c680f997e8b11948988c7e97f1c83 /lib/libspl | |
parent | 0b78aeae927833de580e140375a15ea5ea9d924a (diff) |
fix: Shift exponent too large
Undefined operation is reported by running ztest (or zloop) compiled with GCC
UndefinedBehaviorSanitizer. Error only happens on top level of dnode indirection
with large enough offset values. Logically, left shift operation would work,
but bit shift semantics in C, and limitation of uint64_t, do not produce desired
result.
Issue #5059, #4883
Signed-off-by: Gvozden Neskovic <[email protected]>
Diffstat (limited to 'lib/libspl')
-rw-r--r-- | lib/libspl/include/sys/sysmacros.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/libspl/include/sys/sysmacros.h b/lib/libspl/include/sys/sysmacros.h index c2525dd2a..f99b4d686 100644 --- a/lib/libspl/include/sys/sysmacros.h +++ b/lib/libspl/include/sys/sysmacros.h @@ -42,6 +42,9 @@ #ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof (a) / sizeof (a[0])) #endif +#ifndef DIV_ROUND_UP +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#endif #define makedevice(maj, min) makedev(maj, min) #define _sysconf(a) sysconf(a) |