From: Topi Miettinen <toiwoton@gmail.com>
To: Paul Moore <paul@paul-moore.com>,
Eric Paris <eparis@parisplace.org>,
James Morris <james.l.morris@oracle.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
"moderated list:SELINUX SECURITY MODULE" <selinux@tycho.nsa.gov>,
"open list:SECURITY SUBSYSTEM"
<linux-security-module@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>,
Stephen Smalley <sds@tycho.nsa.gov>
Subject: selinux: should execmem disable shmat(..., SHM_EXEC)?
Date: Wed, 26 Oct 2016 20:31:36 +0000 [thread overview]
Message-ID: <3f453e5e-e70c-f00d-9b5b-f09addd04ada@gmail.com> (raw)
Hi,
Maybe this is a stupid question and I didn't test this with SELinux, but
it looks to me that SELinux execmem does not prevent process from
getting writable and executable memory mappings by using shmat(...,
SHM_EXEC). Shouldn't this be blocked by execmem, I suppose it is there
to prevent this kind of memory access?
Here's a test program:
#include <sys/ipc.h>
#include <sys/shm.h>
int main(void) {
int shmid;
char *execmem;
void (*fn)(void);
shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT | 0777);
execmem = shmat(shmid, 0, SHM_EXEC);
shmctl(shmid, IPC_RMID, 0);
*execmem = 0xc3; // retq
fn = (void (*)(void))execmem;
fn();
shmdt(execmem);
}
-Topi
next reply other threads:[~2016-10-26 20:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 20:31 Topi Miettinen [this message]
2016-10-27 13:01 ` selinux: should execmem disable shmat(..., SHM_EXEC)? Stephen Smalley
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=3f453e5e-e70c-f00d-9b5b-f09addd04ada@gmail.com \
--to=toiwoton@gmail.com \
--cc=eparis@parisplace.org \
--cc=james.l.morris@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=serge@hallyn.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;
as well as URLs for NNTP newsgroup(s).