Jason Cooper
99fdafdeac
random: simplify API for random address requests
To date, all callers of randomize_range() have set the length to 0, and
check for a zero return value. For the current callers, the only way to
get zero returned is if end <= start. Since they are all adding a
constant to the start address, this is unnecessary.
We can remove a bunch of needless checks by simplifying the API to do just
what everyone wants, return an address between [start, start + range).
While we're here, s/get_random_int/get_random_long/. No current call site
is adversely affected by get_random_int(), since all current range
requests are < UINT_MAX. However, we should match caller expectations to
avoid coming up short (ha!) in the future.
All current callers to randomize_range() chose to use the start address if
randomize_range() failed. Therefore, we simplify things by just returning
the start address on error.
randomize_range() will be removed once all callers have been converted
over to randomize_addr().
Link: http://lkml.kernel.org/r/20160803233913.32511-2-jason@lakedaemon.net
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: "Roberts, William C" <william.c.roberts@intel.com>
Cc: Yann Droneaud <ydroneaud@opteya.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: Nick Kralevich <nnk@google.com>
Cc: Jeffrey Vander Stoep <jeffv@google.com>
Cc: Daniel Cashman <dcashman@android.com>
Cc: Chris Metcalf <cmetcalf@mellanox.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-10-11 15:06:32 -07:00
..
2016-06-13 10:03:54 +01:00
2016-10-10 11:19:47 +08:00
2016-07-27 14:19:25 -07:00
2016-08-31 14:22:49 +02:00
2016-05-20 20:57:27 -07:00
2016-09-27 12:02:13 +03:00
2015-06-12 16:58:33 -07:00
2016-08-31 14:47:54 +02:00
2014-01-07 13:50:28 +01:00
2014-05-27 17:43:12 -07:00
2016-08-31 14:12:35 +02:00
2014-07-09 16:59:15 -07:00
2013-05-05 00:11:29 -04:00
2016-07-14 16:21:53 +09:00
2015-09-20 19:32:35 -07:00
2015-12-09 13:00:45 -05:00
2014-11-07 11:24:01 -08:00
2016-02-17 09:39:56 +01:00
2016-08-05 09:48:22 -04:00
2013-12-18 16:39:54 -08:00
2016-08-05 09:48:22 -04:00
2015-12-09 13:00:45 -05:00
2016-08-31 15:21:18 +02:00
2015-08-05 10:35:49 -07:00
2016-01-22 17:02:18 -08:00
2016-02-08 14:57:30 -08:00
2016-02-09 17:39:56 -08:00
2015-12-23 10:41:31 -05:00
2016-06-29 17:33:46 +10:00
2016-08-31 14:22:49 +02:00
2016-01-22 18:04:28 -05:00
2016-10-11 15:06:32 -07:00
2016-02-08 14:57:30 -08:00
2013-10-16 12:36:10 -07:00
2013-10-16 12:36:10 -07:00
2016-08-31 14:47:54 +02:00
2016-09-27 21:06:22 -04:00
2014-10-20 16:20:19 +02:00
2016-08-30 14:45:50 +02:00
2013-10-16 12:36:10 -07:00
2015-08-05 17:26:00 -07:00
2016-09-13 17:30:17 +02:00
2016-10-05 18:23:59 -04:00