Fix detection of ktls support in cross-compile environment on Linux
authorTomas Mraz <tomas@openssl.org>
Wed, 14 Sep 2022 08:41:04 +0000 (10:41 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 19 Sep 2022 09:51:05 +0000 (11:51 +0200)
Fixes #19212

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19213)

(cherry picked from commit 9b25f52a4425d03fee1364d3531331d5d37ef742)

Configure

index 8caf5ae2fec9ffa8ecf2c9183e80c67a3a68f259..a558e5ab1a8b951a6cc7cb1de1ff89b98b05528b 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1714,20 +1714,13 @@ unless ($disabled{devcryptoeng}) {
 
 unless ($disabled{ktls}) {
     $config{ktls}="";
+    my $cc = $config{CROSS_COMPILE}.$config{CC};
     if ($target =~ m/^linux/) {
-        my $usr = "/usr/$config{cross_compile_prefix}";
-        chop($usr);
-        if ($config{cross_compile_prefix} eq "") {
-            $usr = "/usr";
-        }
-        my $minver = (4 << 16) + (13 << 8) + 0;
-        my @verstr = split(" ",`cat $usr/include/linux/version.h | grep LINUX_VERSION_CODE`);
-
-        if ($verstr[2] < $minver) {
+        system("printf '#include <sys/types.h>\n#include <linux/tls.h>' | $cc -E - >/dev/null 2>&1");
+        if ($? != 0) {
             disable('too-old-kernel', 'ktls');
         }
     } elsif ($target =~ m/^BSD/) {
-        my $cc = $config{CROSS_COMPILE}.$config{CC};
         system("printf '#include <sys/types.h>\n#include <sys/ktls.h>' | $cc -E - >/dev/null 2>&1");
         if ($? != 0) {
             disable('too-old-freebsd', 'ktls');