Gentoo Archives: gentoo-commits

From: Alice Ferrazzi <alicef@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/linux-patches:5.7 commit in: /
Date: Fri, 07 Aug 2020 12:13:35
Message-Id: 1596802370.56c5495f139f487a3030babb821d312d91a71475.alicef@gentoo
1 commit: 56c5495f139f487a3030babb821d312d91a71475
2 Author: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
3 AuthorDate: Fri Aug 7 12:12:33 2020 +0000
4 Commit: Alice Ferrazzi <alicef <AT> gentoo <DOT> org>
5 CommitDate: Fri Aug 7 12:12:50 2020 +0000
6 URL: https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=56c5495f
7
8 Linux patch 5.7.14
9
10 Signed-off-by: Alice Ferrazzi <alicef <AT> gentoo.org>
11
12 0000_README | 4 +
13 1013_linux-5.7.14.patch | 294 ++++++++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 298 insertions(+)
15
16 diff --git a/0000_README b/0000_README
17 index a388fef..ff8860b 100644
18 --- a/0000_README
19 +++ b/0000_README
20 @@ -95,6 +95,10 @@ Patch: 1012_linux-5.7.13.patch
21 From: http://www.kernel.org
22 Desc: Linux 5.7.13
23
24 +Patch: 1013_linux-5.7.14.patch
25 +From: http://www.kernel.org
26 +Desc: Linux 5.7.14
27 +
28 Patch: 1500_XATTR_USER_PREFIX.patch
29 From: https://bugs.gentoo.org/show_bug.cgi?id=470644
30 Desc: Support for namespace user.pax.* on tmpfs.
31
32 diff --git a/1013_linux-5.7.14.patch b/1013_linux-5.7.14.patch
33 new file mode 100644
34 index 0000000..92e5caa
35 --- /dev/null
36 +++ b/1013_linux-5.7.14.patch
37 @@ -0,0 +1,294 @@
38 +diff --git a/Makefile b/Makefile
39 +index b77b4332a41a..70942a6541d8 100644
40 +--- a/Makefile
41 ++++ b/Makefile
42 +@@ -1,7 +1,7 @@
43 + # SPDX-License-Identifier: GPL-2.0
44 + VERSION = 5
45 + PATCHLEVEL = 7
46 +-SUBLEVEL = 13
47 ++SUBLEVEL = 14
48 + EXTRAVERSION =
49 + NAME = Kleptomaniac Octopus
50 +
51 +diff --git a/arch/arm/include/asm/percpu.h b/arch/arm/include/asm/percpu.h
52 +index f44f448537f2..1a3eedbac4a2 100644
53 +--- a/arch/arm/include/asm/percpu.h
54 ++++ b/arch/arm/include/asm/percpu.h
55 +@@ -5,6 +5,8 @@
56 + #ifndef _ASM_ARM_PERCPU_H_
57 + #define _ASM_ARM_PERCPU_H_
58 +
59 ++#include <asm/thread_info.h>
60 ++
61 + /*
62 + * Same as asm-generic/percpu.h, except that we store the per cpu offset
63 + * in the TPIDRPRW. TPIDRPRW only exists on V6K and V7
64 +diff --git a/arch/arm64/include/asm/archrandom.h b/arch/arm64/include/asm/archrandom.h
65 +index fc1594a0710e..44209f6146aa 100644
66 +--- a/arch/arm64/include/asm/archrandom.h
67 ++++ b/arch/arm64/include/asm/archrandom.h
68 +@@ -6,7 +6,6 @@
69 +
70 + #include <linux/bug.h>
71 + #include <linux/kernel.h>
72 +-#include <linux/random.h>
73 + #include <asm/cpufeature.h>
74 +
75 + static inline bool __arm64_rndr(unsigned long *v)
76 +diff --git a/arch/arm64/include/asm/pointer_auth.h b/arch/arm64/include/asm/pointer_auth.h
77 +index c6b4f0603024..be7f853738e6 100644
78 +--- a/arch/arm64/include/asm/pointer_auth.h
79 ++++ b/arch/arm64/include/asm/pointer_auth.h
80 +@@ -3,7 +3,6 @@
81 + #define __ASM_POINTER_AUTH_H
82 +
83 + #include <linux/bitops.h>
84 +-#include <linux/random.h>
85 +
86 + #include <asm/cpufeature.h>
87 + #include <asm/memory.h>
88 +@@ -34,6 +33,13 @@ struct ptrauth_keys_kernel {
89 + struct ptrauth_key apia;
90 + };
91 +
92 ++/*
93 ++ * Only include random.h once ptrauth_keys_* structures are defined
94 ++ * to avoid yet another circular include hell (random.h * ends up
95 ++ * including asm/smp.h, which requires ptrauth_keys_kernel).
96 ++ */
97 ++#include <linux/random.h>
98 ++
99 + static inline void ptrauth_keys_init_user(struct ptrauth_keys_user *keys)
100 + {
101 + if (system_supports_address_auth()) {
102 +diff --git a/arch/arm64/kernel/kaslr.c b/arch/arm64/kernel/kaslr.c
103 +index 91a83104c6e8..e2101440c314 100644
104 +--- a/arch/arm64/kernel/kaslr.c
105 ++++ b/arch/arm64/kernel/kaslr.c
106 +@@ -10,8 +10,8 @@
107 + #include <linux/mm_types.h>
108 + #include <linux/sched.h>
109 + #include <linux/types.h>
110 ++#include <linux/random.h>
111 +
112 +-#include <asm/archrandom.h>
113 + #include <asm/cacheflush.h>
114 + #include <asm/fixmap.h>
115 + #include <asm/kernel-pgtable.h>
116 +diff --git a/drivers/char/random.c b/drivers/char/random.c
117 +index 0d10e31fd342..344a57ebb35e 100644
118 +--- a/drivers/char/random.c
119 ++++ b/drivers/char/random.c
120 +@@ -1277,6 +1277,7 @@ void add_interrupt_randomness(int irq, int irq_flags)
121 +
122 + fast_mix(fast_pool);
123 + add_interrupt_bench(cycles);
124 ++ this_cpu_add(net_rand_state.s1, fast_pool->pool[cycles & 3]);
125 +
126 + if (unlikely(crng_init == 0)) {
127 + if ((fast_pool->count >= 64) &&
128 +diff --git a/include/linux/prandom.h b/include/linux/prandom.h
129 +new file mode 100644
130 +index 000000000000..aa16e6468f91
131 +--- /dev/null
132 ++++ b/include/linux/prandom.h
133 +@@ -0,0 +1,78 @@
134 ++/* SPDX-License-Identifier: GPL-2.0 */
135 ++/*
136 ++ * include/linux/prandom.h
137 ++ *
138 ++ * Include file for the fast pseudo-random 32-bit
139 ++ * generation.
140 ++ */
141 ++#ifndef _LINUX_PRANDOM_H
142 ++#define _LINUX_PRANDOM_H
143 ++
144 ++#include <linux/types.h>
145 ++#include <linux/percpu.h>
146 ++
147 ++u32 prandom_u32(void);
148 ++void prandom_bytes(void *buf, size_t nbytes);
149 ++void prandom_seed(u32 seed);
150 ++void prandom_reseed_late(void);
151 ++
152 ++struct rnd_state {
153 ++ __u32 s1, s2, s3, s4;
154 ++};
155 ++
156 ++DECLARE_PER_CPU(struct rnd_state, net_rand_state);
157 ++
158 ++u32 prandom_u32_state(struct rnd_state *state);
159 ++void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
160 ++void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state);
161 ++
162 ++#define prandom_init_once(pcpu_state) \
163 ++ DO_ONCE(prandom_seed_full_state, (pcpu_state))
164 ++
165 ++/**
166 ++ * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
167 ++ * @ep_ro: right open interval endpoint
168 ++ *
169 ++ * Returns a pseudo-random number that is in interval [0, ep_ro). Note
170 ++ * that the result depends on PRNG being well distributed in [0, ~0U]
171 ++ * u32 space. Here we use maximally equidistributed combined Tausworthe
172 ++ * generator, that is, prandom_u32(). This is useful when requesting a
173 ++ * random index of an array containing ep_ro elements, for example.
174 ++ *
175 ++ * Returns: pseudo-random number in interval [0, ep_ro)
176 ++ */
177 ++static inline u32 prandom_u32_max(u32 ep_ro)
178 ++{
179 ++ return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
180 ++}
181 ++
182 ++/*
183 ++ * Handle minimum values for seeds
184 ++ */
185 ++static inline u32 __seed(u32 x, u32 m)
186 ++{
187 ++ return (x < m) ? x + m : x;
188 ++}
189 ++
190 ++/**
191 ++ * prandom_seed_state - set seed for prandom_u32_state().
192 ++ * @state: pointer to state structure to receive the seed.
193 ++ * @seed: arbitrary 64-bit value to use as a seed.
194 ++ */
195 ++static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
196 ++{
197 ++ u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
198 ++
199 ++ state->s1 = __seed(i, 2U);
200 ++ state->s2 = __seed(i, 8U);
201 ++ state->s3 = __seed(i, 16U);
202 ++ state->s4 = __seed(i, 128U);
203 ++}
204 ++
205 ++/* Pseudo random number generator from numerical recipes. */
206 ++static inline u32 next_pseudo_random32(u32 seed)
207 ++{
208 ++ return seed * 1664525 + 1013904223;
209 ++}
210 ++
211 ++#endif
212 +diff --git a/include/linux/random.h b/include/linux/random.h
213 +index 45e1f8fa742b..f45b8be3e3c4 100644
214 +--- a/include/linux/random.h
215 ++++ b/include/linux/random.h
216 +@@ -110,61 +110,12 @@ declare_get_random_var_wait(long)
217 +
218 + unsigned long randomize_page(unsigned long start, unsigned long range);
219 +
220 +-u32 prandom_u32(void);
221 +-void prandom_bytes(void *buf, size_t nbytes);
222 +-void prandom_seed(u32 seed);
223 +-void prandom_reseed_late(void);
224 +-
225 +-struct rnd_state {
226 +- __u32 s1, s2, s3, s4;
227 +-};
228 +-
229 +-u32 prandom_u32_state(struct rnd_state *state);
230 +-void prandom_bytes_state(struct rnd_state *state, void *buf, size_t nbytes);
231 +-void prandom_seed_full_state(struct rnd_state __percpu *pcpu_state);
232 +-
233 +-#define prandom_init_once(pcpu_state) \
234 +- DO_ONCE(prandom_seed_full_state, (pcpu_state))
235 +-
236 +-/**
237 +- * prandom_u32_max - returns a pseudo-random number in interval [0, ep_ro)
238 +- * @ep_ro: right open interval endpoint
239 +- *
240 +- * Returns a pseudo-random number that is in interval [0, ep_ro). Note
241 +- * that the result depends on PRNG being well distributed in [0, ~0U]
242 +- * u32 space. Here we use maximally equidistributed combined Tausworthe
243 +- * generator, that is, prandom_u32(). This is useful when requesting a
244 +- * random index of an array containing ep_ro elements, for example.
245 +- *
246 +- * Returns: pseudo-random number in interval [0, ep_ro)
247 +- */
248 +-static inline u32 prandom_u32_max(u32 ep_ro)
249 +-{
250 +- return (u32)(((u64) prandom_u32() * ep_ro) >> 32);
251 +-}
252 +-
253 + /*
254 +- * Handle minimum values for seeds
255 ++ * This is designed to be standalone for just prandom
256 ++ * users, but for now we include it from <linux/random.h>
257 ++ * for legacy reasons.
258 + */
259 +-static inline u32 __seed(u32 x, u32 m)
260 +-{
261 +- return (x < m) ? x + m : x;
262 +-}
263 +-
264 +-/**
265 +- * prandom_seed_state - set seed for prandom_u32_state().
266 +- * @state: pointer to state structure to receive the seed.
267 +- * @seed: arbitrary 64-bit value to use as a seed.
268 +- */
269 +-static inline void prandom_seed_state(struct rnd_state *state, u64 seed)
270 +-{
271 +- u32 i = (seed >> 32) ^ (seed << 10) ^ seed;
272 +-
273 +- state->s1 = __seed(i, 2U);
274 +- state->s2 = __seed(i, 8U);
275 +- state->s3 = __seed(i, 16U);
276 +- state->s4 = __seed(i, 128U);
277 +-}
278 ++#include <linux/prandom.h>
279 +
280 + #ifdef CONFIG_ARCH_RANDOM
281 + # include <asm/archrandom.h>
282 +@@ -207,10 +158,4 @@ static inline bool __init arch_get_random_long_early(unsigned long *v)
283 + }
284 + #endif
285 +
286 +-/* Pseudo random number generator from numerical recipes. */
287 +-static inline u32 next_pseudo_random32(u32 seed)
288 +-{
289 +- return seed * 1664525 + 1013904223;
290 +-}
291 +-
292 + #endif /* _LINUX_RANDOM_H */
293 +diff --git a/kernel/time/timer.c b/kernel/time/timer.c
294 +index 03c9fc395ab1..721d5af8cfc7 100644
295 +--- a/kernel/time/timer.c
296 ++++ b/kernel/time/timer.c
297 +@@ -43,6 +43,7 @@
298 + #include <linux/sched/debug.h>
299 + #include <linux/slab.h>
300 + #include <linux/compat.h>
301 ++#include <linux/random.h>
302 +
303 + #include <linux/uaccess.h>
304 + #include <asm/unistd.h>
305 +@@ -1743,6 +1744,13 @@ void update_process_times(int user_tick)
306 + scheduler_tick();
307 + if (IS_ENABLED(CONFIG_POSIX_TIMERS))
308 + run_posix_cpu_timers();
309 ++
310 ++ /* The current CPU might make use of net randoms without receiving IRQs
311 ++ * to renew them often enough. Let's update the net_rand_state from a
312 ++ * non-constant value that's not affine to the number of calls to make
313 ++ * sure it's updated when there's some activity (we don't care in idle).
314 ++ */
315 ++ this_cpu_add(net_rand_state.s1, rol32(jiffies, 24) + user_tick);
316 + }
317 +
318 + /**
319 +diff --git a/lib/random32.c b/lib/random32.c
320 +index 763b920a6206..3d749abb9e80 100644
321 +--- a/lib/random32.c
322 ++++ b/lib/random32.c
323 +@@ -48,7 +48,7 @@ static inline void prandom_state_selftest(void)
324 + }
325 + #endif
326 +
327 +-static DEFINE_PER_CPU(struct rnd_state, net_rand_state) __latent_entropy;
328 ++DEFINE_PER_CPU(struct rnd_state, net_rand_state);
329 +
330 + /**
331 + * prandom_u32_state - seeded pseudo-random number generator.