Commit 8b3ccbc
committed
treewide: use prandom_u32_max() when possible, part 2
Rather than incurring a division or requesting too many random bytes for
the given range, use the prandom_u32_max() function, which only takes
the minimum required bytes from the RNG and avoids divisions. This was
done by hand, covering things that coccinelle could not do on its own.
Reviewed-by: Greg Kroah-Hartman <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Reviewed-by: Yury Norov <[email protected]>
Reviewed-by: Jan Kara <[email protected]> # for ext2, ext4, and sbitmap
Acked-by: Jakub Kicinski <[email protected]>
Signed-off-by: Jason A. Donenfeld <[email protected]>1 parent 81895a6 commit 8b3ccbc
4 files changed
+8
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
280 | | - | |
281 | | - | |
| 280 | + | |
282 | 281 | | |
283 | 282 | | |
284 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
463 | 463 | | |
464 | 464 | | |
465 | 465 | | |
466 | | - | |
| 466 | + | |
467 | 467 | | |
468 | | - | |
469 | | - | |
| 468 | + | |
470 | 469 | | |
471 | 470 | | |
472 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
| 154 | + | |
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
| |||
293 | 291 | | |
294 | 292 | | |
295 | 293 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 294 | + | |
300 | 295 | | |
301 | 296 | | |
302 | 297 | | |
303 | 298 | | |
304 | | - | |
305 | | - | |
| 299 | + | |
306 | 300 | | |
307 | 301 | | |
308 | 302 | | |
| |||
393 | 387 | | |
394 | 388 | | |
395 | 389 | | |
396 | | - | |
397 | 390 | | |
398 | 391 | | |
399 | 392 | | |
400 | | - | |
401 | | - | |
402 | 393 | | |
403 | | - | |
| 394 | + | |
404 | 395 | | |
405 | 396 | | |
406 | 397 | | |
| |||
0 commit comments