-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Stephan Mueller <smueller@chronox.de>
- Loading branch information
1 parent
9c7f5c0
commit 8ea1e78
Showing
74 changed files
with
2,693 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Backport Patches for Kernel 4.14 | ||
|
||
The patches allow applying the LRNG to older kernels. Perform the following | ||
operations: | ||
|
||
1. apply all six-digit patches providing necessary code updates to | ||
required before applying the LRNG patches. | ||
|
||
2. apply all LRNG patches from upstream - note, some hunks are expected | ||
considering the original code base is written for a different kernel version | ||
|
||
3. apply all two-digit patches providing code updates after the LRNG patches | ||
are applied. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- linux-5.8/kernel/sched/core.c.orig 2022-05-17 09:59:33.887522471 +0200 | ||
+++ linux-5.8/kernel/sched/core.c 2022-05-17 10:00:18.241509892 +0200 | ||
@@ -6,6 +6,10 @@ | ||
* | ||
* Copyright (C) 1991-2002 Linus Torvalds | ||
*/ | ||
+#include <linux/highmem.h> | ||
+#include <linux/hrtimer_api.h> | ||
+#include <linux/ktime_api.h> | ||
+ | ||
#include <linux/sched.h> | ||
#include <linux/sched/clock.h> | ||
#include <uapi/linux/sched/types.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
diff -urNp linux-4.19.orig/crypto/jitterentropy.c linux-4.19/crypto/jitterentropy.c | ||
--- linux-4.19.orig/crypto/jitterentropy.c 2020-08-20 12:33:37.584860610 +0200 | ||
+++ linux-4.19/crypto/jitterentropy.c 2020-08-20 12:44:34.654746533 +0200 | ||
@@ -110,13 +110,7 @@ struct rand_data { | ||
* Helper functions | ||
***************************************************************************/ | ||
|
||
-void jent_get_nstime(__u64 *out); | ||
-__u64 jent_rol64(__u64 word, unsigned int shift); | ||
-void *jent_zalloc(unsigned int len); | ||
-void jent_zfree(void *ptr); | ||
-int jent_fips_enabled(void); | ||
-void jent_panic(char *s); | ||
-void jent_memcpy(void *dest, const void *src, unsigned int n); | ||
+#include "jitterentropy.h" | ||
|
||
/** | ||
* Update of the loop count used for the next round of | ||
@@ -418,6 +412,7 @@ static __u64 jent_unbiased_bit(struct ra | ||
* Input: | ||
* @entropy_collector Reference to entropy collector | ||
*/ | ||
+__u64 jent_rol64(__u64 word, unsigned int shift); | ||
static void jent_stir_pool(struct rand_data *entropy_collector) | ||
{ | ||
/* | ||
diff -urNp linux-4.19.orig/crypto/jitterentropy.h linux-4.19/crypto/jitterentropy.h | ||
--- linux-4.19.orig/crypto/jitterentropy.h 1970-01-01 01:00:00.000000000 +0100 | ||
+++ linux-4.19/crypto/jitterentropy.h 2020-08-20 12:44:34.654746533 +0200 | ||
@@ -0,0 +1,19 @@ | ||
+// SPDX-License-Identifier: GPL-2.0-or-later | ||
+ | ||
+typedef unsigned long long __u64; | ||
+ | ||
+extern void *jent_zalloc(unsigned int len); | ||
+extern void jent_zfree(void *ptr); | ||
+extern int jent_fips_enabled(void); | ||
+extern void jent_panic(char *s); | ||
+extern void jent_memcpy(void *dest, const void *src, unsigned int n); | ||
+extern void jent_get_nstime(__u64 *out); | ||
+ | ||
+struct rand_data; | ||
+extern int jent_entropy_init(void); | ||
+extern int jent_read_entropy(struct rand_data *ec, unsigned char *data, | ||
+ unsigned int len); | ||
+ | ||
+extern struct rand_data *jent_entropy_collector_alloc(unsigned int osr, | ||
+ unsigned int flags); | ||
+extern void jent_entropy_collector_free(struct rand_data *entropy_collector); | ||
diff -urNp linux-4.19.orig/crypto/jitterentropy-kcapi.c linux-4.19/crypto/jitterentropy-kcapi.c | ||
--- linux-4.19.orig/crypto/jitterentropy-kcapi.c 2020-08-20 12:33:37.583860598 +0200 | ||
+++ linux-4.19/crypto/jitterentropy-kcapi.c 2020-08-20 12:44:34.653746522 +0200 | ||
@@ -44,13 +44,7 @@ | ||
#include <linux/crypto.h> | ||
#include <crypto/internal/rng.h> | ||
|
||
-struct rand_data; | ||
-int jent_read_entropy(struct rand_data *ec, unsigned char *data, | ||
- unsigned int len); | ||
-int jent_entropy_init(void); | ||
-struct rand_data *jent_entropy_collector_alloc(unsigned int osr, | ||
- unsigned int flags); | ||
-void jent_entropy_collector_free(struct rand_data *entropy_collector); | ||
+#include "jitterentropy.h" | ||
|
||
/*************************************************************************** | ||
* Helper function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- linux-4.14.286/drivers/char/Makefile.orig 2022-07-10 22:52:59.154987205 +0200 | ||
+++ linux-4.14.286/drivers/char/Makefile 2022-07-10 22:53:30.497460021 +0200 | ||
@@ -60,3 +60,4 @@ js-rtc-y = rtc.o | ||
obj-$(CONFIG_TILE_SROM) += tile-srom.o | ||
obj-$(CONFIG_XILLYBUS) += xillybus/ | ||
obj-$(CONFIG_POWERNV_OP_PANEL) += powernv-op-panel.o | ||
+obj-$(CONFIG_ADI) += adi.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- linux-4.19/include/crypto/sha.h.lrng13 2020-08-13 22:06:20.353827574 -0600 | ||
+++ linux-4.19/include/crypto/sha.h 2020-08-13 22:18:18.678469365 -0600 | ||
@@ -112,4 +112,15 @@ | ||
|
||
extern int crypto_sha512_finup(struct shash_desc *desc, const u8 *data, | ||
unsigned int len, u8 *hash); | ||
+ | ||
+/* | ||
+ * An implementation of SHA-1's compression function. Don't use in new code! | ||
+ * You shouldn't be using SHA-1, and even if you *have* to use SHA-1, this isn't | ||
+ * the correct way to hash something with SHA-1 (use crypto_shash instead). | ||
+ */ | ||
+#define SHA1_DIGEST_WORDS (SHA1_DIGEST_SIZE / 4) | ||
+#define SHA1_WORKSPACE_WORDS 16 | ||
+void sha_init(__u32 *buf); | ||
+void sha_transform(__u32 *digest, const char *data, __u32 *W); | ||
+ | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- linux-5.15/kernel/sched/core.c.orig 2022-05-17 08:10:20.541904807 +0200 | ||
+++ linux-5.15/kernel/sched/core.c 2022-05-17 08:10:31.720932544 +0200 | ||
@@ -7,9 +7,6 @@ | ||
* Copyright (C) 1991-2002 Linus Torvalds | ||
*/ | ||
#include <linux/lrng.h> | ||
-#include <linux/highmem.h> | ||
-#include <linux/hrtimer_api.h> | ||
-#include <linux/ktime_api.h> | ||
|
||
#define CREATE_TRACE_POINTS | ||
#include <trace/events/sched.h> |
68 changes: 68 additions & 0 deletions
68
backports/v51-4.14.325/v51-03-revert-arch_get_random_long.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
diff --git a/drivers/char/lrng/lrng_es_cpu.c b/drivers/char/lrng/lrng_es_cpu.c | ||
index f982cc31df4e..3910108cfd08 100644 | ||
--- a/drivers/char/lrng/lrng_es_cpu.c | ||
+++ b/drivers/char/lrng/lrng_es_cpu.c | ||
@@ -65,8 +65,7 @@ static u32 lrng_cpu_poolsize(void) | ||
|
||
static u32 lrng_get_cpu_data(u8 *outbuf, u32 requested_bits) | ||
{ | ||
- size_t longs = 0; | ||
- u32 i, req = requested_bits >> 3; | ||
+ u32 i; | ||
|
||
/* operate on full blocks */ | ||
BUILD_BUG_ON(LRNG_DRNG_SECURITY_STRENGTH_BYTES % sizeof(unsigned long)); | ||
@@ -74,14 +73,10 @@ static u32 lrng_get_cpu_data(u8 *outbuf, u32 requested_bits) | ||
/* ensure we have aligned buffers */ | ||
BUILD_BUG_ON(LRNG_KCAPI_ALIGN % sizeof(unsigned long)); | ||
|
||
- for (i = 0; i < req; i += longs) { | ||
- longs = arch_get_random_seed_longs( | ||
- (unsigned long *)(outbuf + i), req - i); | ||
- if (longs) | ||
- continue; | ||
- longs = arch_get_random_longs((unsigned long *)(outbuf + i), | ||
- req - i); | ||
- if (!longs) { | ||
+ for (i = 0; i < (requested_bits >> 3); | ||
+ i += sizeof(unsigned long)) { | ||
+ if (!arch_get_random_seed_long((unsigned long *)(outbuf + i)) && | ||
+ !arch_get_random_long((unsigned long *)(outbuf + i))) { | ||
cpu_entropy = 0; | ||
return 0; | ||
} | ||
@@ -180,7 +175,7 @@ static u32 lrng_cpu_multiplier(void) | ||
if (data_multiplier > 0) | ||
return data_multiplier; | ||
|
||
- if (IS_ENABLED(CONFIG_X86) && !arch_get_random_seed_longs(&v, 1)) { | ||
+ if (IS_ENABLED(CONFIG_X86) && !arch_get_random_seed_long(&v)) { | ||
/* | ||
* Intel SPEC: pulling 512 blocks from RDRAND ensures | ||
* one reseed making it logically equivalent to RDSEED. | ||
--- linux-5.15.86/drivers/char/lrng/lrng_es_mgr.c.orig2 2023-01-07 21:18:49.376364123 +0100 | ||
+++ linux-5.15.86/drivers/char/lrng/lrng_es_mgr.c 2023-01-07 21:19:44.168291522 +0100 | ||
@@ -376,19 +376,12 @@ void __init lrng_rand_initialize_early(v | ||
sizeof(unsigned long))]; | ||
struct new_utsname utsname; | ||
} seed __aligned(LRNG_KCAPI_ALIGN); | ||
- size_t longs = 0; | ||
unsigned int i; | ||
|
||
- for (i = 0; i < ARRAY_SIZE(seed.data); i += longs) { | ||
- longs = arch_get_random_seed_longs(seed.data + i, | ||
- ARRAY_SIZE(seed.data) - i); | ||
- if (longs) | ||
- continue; | ||
- longs = arch_get_random_longs(seed.data + i, | ||
- ARRAY_SIZE(seed.data) - i); | ||
- if (longs) | ||
- continue; | ||
- longs = 1; | ||
+ for (i = 0; i < ARRAY_SIZE(seed.data); i++) { | ||
+ if (!arch_get_random_seed_long_early(&(seed.data[i])) && | ||
+ !arch_get_random_long_early(&seed.data[i])) | ||
+ seed.data[i] = random_get_entropy(); | ||
} | ||
memcpy(&seed.utsname, init_utsname(), sizeof(*(init_utsname()))); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- linux-5.15/drivers/char/lrng/lrng_sysctl.c.orig 2022-05-17 08:35:09.958660325 +0200 | ||
+++ linux-5.15/drivers/char/lrng/lrng_sysctl.c 2022-05-17 08:36:17.829818950 +0200 | ||
@@ -91,7 +91,7 @@ void lrng_sysctl_update_max_write_thresh | ||
mb(); | ||
} | ||
|
||
-static struct ctl_table random_table[] = { | ||
+struct ctl_table random_table[] = { | ||
{ | ||
.procname = "poolsize", | ||
.maxlen = sizeof(int), | ||
@@ -137,9 +137,3 @@ static struct ctl_table random_table[] = | ||
{ } | ||
}; | ||
|
||
-static int __init random_sysctls_init(void) | ||
-{ | ||
- register_sysctl_init("kernel/random", random_table); | ||
- return 0; | ||
-} | ||
-device_initcall(random_sysctls_init); |
Oops, something went wrong.