All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Moore <paul@paul-moore.com>
To: Jan Stancek <jstancek@redhat.com>
Cc: selinux@tycho.nsa.gov, sds@tycho.nsa.gov
Subject: Re: [selinux-testsuite PATCH v2 3/4] mmap/mprotect_heap: make sure memory is allocated from heap
Date: Thu, 19 Nov 2015 15:46:10 -0500	[thread overview]
Message-ID: <1825470.eZrmI3mDaB@sifl> (raw)
In-Reply-To: <e216aafa0f8ba1092e721c7c985385dc9a95f44a.1447666725.git.jstancek@redhat.com>

On Monday, November 16, 2015 10:46:26 AM Jan Stancek wrote:
> This test failed on ppc64 with 64k pagesize because memory
> allocation used mmap() instead of advancing heap.
> 
> Use mallopt(M_MMAP_THRESHOLD,..) with large enough value
> to discourage use of mmap().
> 
> Also set length in mprotect to pagesize, kernel silently aligns
> it to pagesize anyway.
> 
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> Cc: Paul Moore <paul@paul-moore.com>
> Cc: Stephen Smalley <sds@tycho.nsa.gov>
> ---
>  tests/mmap/mprotect_heap.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

Merged.  This looks much better, thanks.

> diff --git a/tests/mmap/mprotect_heap.c b/tests/mmap/mprotect_heap.c
> index 691299493c3f..23de4de5be62 100644
> --- a/tests/mmap/mprotect_heap.c
> +++ b/tests/mmap/mprotect_heap.c
> @@ -3,6 +3,11 @@
>  #include <stdlib.h>
>  #include <errno.h>
>  #include <sys/mman.h>
> +#include <malloc.h>
> +
> +#ifndef DEFAULT_MMAP_THRESHOLD_MAX
> +#define DEFAULT_MMAP_THRESHOLD_MAX 512*1024
> +#endif
> 
>  int main(void)
>  {
> @@ -10,13 +15,19 @@ int main(void)
>  	int rc;
>  	int pagesize = getpagesize();
> 
> +	rc = mallopt(M_MMAP_THRESHOLD, DEFAULT_MMAP_THRESHOLD_MAX);
> +	if (rc != 1) {
> +		fprintf(stderr, "mallopt failed: %d\n", rc);
> +		exit(1);
> +	}
> +
>  	rc = posix_memalign(&ptr, pagesize, pagesize);
>  	if (rc) {
>  		fprintf(stderr, "posix_memalign failed: %d\n", rc);
>  		exit(1);
>  	}
> 
> -	rc = mprotect(ptr, 4096, PROT_READ | PROT_EXEC);
> +	rc = mprotect(ptr, pagesize, PROT_READ | PROT_EXEC);
>  	if (rc < 0) {
>  		perror("mprotect");
>  		exit(1);

-- 
paul moore
www.paul-moore.com

  reply	other threads:[~2015-11-19 20:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06 13:07 [selinux-testsuite PATCH 0/4] inet_socket and mmap patches Jan Stancek
2015-11-06 13:07 ` [selinux-testsuite PATCH 1/4] tests/inet_socket: check 'ip xfrm policy ctx' support Jan Stancek
2015-11-06 17:58   ` Paul Moore
2015-11-06 21:44     ` Jan Stancek
2015-11-19 21:04       ` Paul Moore
2015-11-06 13:07 ` [selinux-testsuite PATCH 2/4] inet_socket: secon: use current pid Jan Stancek
2015-11-06 18:07   ` Paul Moore
2015-11-06 13:07 ` [selinux-testsuite PATCH 3/4] mmap/mprotect_heap: make sure memory is allocated from heap Jan Stancek
2015-11-06 18:14   ` Paul Moore
2015-11-06 21:57     ` Jan Stancek
2015-11-16  9:46   ` [selinux-testsuite PATCH v2 " Jan Stancek
2015-11-19 20:46     ` Paul Moore [this message]
2015-11-06 13:07 ` [selinux-testsuite PATCH 4/4] mmap/mprotect_file_private_execmod: clear READ_IMPLIES_EXEC Jan Stancek
2015-11-06 18:25   ` Paul Moore

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=1825470.eZrmI3mDaB@sifl \
    --to=paul@paul-moore.com \
    --cc=jstancek@redhat.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.