From: kennethadammiller@gmail.com (Kenneth Adam Miller)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Inexplicable PROT_EXEC flag set on mmap callback
Date: Thu, 14 Jan 2016 12:28:43 -0500 [thread overview]
Message-ID: <CAK7rcp-SQmmtAK4BC6gb_ZCDTLH0stcrCRZ95w+4E1HeEwn_6Q@mail.gmail.com> (raw)
In-Reply-To: <20160114170011.GA24746@kmu-tp-x230>
On Thu, Jan 14, 2016 at 12:00 PM, Mike Krinkin <krinkin.m.u@gmail.com>
wrote:
> Hi, i have a couple of questions to clarify, if you don't mind
>
> On Thu, Jan 14, 2016 at 11:04:28AM -0500, Kenneth Adam Miller wrote:
> > I have a custom drive and userland program pair that I'm using for a very
> > special use case at my workplace where we are mapping specific physical
> > address ranges into userland memory with a mmap callback. Everything
> works
> > together well with a C userland program that calls into our driver's
> ioctl
> > and mmap definitions, but for our case we are using an alternative
> systems
> > language just for the userland program.
>
> So you have userland app written in C, and another not written in C?
> The former works well while the latter doesn't, am i right?
>
Yes, the former works in so much as mmap completes successfully. I've
verified that the
parameters are identical in the non-C program. The issue of just using the
C only program
is that the actual implementation of interest is in the non-C program, and
that's because
that language facilitates other features that are *required* on our end.
>
> > That mmap call is failing (properly
> > as we want) out from the driver's mmap implementation due to the fact
> that
> > the vm_flags have the VM_EXEC flag set. We do not want users to be able
> to
> > map the memory range as executable, so the driver should check for this
> as
> > it does. The issue is in the fact that somewhere between where mmap is
> > called and when the parameters are given to the driver, the vma->vm_flags
> > are being set to 255. I've manually checked the values being given to the
> > mmap call in our non-C binary, and they are *equivalent* in value to that
> > of the C program.
>
> By "manually" do you mean strace? Could you show strace output for
> both apps? And also could you show readelf -l output for both binaries?
>
By manually, I mean with a print call just before the mmap call in each of
the
programs. Right now, I'm working on getting a strace output, but I have to
run that in qemu.
To be able to run it in qemu in order to isolate the driver and all from my
host, I have to build
with buildroot. So I'll email that when I get it, but it'll be a while.
>
> >
> > My question is, is there anything that can cause the vma->vm_flags to be
> > changed in the trip between when the user land program calls mmap and
> when
> > control is delivered to the mmap callback?
>
> > _______________________________________________
> > Kernelnewbies mailing list
> > Kernelnewbies at kernelnewbies.org
> > http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160114/1dd7454d/attachment.html
next prev parent reply other threads:[~2016-01-14 17:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-14 16:04 Inexplicable PROT_EXEC flag set on mmap callback Kenneth Adam Miller
2016-01-14 16:26 ` Kenneth Adam Miller
2016-01-14 17:00 ` Mike Krinkin
2016-01-14 17:28 ` Kenneth Adam Miller [this message]
2016-01-16 17:45 ` Kenneth Adam Miller
2016-01-16 18:08 ` Mike Krinkin
2016-01-16 18:16 ` Kenneth Adam Miller
2016-01-16 18:31 ` Mike Krinkin
2016-01-16 18:32 ` Kenneth Adam Miller
2016-01-16 18:33 ` Kenneth Adam Miller
2016-01-16 19:15 ` Kenneth Adam Miller
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=CAK7rcp-SQmmtAK4BC6gb_ZCDTLH0stcrCRZ95w+4E1HeEwn_6Q@mail.gmail.com \
--to=kennethadammiller@gmail.com \
--cc=kernelnewbies@lists.kernelnewbies.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;
as well as URLs for NNTP newsgroup(s).