Добрый день.
Иногда при вызове данной функции compression_data примерно один раз из пяти, вылетает один и тотже Oops:
BUG: unable to handle kernel NULL pointer dereference at 00000177
IP: [<c02b4fe2>] rb_next+0x22/0x50
*pde = 00000000
Oops: 0000 [#1] SMP
EIP: 0060:[<c02b4fe2>] EFLAGS: 00210206 CPU: 0
EIP is at rb_next+0x22/0x50
EAX: 0000016f EBX: f2dce00c ECX: f2dce00c EDX: 0000016f
ESI: 00043000 EDI: f8415000 EBP: f3ef7c68 ESP: f3ef7c64
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
Stack:
00000001 f3ef7cb8 c01edbe0 f815ad9e 00000000 fe63800b 00000000 f2c2d680
<0> f2c2d680 f7bfe000 00000001 f7c40fff f7c41000 00000000 00042fff ffffffff
<0> c01ee1c8 00200246 f3eea520 f3eea520 00000001 f3ef7cec c01ee20f ff3fe000
Call Trace:
[<c01edbe0>] ? alloc_vmap_area+0x160/0x2d0
[<f7c40fff>] ? jbd2_journal_revoke+0x2f/0x100 [jbd2]
[<f7c41000>] ? jbd2_journal_revoke+0x30/0x100 [jbd2]
[<c01ee1c8>] ? __get_vm_area_node+0x78/0x1c0
[<c01ee20f>] ? __get_vm_area_node+0xbf/0x1c0
[<f80177fe>] ? zlib_compress_setup+0x5e/0x100 [zlib]
[<c01ee606>] ? __vmalloc_node+0x86/0xa0
[<f80177fe>] ? zlib_compress_setup+0x5e/0x100 [zlib]
[<c01ee900>] ? vmalloc+0x30/0x40
[<f80177fe>] ? zlib_compress_setup+0x5e/0x100 [zlib]
[<f80177fe>] ? zlib_compress_setup+0x5e/0x100 [zlib]
[<c028e996>] ? crypto_alloc_tfm+0x46/0x90
[<f81534c5>] ? compression_data+0xd5/0x1f0 [test_cypto] // моя функция
[<f80177a0>] ? zlib_compress_setup+0x0/0x100 [zlib]
[<c03a9fbb>] ? sock_aio_write+0x12b/0x140
[<c020835d>] ? do_sync_readv_writev+0x9d/0xe0
[<c01e2ba0>] ? __do_fault+0x3c0/0x4e0
[<c02085c2>] ? rw_verify_area+0x62/0xd0
[<c0208bb0>] ? rw_copy_check_uvector+0x80/0x100
[<c02092a0>] ? do_readv_writev+0xa0/0x190
[<c03a9e90>] ? sock_aio_write+0x0/0x140
[<c02093d5>] ? vfs_writev+0x45/0x60
[<c02094e2>] ? sys_writev+0x42/0xa0
[<c0456f84>] ? syscall_call+0x7/0xb
Code: 75 f7 5d c3 90 8d 74 26 00 55 89 c2 89 e5 53 8b 08 31 c0 89 cb 83 e3 fc 39 da 74 16 8b 42 04 85 c0 75 08 eb 18 8d 74 26 00 89 d0 <8b> 50 08 85 d2 75 f7 5b 5d c3 8d 74 26 00 8b 0b 89 da 89 cb 83
EIP: [<c02b4fe2>] rb_next+0x22/0x50 SS:ESP 0068:f3ef7c64
CR2: 0000000000000177
localhost kernel: ---[ end trace a7919e7f17c0a727 ]---
Вот код функции.
/*
data - сжимаемые данные
data_len - длина сжимаемых данных
result_buf - буфер для записи сжатых данных
result_buf_len - длина буфера для записи результата
*/
inline bool compression_data(char *data, int data_len, char *result_buf, int *result_buf_len)
{
struct pcomp_vec vec;
struct crypto_pcomp *tfm = NULL;
struct comp_request req;
/*Заполненяем структуру вектора */
vec.params = (void *)&deflate_comp_params;
vec.paramsize = sizeof(deflate_comp_params);
vec.inlen = data_len;
vec.outlen = *result_buf_len;
/* Выделение памяти под «struct crypto_tfm» */
tfm = crypto_alloc_pcomp(«zlib», 0, CRYPTO_ALG_TYPE_PCOMPRESS);
if (IS_ERR(tfm)) return 0;
/* Вот функция, в которой происходит ошибка */
crypto_compress_setup(tfm, vec.params, vec.paramsize); // Вызывается zlib_compress_setup
/* Сюда код не доходит */
/* .... */
}
Данные используемые в функции.
struct pcomp_vec
{
void *params;
unsigned int paramsize;
int inlen;
int outlen;
char *input_ptr;
};
static const struct a {
struct nlattr nla;
int val;
} deflate_decomp_params = {
.nla = {
.nla_len = NLA_HDRLEN + sizeof(int),
.nla_type = ZLIB_DECOMP_WINDOWBITS,
},
.val = -11,
};
static const struct {
struct nlattr nla;
int val;
} deflate_comp_params[] = {
{
.nla = {
.nla_len = NLA_HDRLEN + sizeof(int),
.nla_type = ZLIB_COMP_LEVEL,
},
.val = Z_DEFAULT_COMPRESSION,
}, {
.nla = {
.nla_len = NLA_HDRLEN + sizeof(int),
.nla_type = ZLIB_COMP_METHOD,
},
.val = Z_DEFLATED,
}, {
.nla = {
.nla_len = NLA_HDRLEN + sizeof(int),
.nla_type = ZLIB_COMP_WINDOWBITS,
},
.val = -11,
}, {
.nla = {
.nla_len = NLA_HDRLEN + sizeof(int),
.nla_type = ZLIB_COMP_MEMLEVEL,
},
.val = MAX_MEM_LEVEL,
}, {
.nla = {
.nla_len = NLA_HDRLEN + sizeof(int),
.nla_type = ZLIB_COMP_STRATEGY,
},
.val = Z_DEFAULT_STRATEGY,
}
};
Пробовал вызывать данную функцию так
lock_kernel();
compression_data(data, data_len, result_buf, &result_buf_len);
unlock_kernel();
Не помогает...
Что делать??? никак не могу этот баг исправить.
Спасибо.