summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2023-10-09 13:52:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-10-13 11:17:11 +0200
commitb41b1c25e966f1d305ab5b5ad791b0b7efa2bd82 (patch)
tree58f00370b08217db3e1a05f2522012ac610ae2a8 /lib
parent4760228e8bbdf80d28e4cdcc3404d4ae5476a2e2 (diff)
downloadbarebox-b41b1c25e966f1d305ab5b5ad791b0b7efa2bd82.tar.gz
barebox-b41b1c25e966f1d305ab5b5ad791b0b7efa2bd82.tar.xz
lib: stackprot: improve error message on missing HWRNG
ERROR: no HWRNG available! WARNING: stackprot: proceeding without randomized stack protector Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231009115239.2291016-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/stackprot.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/stackprot.c b/lib/stackprot.c
index aa0e88603a..c1cc19aadd 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);