reiser4: use lzo library functions
PATCH 2/5 reiser4: use lzo library functions
Convert Reiser4 to use lzo implementation in lib/lzo/ instead of including its own copy of minilzo.
This fixes a security issue by switching to the _safe LZO decompression function and includes a small fix from Edward Shishkin.
Signed-off-by Richard Purdie <[email protected]>
--- fs/reiser4/Kconfig | 1 fs/reiser4/Makefile | 1 fs/reiser4/plugin/compress/Makefile | 1 fs/reiser4/plugin/compress/compress.c | 27 fs/reiser4/plugin/compress/lzoconf.h | 216 --- fs/reiser4/plugin/compress/minilzo.c | 1967 ---------------------------------- fs/reiser4/plugin/compress/minilzo.h | 70 - 7 files changed, 13 insertions(+), 2270 deletions(-)
fs/reiser4/Kconfig +1 -0
@@ -3,6 +3,7 @@ config REISER4_FS depends on EXPERIMENTAL select ZLIB_INFLATE select ZLIB_DEFLATE + select LZO select CRYPTO help Reiser4 is a filesystem that performs all filesystem operations
fs/reiser4/Makefile +0 -1
@@ -70,7 +70,6 @@ reiser4-y := \ plugin/crypto/cipher.o \ plugin/crypto/digest.o \ \ - plugin/compress/minilzo.o \ plugin/compress/compress.o \ plugin/compress/compress_mode.o \ \
fs/reiser4/plugin/compress/Makefile +0 -1
@@ -2,5 +2,4 @@ obj-$(CONFIG_REISER4_FS) += compress_plu compress_plugins-objs := \ compress.o \ - minilzo.o \ compress_mode.o
fs/reiser4/plugin/compress/compress.c +12 -15
@@ -4,8 +4,8 @@#include "../../debug.h" #include "../../inode.h" #include "../plugin.h" -#include "minilzo.h" +#include <linux/lzo.h> #include <linux/zlib.h> #include <linux/types.h> #include <linux/hardirq.h>
@@ -226,11 +226,7 @@ gzip1_decompress(coa_t coa, __u8 * src_fstatic int lzo1_init (void ) { -int ret; - ret =lzo_init (); -if (ret !=LZO_E_OK ) -warning ("edward-848" ,"lzo_init() failed with ret = %d\n" , ret); -return ret; +return 0 ; }static int lzo1_overrun (unsigned in_len)
@@ -238,9 +234,6 @@ static int lzo1_overrun(unsigned in_len)return in_len /64 +16 +3 ; } -#define LZO_HEAP_SIZE (size) \ - sizeof(lzo_align_t) * (((size) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t)) -static coa_t lzo1_alloc (tfm_action act) {int ret =0 ;
@@ -248,12 +241,12 @@ static coa_t lzo1_alloc(tfm_action act)switch (act) {case TFMA_WRITE :/* compress */ - coa =reiser4_vmalloc (LZO_HEAP_SIZE (LZO1X_1_MEM_COMPRESS )); + coa =reiser4_vmalloc (LZO1X_1_MEM_COMPRESS );if (!coa) { ret = -ENOMEM ;break ; } -memset (coa,0 ,LZO_HEAP_SIZE (LZO1X_1_MEM_COMPRESS )); +memset (coa,0 ,LZO1X_1_MEM_COMPRESS );case TFMA_READ :/* decompress */ break ;default :
@@ -295,20 +288,22 @@ static void lzo1_compress(coa_t coa, __u8 * src_first, unsigned src_len, __u8 * dst_first, unsigned *dst_len) { + unsigned long dstlen = *dst_len;int result;assert ("edward-846" , coa !=NULL );assert ("edward-847" , src_len !=0 ); - result =lzo1x_1_compress (src_first, src_len, dst_first, dst_len, coa); -if (result !=LZO_E_OK ) { + result =lzo1x_1_compress (src_first, src_len, dst_first, &dstlen, coa); +if (unlikely (result !=LZO_E_OK )) {warning ("edward-849" ,"lzo1x_1_compress failed\n" ); goto out; } -if (*dst_len >= src_len) { +if (dstlen >= src_len) {//warning("edward-850", "lzo1x_1_compress: incompressible data\n"); goto out; } + *dst_len = dstlen;return ; out: *dst_len = src_len;
@@ -319,14 +314,16 @@ static void lzo1_decompress(coa_t coa, __u8 * src_first, unsigned src_len, __u8 * dst_first, unsigned *dst_len) { + unsigned long dstlen = *dst_len;int result;assert ("edward-851" , coa ==NULL );assert ("edward-852" , src_len !=0 ); - result =lzo1x_decompress (src_first, src_len, dst_first, dst_len,NULL ); + result =lzo1x_decompress_safe (src_first, src_len, dst_first, &dstlen,NULL );if (result !=LZO_E_OK )warning ("edward-853" ,"lzo1x_1_decompress failed\n" ); + *dst_len = dstlen;return ; }
fs/reiser4/plugin/compress/lzoconf.h deleted +0 -216
216 lines not on this page · raw message
fs/reiser4/plugin/compress/minilzo.c deleted +0 -1967
1,967 lines not on this page · raw message
fs/reiser4/plugin/compress/minilzo.h deleted +0 -70
70 lines not on this page · raw message