git: 5f5c20f3b2a8 - stable/12 - Avoid returning a NULL pointer from the Intel hw PRNG ifunc resolver.

From: David E. O'Brien <obrien_at_FreeBSD.org>
Date: Mon, 21 Feb 2022 08:07:45 UTC
The branch stable/12 has been updated by obrien:

URL: https://cgit.FreeBSD.org/src/commit/?id=5f5c20f3b2a8f58e1f4ace73aa92a9f4ae46568c

commit 5f5c20f3b2a8f58e1f4ace73aa92a9f4ae46568c
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2019-05-10 04:28:17 +0000
Commit:     David E. O'Brien <obrien@FreeBSD.org>
CommitDate: 2022-02-21 05:56:42 +0000

    Avoid returning a NULL pointer from the Intel hw PRNG ifunc resolver.
    
    DTrace expects kernel function symbols of a non-zero size to have an
    implementation, which is a reasonable invariant to preserve.
    
    (cherry picked from commit b870199522666a66e378e90ca3dbef39c30f12c6)
---
 sys/dev/random/ivy.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/dev/random/ivy.c b/sys/dev/random/ivy.c
index 5ff288b394ac..e45e6a2d1242 100644
--- a/sys/dev/random/ivy.c
+++ b/sys/dev/random/ivy.c
@@ -97,6 +97,13 @@ x86_rdseed_store(u_long *buf)
 	return (retry);
 }
 
+static int
+x86_unimpl_store(u_long *buf __unused)
+{
+
+	panic("%s called", __func__);
+}
+
 DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf), static)
 {
 	has_rdrand = (cpu_feature2 & CPUID2_RDRAND);
@@ -107,7 +114,7 @@ DEFINE_IFUNC(static, int, x86_rng_store, (u_long *buf), static)
 	else if (has_rdrand)
 		return (x86_rdrand_store);
 	else
-		return (NULL);
+		return (x86_unimpl_store);
 }
 
 /* It is required that buf length is a multiple of sizeof(u_long). */