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-10-07 18:46:30 -07:00
2016-09-15 19:15:55 -04:00
2016-10-07 18:46:28 -07:00
2016-10-10 13:52:05 -07:00
2016-10-07 09:46:56 +02:00
2016-10-07 21:23:40 -07:00
2016-10-11 15:06:32 -07:00
2016-10-07 21:34:49 -07:00
2016-10-07 21:23:40 -07:00
2016-10-06 07:59:37 -07:00
2016-10-07 18:46:30 -07:00
2016-10-10 14:04:16 -07:00
2016-09-19 13:36:20 +02:00
2016-10-06 17:13:54 -07:00
2016-10-04 12:06:26 -07:00
2016-10-07 21:23:40 -07:00
2016-10-07 14:12:21 -07:00
2016-10-10 13:04:49 -07:00
2016-10-07 11:58:38 -07:00
2016-09-27 12:35:49 +02:00
2016-10-04 10:56:14 -07:00
2016-10-07 14:12:21 -07:00
2016-10-07 18:46:30 -07:00
2016-10-05 14:50:51 -07:00
2016-10-10 20:16:43 -07:00
2016-10-07 09:12:19 -07:00
2016-10-06 10:49:01 -07:00
2016-10-10 10:24:41 -07:00
2016-09-20 10:22:10 +02:00
2016-10-07 14:42:05 -07:00
2016-09-20 20:57:12 +10:00
2016-10-06 17:36:53 -07:00
2016-09-27 12:33:47 +02:00
2016-10-09 17:29:33 -07:00
2016-10-07 21:23:40 -07:00
2016-10-07 21:23:40 -07:00
2016-10-07 08:35:35 -07:00
2016-10-10 20:16:43 -07:00
2016-10-03 20:17:35 -07:00
2016-10-10 17:39:51 -07:00
2016-10-11 08:10:19 -07:00
2016-09-24 11:45:38 -07:00
2016-10-09 17:29:33 -07:00
2016-10-07 21:23:40 -07:00
2016-10-10 17:39:51 -07:00
2016-10-10 20:16:43 -07:00
2016-10-10 14:04:16 -07:00
2016-09-22 09:39:16 +01:00
2016-10-07 21:23:40 -07:00
2016-10-07 21:23:40 -07:00
2016-10-10 20:16:43 -07:00
2016-10-06 18:21:15 -07:00
2016-09-20 20:57:12 +10:00
2016-10-03 21:54:10 -04:00
2016-10-11 15:06:32 -07:00
2016-10-07 08:35:35 -07:00
2016-10-06 17:03:49 -07:00
2016-10-04 15:47:01 +01:00
2016-10-07 09:28:53 -07:00
2016-10-09 17:29:33 -07:00
2016-10-07 21:23:40 -07:00
2016-09-30 09:14:22 -07:00
2016-09-27 12:43:34 +02:00
2016-10-10 20:16:43 -07:00
2016-09-19 01:37:32 -04:00
2016-10-10 09:29:50 -07:00
2016-10-10 20:16:43 -07:00
2016-09-29 13:36:38 -06:00
2016-10-06 09:27:26 +01:00
2016-09-27 12:43:35 +02:00
2016-10-03 20:17:35 -07:00
2016-10-06 11:19:10 -07:00
2016-09-23 13:00:04 +02:00