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