public inbox for gentoo-hardened@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Török Edwin" <edwintorok@gmail.com>
To: gentoo-hardened@lists.gentoo.org
Cc: p.labushev@gmail.com, Kyle Bader <kyle.bader@gmail.com>
Subject: Re: [gentoo-hardened] FYI: Clamav bytecode feature isn't compatible with PaX
Date: Thu, 22 Jul 2010 19:27:20 +0300	[thread overview]
Message-ID: <20100722192720.3c598d42@debian> (raw)
In-Reply-To: <4C4862D6.5070107@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1019 bytes --]

On Thu, 22 Jul 2010 23:25:10 +0800
Pavel Labushev <p.labushev@gmail.com> wrote:

> 22.07.2010 19:52, "Tóth Attila" пишет:
> 
> > 1. What is the neat way of detecting PaX running on a system?
> 
> To check /proc/self/status for "PaX:". That's what host-is-pax from
> pax-utils.eclass does.
> 

On Thu, 22 Jul 2010 07:08:30 -0700
Kyle Bader <kyle.bader@gmail.com> wrote:

> > https://wwws.clamav.net/bugzilla/show_bug.cgi?id=2092
> > http://bugs.gentoo.org/show_bug.cgi?id=326199
> >
> > https://wwws.clamav.net/bugzilla/show_bug.cgi?id=2092#c39
> > It raises two questions:
> > 1. What is the neat way of detecting PaX running on a system?
> 
> http://tk-blog.blogspot.com/2009/02/checksec.html
> 
> > 2. Edwin Török says PaX allows RWX mapping and kills the program
> > after that.
> 
> http://pax.grsecurity.net/docs/pageexec.txt
> 

Thanks. I have implemented PaX detection, see attached patch.

I'll commit it shortly to the ClamAV repository.

Best regards,
--Edwin




[-- Attachment #2: pax.patch --]
[-- Type: text/x-patch, Size: 1726 bytes --]

diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
index 22b5413..de01f4c 100644
--- a/libclamav/c++/bytecode2llvm.cpp
+++ b/libclamav/c++/bytecode2llvm.cpp
@@ -1914,6 +1914,7 @@ int cli_bytecode_init_jit(struct cli_all_bc *bcs, unsigned dconfmask)
 	bcs->engine = 0;
 	DEBUG(errs() << "i[34]86 detected, falling back to interpreter (JIT needs pentium or better\n");
 	/* i386 and i486 has to fallback to interpreter */
+	have_clamjit=0;
 	return 0;
     }
     std::string ErrMsg;
@@ -1921,12 +1922,35 @@ int cli_bytecode_init_jit(struct cli_all_bc *bcs, unsigned dconfmask)
     if (B.base() == 0) {
 	errs() << MODULE << ErrMsg << "\n";
 #ifdef __linux__
-	errs() << MODULE << "SELinux is preventing 'execmem' access. Run 'setsebool -P clamd_use_jit on' to allow access\n";
+	errs() << MODULE << "SELinux or PaX is preventing 'execmem' access."
+	    << "Run 'setsebool -P clamd_use_jit on' or 'paxctl -m <executable>' to allow access\n";
 #endif
 	errs() << MODULE << "falling back to interpreter mode\n";
+	have_clamjit=0;
 	return 0;
     } else {
 	sys::Memory::ReleaseRWX(B);
+#ifdef __linux__
+	FILE *f = fopen("/proc/self/status", "r");
+	if (f) {
+	    char line[128];
+	    while (fgets(line, sizeof(line), f)) {
+		if (!memcmp(line, "PaX:", 4)) {
+		    if (cli_debug_flag) {
+			errs() << "bytecode JIT: PaX found: " << line;
+		    }
+		    if (!strchr(line,'m')) {
+			errs() << MODULE << "PaX is preventing MPROTECT, use 'paxctl -m <executable>' to allow\n";
+			errs() << MODULE << "falling back to interpreter mode\n";
+			fclose(f);
+			have_clamjit=0;
+			return 0;
+		    }
+		}
+	    }
+	    fclose(f);
+	}
+#endif
     }
 
     bcs->engine = new(std::nothrow) cli_bcengine;

      reply	other threads:[~2010-07-22 17:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-22 11:52 [gentoo-hardened] FYI: Clamav bytecode feature isn't compatible with PaX "Tóth Attila"
2010-07-22 14:08 ` Kyle Bader
2010-07-22 15:25 ` Pavel Labushev
2010-07-22 16:27   ` Török Edwin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100722192720.3c598d42@debian \
    --to=edwintorok@gmail.com \
    --cc=gentoo-hardened@lists.gentoo.org \
    --cc=kyle.bader@gmail.com \
    --cc=p.labushev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox