|
|
1c5ca07 |
--- a/clamd/clamd.c
|
|
|
1c5ca07 |
+++ a/clamd/clamd.c
|
|
|
1c5ca07 |
@@ -431,6 +431,9 @@ int main(int argc, char **argv)
|
|
|
1c5ca07 |
if((opt = optget(opts,"BytecodeTimeout"))->enabled) {
|
|
|
1c5ca07 |
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
|
|
|
1c5ca07 |
}
|
|
|
1c5ca07 |
+ if((opt = optget(opts,"BytecodeDisableJIT"))->enabled) {
|
|
|
1c5ca07 |
+ cl_engine_set_num(engine, CL_ENGINE_BYTECODE_DISABLEJIT, opt->numarg);
|
|
|
1c5ca07 |
+ }
|
|
|
1c5ca07 |
|
|
|
1c5ca07 |
if(optget(opts,"PhishingScanURLs")->enabled)
|
|
|
1c5ca07 |
dboptions |= CL_DB_PHISHING_URLS;
|
|
|
1c5ca07 |
--- a/clamscan/manager.c
|
|
|
1c5ca07 |
+++ a/clamscan/manager.c
|
|
|
1c5ca07 |
@@ -405,6 +405,8 @@ int scanmanager(const struct optstruct *opts)
|
|
|
1c5ca07 |
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_SECURITY, CL_BYTECODE_TRUST_ALL);
|
|
|
1c5ca07 |
if((opt = optget(opts,"bytecode-timeout"))->enabled)
|
|
|
1c5ca07 |
cl_engine_set_num(engine, CL_ENGINE_BYTECODE_TIMEOUT, opt->numarg);
|
|
|
1c5ca07 |
+ if((opt = optget(opts,"bytecode-disable-jit"))->enabled)
|
|
|
1c5ca07 |
+ cl_engine_set_num(engine, CL_ENGINE_BYTECODE_DISABLEJIT, opt->numarg);
|
|
|
1c5ca07 |
|
|
|
1c5ca07 |
if((opt = optget(opts, "tempdir"))->enabled) {
|
|
|
1c5ca07 |
if((ret = cl_engine_set_str(engine, CL_ENGINE_TMPDIR, opt->strarg))) {
|
|
|
1c5ca07 |
--- a/docs/man/clamd.conf.5.in
|
|
|
1c5ca07 |
+++ a/docs/man/clamd.conf.5.in
|
|
|
1c5ca07 |
@@ -253,6 +253,12 @@ Default: TrustSigned
|
|
|
1c5ca07 |
Set bytecode timeout in milliseconds.
|
|
|
1c5ca07 |
.br
|
|
|
1c5ca07 |
Default: 60000
|
|
|
1c5ca07 |
+.TP
|
|
|
1c5ca07 |
+\fBBytecodeDisableJIT BOOL\fR
|
|
|
1c5ca07 |
+Disable the JIT and fallback to interpreter mode.
|
|
|
1c5ca07 |
+WARNING: disabling the JIT affects performance!
|
|
|
1c5ca07 |
+.br
|
|
|
1c5ca07 |
+Default: No
|
|
|
1c5ca07 |
.TP
|
|
|
1c5ca07 |
\fBDetectPUA BOOL\fR
|
|
|
1c5ca07 |
Detect Possibly Unwanted Applications.
|
|
|
1c5ca07 |
--- a/docs/man/clamscan.1.in
|
|
|
1c5ca07 |
+++ a/docs/man/clamscan.1.in
|
|
|
1c5ca07 |
@@ -86,6 +86,10 @@ This option disables safety checks and makes ClamAV trust all bytecode. It shoul
|
|
|
1c5ca07 |
.TP
|
|
|
1c5ca07 |
\fB\-\-bytecode\-timeout=N\fR
|
|
|
1c5ca07 |
Set bytecode timeout in milliseconds (default: 60000 = 60s)
|
|
|
1c5ca07 |
+.TP
|
|
|
1c5ca07 |
+\fB\-\-bytecode\-disable\-jit\fR
|
|
|
1c5ca07 |
+Disable the JIT and fallback to interpreter mode.
|
|
|
1c5ca07 |
+WARNING: disable the JIT affects performance!
|
|
|
1c5ca07 |
.TP
|
|
|
1c5ca07 |
\fB\-\-detect\-pua[=yes/no(*)]\fR
|
|
|
1c5ca07 |
Detect Possibly Unwanted Applications.
|
|
|
1c5ca07 |
--- a/etc/clamd.conf
|
|
|
1c5ca07 |
+++ a/etc/clamd.conf
|
|
|
1c5ca07 |
@@ -474,3 +474,8 @@ Example
|
|
|
1c5ca07 |
#
|
|
|
1c5ca07 |
# Default: 60000
|
|
|
1c5ca07 |
# BytecodeTimeout 60000
|
|
|
1c5ca07 |
+
|
|
|
1c5ca07 |
+# Disable JIT and fallback to interpreter. WARNING: disabling JIT affects performance.
|
|
|
1c5ca07 |
+#
|
|
|
1c5ca07 |
+# Default: no
|
|
|
1c5ca07 |
+#BytecodeDisableJIT no
|
|
|
1c5ca07 |
--- a/libclamav/clamav.h
|
|
|
1c5ca07 |
+++ a/libclamav/clamav.h
|
|
|
1c5ca07 |
@@ -142,7 +142,8 @@ enum cl_engine_field {
|
|
|
1c5ca07 |
CL_ENGINE_TMPDIR, /* (char *) */
|
|
|
1c5ca07 |
CL_ENGINE_KEEPTMP, /* uint32_t */
|
|
|
1c5ca07 |
CL_ENGINE_BYTECODE_SECURITY, /* uint32_t */
|
|
|
1c5ca07 |
- CL_ENGINE_BYTECODE_TIMEOUT /* uint32_t */
|
|
|
1c5ca07 |
+ CL_ENGINE_BYTECODE_TIMEOUT, /* uint32_t */
|
|
|
1c5ca07 |
+ CL_ENGINE_BYTECODE_DISABLEJIT /* uint32_t */
|
|
|
1c5ca07 |
};
|
|
|
1c5ca07 |
|
|
|
1c5ca07 |
enum bytecode_security {
|
|
|
1c5ca07 |
--- a/libclamav/others.c
|
|
|
1c5ca07 |
+++ a/libclamav/others.c
|
|
|
1c5ca07 |
@@ -301,6 +301,7 @@ struct cl_engine *cl_engine_new(void)
|
|
|
1c5ca07 |
new->bytecode_security = CL_BYTECODE_TRUST_SIGNED;
|
|
|
1c5ca07 |
/* 5 seconds timeout */
|
|
|
1c5ca07 |
new->bytecode_timeout = 60000;
|
|
|
1c5ca07 |
+ new->disablejit = 0;
|
|
|
1c5ca07 |
new->refcount = 1;
|
|
|
1c5ca07 |
new->ac_only = 0;
|
|
|
1c5ca07 |
new->ac_mindepth = CLI_DEFAULT_AC_MINDEPTH;
|
|
|
1c5ca07 |
@@ -395,6 +396,9 @@ int cl_engine_set_num(struct cl_engine *engine, enum cl_engine_field field, long
|
|
|
1c5ca07 |
case CL_ENGINE_BYTECODE_TIMEOUT:
|
|
|
1c5ca07 |
engine->bytecode_timeout = num;
|
|
|
1c5ca07 |
break;
|
|
|
1c5ca07 |
+ case CL_ENGINE_BYTECODE_DISABLEJIT:
|
|
|
1c5ca07 |
+ engine->disablejit = num;
|
|
|
1c5ca07 |
+ break;
|
|
|
1c5ca07 |
default:
|
|
|
1c5ca07 |
cli_errmsg("cl_engine_set_num: Incorrect field number\n");
|
|
|
1c5ca07 |
return CL_EARG;
|
|
|
1c5ca07 |
--- a/libclamav/others.h
|
|
|
1c5ca07 |
+++ a/libclamav/others.h
|
|
|
1c5ca07 |
@@ -249,6 +249,7 @@ struct cl_engine {
|
|
|
1c5ca07 |
unsigned hook_lsig_ids;
|
|
|
1c5ca07 |
enum bytecode_security bytecode_security;
|
|
|
1c5ca07 |
uint32_t bytecode_timeout;
|
|
|
1c5ca07 |
+ unsigned disablejit;
|
|
|
1c5ca07 |
};
|
|
|
1c5ca07 |
|
|
|
1c5ca07 |
struct cl_settings {
|
|
|
1c5ca07 |
--- a/libclamav/readdb.c
|
|
|
1c5ca07 |
+++ a/libclamav/readdb.c
|
|
|
1c5ca07 |
@@ -2566,7 +2566,10 @@ int cl_load(const char *path, struct cl_engine *engine, unsigned int *signo, uns
|
|
|
1c5ca07 |
return ret;
|
|
|
1c5ca07 |
|
|
|
1c5ca07 |
if((dboptions & CL_DB_BYTECODE) && !engine->bcs.engine && (engine->dconf->bytecode & BYTECODE_ENGINE_MASK)) {
|
|
|
1c5ca07 |
- if((ret = cli_bytecode_init(&engine->bcs, engine->dconf->bytecode)))
|
|
|
1c5ca07 |
+ unsigned dconfmask = engine->dconf->bytecode;
|
|
|
1c5ca07 |
+ if (engine->disablejit)
|
|
|
1c5ca07 |
+ dconfmask &= BYTECODE_INTERPRETER;
|
|
|
1c5ca07 |
+ if((ret = cli_bytecode_init(&engine->bcs, dconfmask)))
|
|
|
1c5ca07 |
return ret;
|
|
|
1c5ca07 |
} else {
|
|
|
1c5ca07 |
cli_dbgmsg("Bytecode engine disabled\n");
|
|
|
1c5ca07 |
--- a/shared/optparser.c
|
|
|
1c5ca07 |
+++ a/shared/optparser.c
|
|
|
1c5ca07 |
@@ -252,6 +252,9 @@ const struct clam_option __clam_options[] = {
|
|
|
1c5ca07 |
"Set bytecode security level.\nPossible values:\n\tNone - no security at all, meant for debugging. DO NOT USE THIS ON PRODUCTION SYSTEMS\n\tTrustSigned - trust bytecode loaded from signed .c[lv]d files,\n\t\t insert runtime safety checks for bytecode loaded from other sources\n\tParanoid - don't trust any bytecode, insert runtime checks for all\nRecommended: TrustSigned, because bytecode in .cvd files already has these checks\n","TrustSigned"},
|
|
|
1c5ca07 |
{ "BytecodeTimeout", "bytecode-timeout", 0, TYPE_NUMBER, MATCH_NUMBER, 60000, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN,
|
|
|
1c5ca07 |
"Set bytecode timeout in miliseconds.\n","60000"},
|
|
|
1c5ca07 |
+ { "BytecodeDisableJIT", "bytecode-disable-jit", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN,
|
|
|
1c5ca07 |
+ "Disable JIT and fallback to interpreter. WARNING: disabling JIT affects performance.\n","no"},
|
|
|
1c5ca07 |
+
|
|
|
1c5ca07 |
{ "DetectPUA", "detect-pua", 0, TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_CLAMSCAN, "Detect Potentially Unwanted Applications.", "yes" },
|
|
|
1c5ca07 |
|
|
|
1c5ca07 |
{ "ExcludePUA", "exclude-pua", 0, TYPE_STRING, NULL, -1, NULL, FLAG_MULTIPLE, OPT_CLAMD | OPT_CLAMSCAN, "Exclude a specific PUA category. This directive can be used multiple times.\nSee http://www.clamav.net/support/pua for the complete list of PUA\ncategories.", "NetTool\nPWTool" },
|