Commit graph

220 commits

Author SHA1 Message Date
Shawn Webb
241e7eb147 bb6258 - Add warnings when allocations fail 2013-03-01 13:51:15 -05:00
Shawn Webb
9691454612 bb6091 - check lseek() return 2013-02-28 19:32:29 -05:00
Carl Wu
8254e4adb5 cwu_cid#_10269: fix 10269 2013-02-20 11:21:30 -05:00
Ryan Pentney
3bd9a14c8c Fixed coverity bugs 11378, 11379, 11380 2013-02-07 08:41:46 -08:00
Steve Morgan
16c4fcdd10 performance statistics for bytecode hooks 2012-12-07 08:09:10 -08:00
Steve Morgan
38956aacb0 windows-friendly bytecode stats 2012-12-06 12:36:21 -08:00
Steve Morgan
54402320c0 Add bytecode performance statistics 2012-12-05 15:48:52 -08:00
Shawn Webb
e522909e19 bb6061 2012-11-19 13:20:33 -05:00
Steve Morgan
6ad45a2931 add initial allscan/allmatch mode to libclamav, clamd, clamdscan, and clamscan with unit tests 2012-10-18 14:12:58 -07:00
David Raynor
7ef9aa8ade bb #5199 and bb #5200 2012-09-14 10:38:56 -04:00
Shawn webb
042a78ac60 Fix previous commits 2012-07-10 16:51:53 -04:00
Shawn webb
6a049897d9 BB#5455 2012-07-10 13:17:45 -04:00
David Raynor
bebd86a60b bb#5343 2012-06-22 16:55:29 -04:00
aCaB
d4d4bce9c7 bb#3789 part 2 2012-02-29 18:39:57 +01:00
Török Edvin
3d664817f6 fix recursion level crash (bb #3706).
Thanks to Stephane Chazelas for the analysis.
2011-10-08 12:12:22 +03:00
Török Edvin
63feb6cdf4 Add some performance measurement code.
Default off, activated by --dev-performance, and always on in c4w.
2011-02-14 19:19:53 +02:00
Török Edvin
0796f1cab5 bytecode: successfully skip bytecodes that use unknown APIs
When unknown APIs are used, the bytecode is skipped.
However we were still checking that the number of loaded functions is correct,
and of course we were failing because when skipping the number of loaded functions is
0. Fix this by not checking the number of loaded functions when skipping a
bytecode.
2011-02-14 10:15:05 +02:00
aCaB
7cbc72d3b1 c4w: error path engine leak 2010-11-09 19:02:53 +02:00
Török Edvin
110731e784 Fix valgrind warning. 2010-10-18 14:36:19 +03:00
Török Edvin
4116c65d1b Add bytecode API to determine whether running under JIT. 2010-10-18 12:35:39 +03:00
Török Edvin
d7531f2ad2 Fix warnings. 2010-10-18 12:24:11 +03:00
Török Edvin
35d6165fa5 bytecode: fix multiple bytecode execution in same hook.
Do not reset filesize to 0.
Otherwise only the 1st bytecode executed in a hook can really scan the file,
all further bytecodes executed in same hook will fail to read anything from the
file.
2010-10-18 10:56:31 +03:00
Török Edvin
6b5af78c33 bytecode_vm: do a 2nd pass over types to update array sizes.
TODO: in the future the .cbc should include these sizes itself.
2010-10-18 10:48:18 +03:00
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