Commit graph

147 commits

Author SHA1 Message Date
Török Edvin
8a8dbd59ea bytecode test mode: collect & diff events for JIT and interpreter.
If execution is different for JIT and interpreter test mode shows error.
2010-10-18 10:48:14 +03:00
Török Edvin
f1ea72ae5b Fix memory leak in runlsig (bb #2291). 2010-09-28 13:06:14 +03:00
Török Edvin
93e0033fb2 Avoid 'line too long for provided buffer'.
This time it was just a message that didn't prevent the DB to be loaded.
Silence it though by using at least a 4k buffer always.
2010-09-11 16:29:21 +03:00
Török Edvin
f73212dc62 Fix bytecode virusname reporting (bb #2255).
Also adds possibility to stop a hook from executing, and set
a virus as heuristic (by using BC.Heuristic* name)
2010-09-10 22:11:32 +03:00
Török Edvin
fcbfb1c6ee Properly skip bytecodes with long lines.
Prevent 'Line too long for provided buffer'.
We must skip using a buffer of length declared in cbc header, not 4096.
So perform the skip in bytecode.c rather than readdb.c (which doesn't know the
length). The skip in readdb.c is good for skipping the source code, so keep it.
2010-09-09 12:30:59 +03:00
Török Edvin
71ca3536c4 Fix hung clamd on FreeBSD (bb #2235).
bytecode selfcheck running under JIT ran too early, and spawned a thread.
Then clamd forked. threads + fork = bad idea.
So prevent the thread from being spawned in selfcheck mode.
So at the time of fork clamd will still be single threaded as in 0.96.1.
2010-09-02 21:24:20 +03:00
Török Edvin
4abbeb3a6c Sync headers with bytecode compiler. 2010-09-02 18:04:00 +03:00
Török Edvin
540fc128a0 freshclam is using private symbol that changed proto (bb #2187).
Change name to prevent crash with 0.96.1 freshclam and 0.96.2 libclamav.
You'll get a missing symbol error.
2010-08-11 14:26:10 +03:00
Török Edvin
d732b5aa67 Reenable JIT selfcheck.
Lost in startup.cbc conversion.
2010-08-09 22:40:48 +03:00
Török Edvin
70c222c99c save lsig counts/offsets (bb #2055). 2010-08-02 23:08:21 +03:00
Török Edvin
762d46e8ea Fix matchicon bytecode API (bb #2139).
Now you can call it both from a normal lsig triggered BC, and from a PE hook BC.
The normal lsig triggered BC has exe_info (but not PE info) which allows it to
invoke the icon matcher API.
Also putting ICONGROUP1 into the ldb trigger of the bytecode works.
2010-08-02 21:52:15 +03:00
Török Edvin
213dfdff06 run 1 unit-test at least in test mode (bb #2151).
Also allow running test mode if JIT is not available, still checking
for failed startup.cbc execution.
2010-08-02 19:00:12 +03:00
Török Edvin
dc200c6b19 Add bytecode API for pdf. 2010-08-02 18:21:24 +03:00
Török Edvin
dbd3ed9345 Make BC_STARTUP run a minimal self-test.
Also change return value to something else than 0.
It is too easy for buggy bytecode to return 0.
2010-07-29 19:34:54 +03:00
Török Edvin
b3b8b6dd40 Pointers are always 64-bit for interpreter.
pointers in the interpreter are of the form:
| pointer id | pointer offset |, where pointer id is an offset into an array
that contains information about the pointer like its bounds.
2010-07-29 18:53:49 +03:00
Török Edvin
c09f9b2941 Fix bytecode on bigendian.
The last commits broke it: we store bytecode constants little-endian-like,
so an 8-bit constant is at offset 0, a 16-bit one at offsets 0,1; a 32-bit one
at 0,1,2,3; and a 64-bit one 0,1,2,3,4,5,6,7,8.
Of course the constant itself is in host-endianness.
2010-07-29 18:23:36 +03:00
Török Edvin
88d54dcb72 Fix distcheck warnings. 2010-07-29 18:22:57 +03:00
Török Edvin
b1018ea52e Fix another interpreter bug accessing structs.
Now that structs are not size 0, fix accessing their fields:
need to map field reads to byte offsets, not struct field index!
2010-07-29 14:06:59 +03:00
Török Edvin
669623d5a6 Fix computation of type sizes in interpreter.
It was not computing the size of structs.
Bug: all bytecodes that had structs on the stack failed with internal
out-of-bounds errors.
Workaround: compiler will need to avoid putting structs on stack, or do so only
for FLEVEL == 0.96.2
2010-07-29 14:06:59 +03:00
Török Edvin
0d4c99465e Add the builtin bytecode. 2010-07-29 14:06:56 +03:00
Török Edvin
d5ffa2acff Introduce BC_STARTUP bytecode (bb #2101, #2078).
This bytecode will be run in interpreter mode on startup:
it can disable the JIT, or disable all further bytecodes.
There will be a builtin copy of it that is loaded if
no BC_STARTUP bytecodes were loaded (like filetypes_int.h and daily.ftm).
Only one BC_STARTUP bytecode is accepted, so as soon as bytecode.cvd will
contain one, it won't be overridable!

This bytecode will replace all the JIT checks (CPU, selinux, pax) etc.,
and allows to disable the JIT on just specific OS/arch/compiler/etc.
combinations. There are too many combinations to have a dconf flag for each.

Also fix the bytecode dconf so that the individual JIT_* flags actually work
(previously we could disable the entire JIT, or none at all).

Also introduce preliminary support for bytecode test mode (we already have
auto, jit and interpreter mode, introducing another mode here is easiest).
The test mode doesn't actually compare the outputs yet, but it does fail if
the JIT is disabled / falls back to interpreter.
2010-07-29 13:48:18 +03:00
Török Edvin
927d054838 Add engine param to bytecode, and remove dconf from _init. 2010-07-29 13:48:18 +03:00
Török Edvin
a5a19f4518 bytecode: PaX and selfcheck.
Detect PaX and fallback to intepreter if needed (bb #2092).
Recent PaX versions deny the RWX mapping, but older versions silently change it
to RW, which causes the program to die as soon as it tries to execute JITed
code.

Add selfcheck on startup (bb #2092).
This will run a very simple bytecode on startup in both JIT and interpreter
mode. The bytecode only calls 1 libclamav API and returns.
2010-07-22 22:34:07 +03:00
Tomasz Kojm
ffa9b06093 sigtool: print match count and offsets in --test-sigs mode (bb#2054)
IMPORTANT NOTE: --test-sigs now only works against the final target file
(after all processing, normalization, etc. for which the tested
signature was directly created)
2010-06-10 12:24:26 +02:00
Török Edvin
5475ec2a72 Don't attempt to allocate 0 bytes (bb #2042). 2010-05-31 16:58:11 +03:00
Török Edvin
cbb9db1941 Fix some error path leaks (bb #1990).
This doesn't actually fix bb #1990 (which is about high memory usage on RHEL6),
but fixes some leaks found while investigating that bug.
2010-05-28 18:47:21 +03:00
Török Edvin
e5f2b2c530 fix build 2010-05-15 23:40:42 +03:00
Török Edvin
6cd36d95f9 bytecode: first close then unlink.
should fix win32.
2010-05-15 23:36:49 +03:00
Török Edvin
a3a6b8138d Handle global gep parameter correctly (bb #1955). 2010-05-14 11:29:27 +03:00
Török Edvin
fa0a9143bb Fix types for store/copy instructions. 2010-05-13 19:51:27 +03:00
Török Edvin
7a7365efe9 0.96.1 new APIs (cli_map etc.) 2010-05-12 23:51:20 +03:00
Török Edvin
1c4683acd1 add match_offsets support. 2010-05-07 10:53:18 +03:00
Török Edvin
3735fda134 min/max functionality level support. 2010-04-26 19:37:04 +03:00
Török Edvin
e86fe7ea90 Add debug messages about how bytecodes are executed (JIT/interpreter). 2010-04-16 10:34:50 +03:00
Török Edvin
b28845c3de Fix cli_unlink warnings (bb #1956).
fd == 0 is used to mark an invalid fd (not fd -1).
Test that tempfile is not NULL before calling cli_unlink
(that is the cause of the Bad address errors).
Also call cli_unlink when a virus is found. This isn't strictly
necessary since the file will get removed by the parent's rmdirs(),
but there is no point in leaving it behind.
2010-04-14 21:15:08 +03:00
Török Edvin
e4a0f2c94f fix compiler warnings (bb #1872, bb #1934, bb #1935) 2010-04-13 16:19:47 +03:00
Török Edvin
b00a7cc8f8 jsnorm api. 2010-03-31 10:53:11 +03:00
Török Edvin
dcaa403826 Fix use-of-uninit memory on zeroinitializer. 2010-03-30 10:42:46 +03:00
Török Edvin
349e6e118b More interpreter fixes, pdf.cbc seems to be running now. 2010-03-30 00:04:38 +03:00
Török Edvin
44e134312c More fixes for pdf.cbc. 2010-03-30 00:04:38 +03:00
Török Edvin
0d9b99f43e Fix bswap.cbc in interpreter mode. 2010-03-28 23:49:25 +03:00
Török Edvin
d11cced291 Fix some possible uninitialized value uses. 2010-03-28 20:15:48 +03:00
Tomasz Kojm
1583913898 fix C++ comments 2010-03-24 17:40:56 +01:00
Török Edvin
12876d3cb6 bytecode timeout 60s. 2010-03-24 18:34:58 +02:00
Török Edvin
7f6b55a124 Downgrade some messages to debug. 2010-03-24 17:55:04 +02:00
Török Edvin
778df8c22f Fix more leaks. 2010-03-24 17:08:20 +02:00
Török Edvin
6ea339aeab Fix bswap. 2010-03-24 15:27:15 +02:00
Török Edvin
48fc8b9852 Leak testcase. 2010-03-24 14:14:33 +02:00
Török Edvin
5dfb4bf136 match_with_read appears to be working! 2010-03-24 11:29:56 +02:00
Török Edvin
cfb0aef113 OP_BC_COPY again. 2010-03-24 10:51:05 +02:00