[PATCH 3/5] lib: stackprot: improve error message on missing HWRNG

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Oct 9 04:52:37 PDT 2023


ERROR: no HWRNG available!
WARNING: stackprot: proceeding without randomized stack protector

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 lib/stackprot.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/stackprot.c b/lib/stackprot.c
index aa0e88603aae..c1cc19aadd09 100644
--- a/lib/stackprot.c
+++ b/lib/stackprot.c
@@ -1,5 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
-#include <printk.h>
+
+#define pr_fmt(fmt) "stackprot: " fmt
+
+#include <linux/printk.h>
 #include <linux/kernel.h>
 #include <linux/export.h>
 #include <init.h>
@@ -27,6 +30,11 @@ EXPORT_SYMBOL(__stack_chk_fail);
 
 static __no_stack_protector int stackprot_randomize_guard(void)
 {
-	return get_crypto_bytes(&__stack_chk_guard, sizeof(__stack_chk_guard));
+	int ret;
+
+	ret = get_crypto_bytes(&__stack_chk_guard, sizeof(__stack_chk_guard));
+	if (ret)
+		pr_warn("proceeding without randomized stack protector\n");
+	return 0;
 }
 late_initcall(stackprot_randomize_guard);
-- 
2.39.2




More information about the barebox mailing list