From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: src/
Date: Tue, 27 Sep 2011 17:58:11 +0000 (UTC) [thread overview]
Message-ID: <83957c336a4cff7d5a8278f21b47b5486d968041.blueness@gentoo> (raw)
commit: 83957c336a4cff7d5a8278f21b47b5486d968041
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 27 17:57:55 2011 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Tue Sep 27 17:57:55 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=83957c33
src/paxctl-ng.c: fix PT_PAX flag setting
---
src/paxctl-ng.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 84 insertions(+), 15 deletions(-)
diff --git a/src/paxctl-ng.c b/src/paxctl-ng.c
index fea0832..c565ffa 100644
--- a/src/paxctl-ng.c
+++ b/src/paxctl-ng.c
@@ -254,6 +254,7 @@ set_flags(Elf *elf, int *pax_flags)
ei_flags = ehdr.e_ident[EI_PAX] + (ehdr.e_ident[EI_PAX + 1] << 8);
+ //PAGEEXEC
if(*pax_flags & PF_PAGEEXEC)
ei_flags &= ~HF_PAX_PAGEEXEC;
if(*pax_flags & PF_NOPAGEEXEC)
@@ -261,6 +262,7 @@ set_flags(Elf *elf, int *pax_flags)
if((*pax_flags & PF_PAGEEXEC) && (*pax_flags & PF_NOPAGEEXEC))
ei_flags &= ~HF_PAX_PAGEEXEC;
+ //SEGMEXEC
if(*pax_flags & PF_SEGMEXEC)
ei_flags &= ~HF_PAX_SEGMEXEC;
if(*pax_flags & PF_NOSEGMEXEC)
@@ -268,6 +270,7 @@ set_flags(Elf *elf, int *pax_flags)
if((*pax_flags & PF_SEGMEXEC) && (*pax_flags & PF_NOSEGMEXEC))
ei_flags &= ~HF_PAX_SEGMEXEC;
+ //MPROTECT
if(*pax_flags & PF_MPROTECT)
ei_flags &= ~HF_PAX_MPROTECT;
if(*pax_flags & PF_NOMPROTECT)
@@ -275,6 +278,7 @@ set_flags(Elf *elf, int *pax_flags)
if((*pax_flags & PF_MPROTECT) && (*pax_flags & PF_NOMPROTECT))
ei_flags &= ~HF_PAX_MPROTECT;
+ //EMUTRAMP
if(*pax_flags & PF_EMUTRAMP)
ei_flags |= HF_PAX_EMUTRAMP;
if(*pax_flags & PF_NOEMUTRAMP)
@@ -282,6 +286,7 @@ set_flags(Elf *elf, int *pax_flags)
if((*pax_flags & PF_EMUTRAMP) && (*pax_flags & PF_NOEMUTRAMP))
ei_flags &= ~HF_PAX_EMUTRAMP;
+ //RANDMMAP
if(*pax_flags & PF_RANDMMAP)
ei_flags &= ~HF_PAX_RANDMMAP;
if(*pax_flags & PF_NORANDMMAP)
@@ -289,6 +294,7 @@ set_flags(Elf *elf, int *pax_flags)
if((*pax_flags & PF_RANDMMAP) && (*pax_flags & PF_NORANDMMAP))
ei_flags &= ~HF_PAX_RANDMMAP;
+ //RANDEXEC
if(*pax_flags & PF_RANDEXEC)
ei_flags |= HF_PAX_RANDEXEC;
if(*pax_flags & PF_NORANDEXEC)
@@ -311,45 +317,108 @@ set_flags(Elf *elf, int *pax_flags)
if(phdr.p_type == PT_PAX_FLAGS)
{
- //Take and Pp flags and conver them to -
+ //PAGEEXEC
+ if(*pax_flags & PF_PAGEEXEC)
+ {
+ phdr.p_flags |= PF_PAGEEXEC;
+ phdr.p_flags &= ~PF_NOPAGEEXEC;
+ }
+ if(*pax_flags & PF_NOPAGEEXEC)
+ {
+ phdr.p_flags &= ~PF_PAGEEXEC;
+ phdr.p_flags |= PF_NOPAGEEXEC;
+ }
if((*pax_flags & PF_PAGEEXEC) && (*pax_flags & PF_NOPAGEEXEC))
{
- *pax_flags ^= PF_PAGEEXEC;
- *pax_flags ^= PF_NOPAGEEXEC;
+ phdr.p_flags &= ~PF_PAGEEXEC;
+ phdr.p_flags &= ~PF_NOPAGEEXEC;
}
+ //SEGMEXEC
+ if(*pax_flags & PF_SEGMEXEC)
+ {
+ phdr.p_flags |= PF_SEGMEXEC;
+ phdr.p_flags &= ~PF_NOSEGMEXEC;
+ }
+ if(*pax_flags & PF_NOSEGMEXEC)
+ {
+ phdr.p_flags &= ~PF_SEGMEXEC;
+ phdr.p_flags |= PF_NOSEGMEXEC;
+ }
if((*pax_flags & PF_SEGMEXEC) && (*pax_flags & PF_NOSEGMEXEC))
{
- *pax_flags ^= PF_SEGMEXEC;
- *pax_flags ^= PF_NOSEGMEXEC;
+ phdr.p_flags &= ~PF_SEGMEXEC;
+ phdr.p_flags &= ~PF_NOSEGMEXEC;
}
+ //MPROTECT
+ if(*pax_flags & PF_MPROTECT)
+ {
+ phdr.p_flags |= PF_MPROTECT;
+ phdr.p_flags &= ~PF_NOMPROTECT;
+ }
+ if(*pax_flags & PF_NOMPROTECT)
+ {
+ phdr.p_flags &= ~PF_MPROTECT;
+ phdr.p_flags |= PF_NOMPROTECT;
+ }
if((*pax_flags & PF_MPROTECT) && (*pax_flags & PF_NOMPROTECT))
{
- *pax_flags ^= PF_MPROTECT;
- *pax_flags ^= PF_NOMPROTECT;
+ phdr.p_flags &= ~PF_MPROTECT;
+ phdr.p_flags &= ~PF_NOMPROTECT;
}
+ //EMUTRAMP
+ if(*pax_flags & PF_EMUTRAMP)
+ {
+ phdr.p_flags |= PF_EMUTRAMP;
+ phdr.p_flags &= ~PF_NOEMUTRAMP;
+ }
+ if(*pax_flags & PF_NOEMUTRAMP)
+ {
+ phdr.p_flags &= ~PF_EMUTRAMP;
+ phdr.p_flags |= PF_NOEMUTRAMP;
+ }
if((*pax_flags & PF_EMUTRAMP) && (*pax_flags & PF_NOEMUTRAMP))
{
- *pax_flags ^= PF_EMUTRAMP;
- *pax_flags ^= PF_NOEMUTRAMP;
+ phdr.p_flags &= ~PF_EMUTRAMP;
+ phdr.p_flags &= ~PF_NOEMUTRAMP;
}
+ //RANDMMAP
+ if(*pax_flags & PF_RANDMMAP)
+ {
+ phdr.p_flags |= PF_RANDMMAP;
+ phdr.p_flags &= ~PF_NORANDMMAP;
+ }
+ if(*pax_flags & PF_NORANDMMAP)
+ {
+ phdr.p_flags &= ~PF_RANDMMAP;
+ phdr.p_flags |= PF_NORANDMMAP;
+ }
if((*pax_flags & PF_RANDMMAP) && (*pax_flags & PF_NORANDMMAP))
{
- *pax_flags ^= PF_RANDMMAP;
- *pax_flags ^= PF_NORANDMMAP;
+ phdr.p_flags &= ~PF_RANDMMAP;
+ phdr.p_flags &= ~PF_NORANDMMAP;
}
+ //RANDEXEC
+ if(*pax_flags & PF_RANDEXEC)
+ {
+ phdr.p_flags |= PF_RANDEXEC;
+ phdr.p_flags &= ~PF_NORANDEXEC;
+ }
+ if(*pax_flags & PF_NORANDEXEC)
+ {
+ phdr.p_flags &= ~PF_RANDEXEC;
+ phdr.p_flags |= PF_NORANDEXEC;
+ }
if((*pax_flags & PF_RANDEXEC) && (*pax_flags & PF_NORANDEXEC))
{
- *pax_flags ^= PF_RANDEXEC;
- *pax_flags ^= PF_NORANDEXEC;
+ phdr.p_flags &= ~PF_RANDEXEC;
+ phdr.p_flags &= ~PF_NORANDEXEC;
}
- phdr.p_flags = *pax_flags ;
-
if(!gelf_update_phdr(elf, i, &phdr))
error(EXIT_FAILURE, 0, "gelf_update_phdr(): %s", elf_errmsg(elf_errno()));
}
next reply other threads:[~2011-09-27 17:58 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-27 17:58 Anthony G. Basile [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-12-13 14:48 [gentoo-commits] proj/elfix:master commit in: src/ Anthony G. Basile
2013-09-26 12:24 Anthony G. Basile
2012-12-28 23:07 Anthony G. Basile
2012-12-22 17:48 Anthony G. Basile
2012-12-21 20:36 Anthony G. Basile
2012-11-10 23:27 Anthony G. Basile
2012-11-10 22:29 Anthony G. Basile
2012-11-10 21:55 Anthony G. Basile
2012-11-10 21:35 Anthony G. Basile
2012-11-10 21:26 Anthony G. Basile
2012-07-27 22:00 Anthony G. Basile
2012-07-23 10:47 Anthony G. Basile
2012-07-21 12:37 Anthony G. Basile
2012-07-20 13:24 Anthony G. Basile
2012-07-20 11:56 Anthony G. Basile
2012-07-20 9:30 Anthony G. Basile
2011-11-27 0:59 Anthony G. Basile
2011-11-27 0:26 Anthony G. Basile
2011-11-15 16:07 Anthony G. Basile
2011-11-03 18:45 Anthony G. Basile
2011-11-03 18:16 Anthony G. Basile
2011-11-03 12:33 Anthony G. Basile
2011-10-22 19:51 Anthony G. Basile
2011-10-18 22:48 Anthony G. Basile
2011-09-27 18:49 Anthony G. Basile
2011-09-27 17:30 Anthony G. Basile
2011-09-18 22:48 Anthony G. Basile
2011-09-18 14:20 Anthony G. Basile
2011-09-11 21:12 Anthony G. Basile
2011-09-11 3:40 Anthony G. Basile
2011-09-11 2:32 Anthony G. Basile
2011-09-11 1:54 Anthony G. Basile
2011-09-11 0:23 Anthony G. Basile
2011-09-10 21:36 Anthony G. Basile
2011-09-10 21:35 Anthony G. Basile
2011-09-10 21:11 Anthony G. Basile
2011-05-13 12:01 Anthony G. Basile
2011-05-05 22:40 Anthony G. Basile
2011-05-04 2:15 Anthony G. Basile
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=83957c336a4cff7d5a8278f21b47b5486d968041.blueness@gentoo \
--to=blueness@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/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