From: David Daney <ddaney.cavm@gmail.com>
To: Prem Karat <pkarat@mvista.com>, linux-mips@linux-mips.org
Subject: Re: [RFC PATCH 1/1] MIPS: Enable VDSO randomization.
Date: Sat, 19 Apr 2014 15:56:21 -0700 [thread overview]
Message-ID: <5352FF15.2080003@gmail.com> (raw)
In-Reply-To: <20140419093302.GH2717@064904.mvista.com>
On 04/19/2014 02:33 AM, Prem Karat wrote:
> Based on commit 1091458d09e1a (mmap randomization)
>
> For 32-bit address spaces randomize within a
> 16MB space, for 64-bit within a 256MB space.
>
How was it tested (i.e. what workload did you run to verify that the
kernel still functions with this change)?
> Signed-off-by: Prem Karat <pkarat@mvista.com>
> ---
> arch/mips/kernel/vdso.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/vdso.c b/arch/mips/kernel/vdso.c
> index 0f1af58..b49c705 100644
> --- a/arch/mips/kernel/vdso.c
> +++ b/arch/mips/kernel/vdso.c
> @@ -16,9 +16,11 @@
> #include <linux/elf.h>
> #include <linux/vmalloc.h>
> #include <linux/unistd.h>
> +#include <linux/random.h>
>
> #include <asm/vdso.h>
> #include <asm/uasm.h>
> +#include <asm/processor.h>
>
> /*
> * Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
> @@ -67,7 +69,18 @@ subsys_initcall(init_vdso);
>
> static unsigned long vdso_addr(unsigned long start)
> {
> - return STACK_TOP;
> + unsigned long offset = 0UL;
> +
> + if (current->flags & PF_RANDOMIZE) {
> + offset = get_random_int();
> + offset = offset << PAGE_SHIFT;
> + if (TASK_IS_32BIT_ADDR)
> + offset &= 0xfffffful;
> + else
> + offset &= 0xffffffful;
> + }
> +
> + return (STACK_TOP + offset);
How can you be sure this address doesn't collide with, or otherwise
interfere with, the stack?
Also, as mentioned by Sergei, run checkpatch.pl to catch obvious
stylistic problems before submitting patches.
Thanks,
David Daney
> }
>
> int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
>
next prev parent reply other threads:[~2014-04-19 22:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-19 9:33 [RFC PATCH 1/1] MIPS: Enable VDSO randomization Prem Karat
2014-04-19 13:49 ` Sergei Shtylyov
2014-04-19 22:56 ` David Daney [this message]
2014-04-21 3:40 ` Prem Karat
2014-04-21 18:38 ` David Daney
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=5352FF15.2080003@gmail.com \
--to=ddaney.cavm@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=pkarat@mvista.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 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.