Skip to content

Commit d8fa96c

Browse files
Sašo KiselkovChristopher Siden
Sašo Kiselkov
authored and
Christopher Siden
committed
3705 stack overflow due to zfs lz4 compression
Reviewed by: Matthew Ahrens <[email protected]> Approved by: Christopher Siden <[email protected]>
1 parent 4a92375 commit d8fa96c

File tree

1 file changed

+8
-15
lines changed
  • usr/src/uts/common/fs/zfs

1 file changed

+8
-15
lines changed

usr/src/uts/common/fs/zfs/lz4.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,17 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
197197
defined(__amd64) || defined(__ppc64__) || defined(_WIN64) || \
198198
defined(__LP64__) || defined(_LP64))
199199
#define LZ4_ARCH64 1
200-
/*
201-
* Illumos: On amd64 we have 20k of stack and 24k on sun4u and sun4v, so we
202-
* can spend 16k on the algorithm
203-
*/
204-
#define STACKLIMIT 12
205200
#else
206201
#define LZ4_ARCH64 0
202+
#endif
203+
207204
/*
208-
* Illumos: On i386 we only have 12k of stack, so in order to maintain the
209-
* same COMPRESSIONLEVEL we have to use heap allocation. Performance will
210-
* suck, but alas, it's ZFS on 32-bit we're talking about, so...
205+
* Limits the amount of stack space that the algorithm may consume to hold
206+
* the compression lookup table. The value `9' here means we'll never use
207+
* more than 2k of stack (see above for a description of COMPRESSIONLEVEL).
208+
* If more memory is needed, it is allocated from the heap.
211209
*/
212-
#define STACKLIMIT 11
213-
#endif
210+
#define STACKLIMIT 9
214211

215212
/*
216213
* Little Endian or Big Endian?
@@ -240,11 +237,7 @@ lz4_decompress(void *s_start, void *d_start, size_t s_len, size_t d_len, int n)
240237
#define LZ4_FORCE_UNALIGNED_ACCESS 1
241238
#endif
242239

243-
/*
244-
* Illumos: we can't use GCC's __builtin_ctz family of builtins in the
245-
* kernel
246-
*/
247-
#define LZ4_FORCE_SW_BITCOUNT
240+
/* #define LZ4_FORCE_SW_BITCOUNT */
248241

249242
/*
250243
* Compiler Options

0 commit comments

Comments
 (0)