From: Balbir Singh <bsingharora@gmail.com> To: Michael Ellerman <mpe@ellerman.id.au> Cc: Bhupesh Sharma <bhsharma@redhat.com>, linuxppc-dev@lists.ozlabs.org, kernel-hardening@lists.openwall.com, Anatolij Gustschin <agust@denx.de>, keescook@chromium.org, Daniel Cashman <dcashman@android.com>, Scott Wood <oss@buserror.net>, Paul Mackerras <paulus@samba.org>, dcashman@google.com, Alistair Popple <alistair@popple.id.au>, bhupesh.linux@gmail.com, Alexander Graf <agraf@suse.com> Subject: Re: [PATCH 1/2] powerpc: mm: support ARCH_MMAP_RND_BITS Date: Thu, 2 Feb 2017 17:52:56 +0530 [thread overview] Message-ID: <20170202122256.GD5179@localhost.localdomain> (raw) In-Reply-To: <87mve4c2my.fsf@concordia.ellerman.id.au> On Thu, Feb 02, 2017 at 09:23:33PM +1100, Michael Ellerman wrote: > +config ARCH_MMAP_RND_BITS_MIN > + # On 64-bit up to 1G of address space (2^30) > + default 12 if 64BIT && PPC_256K_PAGES # 256K (2^18), = 30 - 18 = 12 > + default 14 if 64BIT && PPC_64K_PAGES # 64K (2^16), = 30 - 16 = 14 > + default 16 if 64BIT && PPC_16K_PAGES # 16K (2^14), = 30 - 14 = 16 > + default 18 if 64BIT # 4K (2^12), = 30 - 12 = 18 > + default ARCH_MMAP_RND_COMPAT_BITS_MIN > + > +config ARCH_MMAP_RND_BITS_MAX > + # On 64-bit up to 32T of address space (2^45) I thought it was 64T, TASK_SIZE_USER64 is 2^46? <snip> > I also have what I think is a better hunk for that: > > unsigned long arch_mmap_rnd(void) > { > - unsigned long rnd; > + unsigned long shift, rnd; > > - /* 8MB for 32bit, 1GB for 64bit */ > + shift = mmap_rnd_bits; > +#ifdef CONFIG_COMPAT > if (is_32bit_task()) > - rnd = (unsigned long)get_random_int() % (1<<(23-PAGE_SHIFT)); > - else > - rnd = (unsigned long)get_random_int() % (1<<(30-PAGE_SHIFT)); > + shift = mmap_rnd_compat_bits; > +#endif > + > + rnd = (unsigned long)get_random_int() % (1 << shift); > > But I'm just nit picking I guess :) > No.. the version above is nicer IMHO Balbir
WARNING: multiple messages have this Message-ID (diff)
From: Balbir Singh <bsingharora@gmail.com> To: Michael Ellerman <mpe@ellerman.id.au> Cc: Bhupesh Sharma <bhsharma@redhat.com>, linuxppc-dev@lists.ozlabs.org, kernel-hardening@lists.openwall.com, Anatolij Gustschin <agust@denx.de>, keescook@chromium.org, Daniel Cashman <dcashman@android.com>, Scott Wood <oss@buserror.net>, Paul Mackerras <paulus@samba.org>, dcashman@google.com, Alistair Popple <alistair@popple.id.au>, bhupesh.linux@gmail.com, Alexander Graf <agraf@suse.com> Subject: [kernel-hardening] Re: [PATCH 1/2] powerpc: mm: support ARCH_MMAP_RND_BITS Date: Thu, 2 Feb 2017 17:52:56 +0530 [thread overview] Message-ID: <20170202122256.GD5179@localhost.localdomain> (raw) In-Reply-To: <87mve4c2my.fsf@concordia.ellerman.id.au> On Thu, Feb 02, 2017 at 09:23:33PM +1100, Michael Ellerman wrote: > +config ARCH_MMAP_RND_BITS_MIN > + # On 64-bit up to 1G of address space (2^30) > + default 12 if 64BIT && PPC_256K_PAGES # 256K (2^18), = 30 - 18 = 12 > + default 14 if 64BIT && PPC_64K_PAGES # 64K (2^16), = 30 - 16 = 14 > + default 16 if 64BIT && PPC_16K_PAGES # 16K (2^14), = 30 - 14 = 16 > + default 18 if 64BIT # 4K (2^12), = 30 - 12 = 18 > + default ARCH_MMAP_RND_COMPAT_BITS_MIN > + > +config ARCH_MMAP_RND_BITS_MAX > + # On 64-bit up to 32T of address space (2^45) I thought it was 64T, TASK_SIZE_USER64 is 2^46? <snip> > I also have what I think is a better hunk for that: > > unsigned long arch_mmap_rnd(void) > { > - unsigned long rnd; > + unsigned long shift, rnd; > > - /* 8MB for 32bit, 1GB for 64bit */ > + shift = mmap_rnd_bits; > +#ifdef CONFIG_COMPAT > if (is_32bit_task()) > - rnd = (unsigned long)get_random_int() % (1<<(23-PAGE_SHIFT)); > - else > - rnd = (unsigned long)get_random_int() % (1<<(30-PAGE_SHIFT)); > + shift = mmap_rnd_compat_bits; > +#endif > + > + rnd = (unsigned long)get_random_int() % (1 << shift); > > But I'm just nit picking I guess :) > No.. the version above is nicer IMHO Balbir
next prev parent reply other threads:[~2017-02-02 12:23 UTC|newest] Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-02-02 5:42 [PATCH 0/2] RFC: Adjust powerpc ASLR elf randomness Bhupesh Sharma 2017-02-02 5:42 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 5:42 ` [PATCH 1/2] powerpc: mm: support ARCH_MMAP_RND_BITS Bhupesh Sharma 2017-02-02 5:42 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 9:11 ` Balbir Singh 2017-02-02 9:11 ` [kernel-hardening] " Balbir Singh 2017-02-02 18:14 ` Bhupesh Sharma 2017-02-02 18:14 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 10:23 ` Michael Ellerman 2017-02-02 10:23 ` [kernel-hardening] " Michael Ellerman 2017-02-02 12:22 ` Balbir Singh [this message] 2017-02-02 12:22 ` Balbir Singh 2017-02-02 23:59 ` Michael Ellerman 2017-02-08 12:53 ` Bhupesh Sharma 2017-02-08 12:53 ` [kernel-hardening] " Bhupesh Sharma 2017-02-10 11:01 ` Michael Ellerman 2017-02-10 11:11 ` Bhupesh Sharma 2017-02-16 4:49 ` Bhupesh Sharma 2017-02-24 7:32 ` Bhupesh Sharma 2017-02-24 9:53 ` Michael Ellerman 2017-02-24 9:53 ` Michael Ellerman 2017-02-02 14:25 ` Kees Cook 2017-02-02 14:25 ` [kernel-hardening] " Kees Cook 2017-02-02 18:04 ` Bhupesh Sharma 2017-02-02 18:04 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 5:42 ` [PATCH 2/2] powerpc: Redefine ELF_ET_DYN_BASE Bhupesh Sharma 2017-02-02 5:42 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 6:44 ` [PATCH 0/2] RFC: Adjust powerpc ASLR elf randomness Balbir Singh 2017-02-02 6:44 ` [kernel-hardening] " Balbir Singh 2017-02-02 18:21 ` Bhupesh Sharma 2017-02-02 18:21 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 14:21 ` Kees Cook 2017-02-02 14:21 ` [kernel-hardening] " Kees Cook 2017-02-02 18:08 ` Bhupesh Sharma 2017-02-02 18:08 ` [kernel-hardening] " Bhupesh Sharma 2017-02-02 19:19 ` Kees Cook 2017-02-02 19:19 ` [kernel-hardening] " Kees Cook 2017-02-02 19:43 ` Bhupesh Sharma 2017-02-02 19:43 ` [kernel-hardening] " Bhupesh Sharma
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=20170202122256.GD5179@localhost.localdomain \ --to=bsingharora@gmail.com \ --cc=agraf@suse.com \ --cc=agust@denx.de \ --cc=alistair@popple.id.au \ --cc=bhsharma@redhat.com \ --cc=bhupesh.linux@gmail.com \ --cc=dcashman@android.com \ --cc=dcashman@google.com \ --cc=keescook@chromium.org \ --cc=kernel-hardening@lists.openwall.com \ --cc=linuxppc-dev@lists.ozlabs.org \ --cc=mpe@ellerman.id.au \ --cc=oss@buserror.net \ --cc=paulus@samba.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: linkBe 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.