From: Michael Ellerman <mpe@ellerman.id.au>
To: linuxppc-dev@ozlabs.org
Cc: bhsharma@redhat.com, keescook@chromium.org, bsingharora@gmail.com
Subject: [PATCH] powerpc/mm: Fix possible out-of-bounds shift in arch_mmap_rnd()
Date: Tue, 25 Apr 2017 22:09:41 +1000 [thread overview]
Message-ID: <1493122181-20921-1-git-send-email-mpe@ellerman.id.au> (raw)
The recent patch to add runtime configuration of the ASLR limits added a bug in
arch_mmap_rnd() where we may shift an integer (32-bits) by up to 33 bits,
leading to undefined behaviour.
In practice it exhibits as every process seg faulting instantly, presumably
because the rnd value hasn't been restricited by the modulus at all. We didn't
notice because it only happens under certain kernel configurations and if the
number of bits is actually set to a large value.
Fix it by switching to unsigned long.
Fixes: 9fea59bd7ca5 ("powerpc/mm: Add support for runtime configuration of ASLR limits")
Reported-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
arch/powerpc/mm/mmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
index 005aa8a44915..9dbd2a733d6b 100644
--- a/arch/powerpc/mm/mmap.c
+++ b/arch/powerpc/mm/mmap.c
@@ -66,7 +66,7 @@ unsigned long arch_mmap_rnd(void)
if (is_32bit_task())
shift = mmap_rnd_compat_bits;
#endif
- rnd = get_random_long() % (1 << shift);
+ rnd = get_random_long() % (1ul << shift);
return rnd << PAGE_SHIFT;
}
--
2.7.4
next reply other threads:[~2017-04-25 12:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 12:09 Michael Ellerman [this message]
2017-04-25 16:08 ` [PATCH] powerpc/mm: Fix possible out-of-bounds shift in arch_mmap_rnd() Kees Cook
2017-04-27 10:30 ` Michael Ellerman
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=1493122181-20921-1-git-send-email-mpe@ellerman.id.au \
--to=mpe@ellerman.id.au \
--cc=bhsharma@redhat.com \
--cc=bsingharora@gmail.com \
--cc=keescook@chromium.org \
--cc=linuxppc-dev@ozlabs.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).