]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/vulnerabilities.cgi
speed.cgi: Use new system methods
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / vulnerabilities.cgi
index 27643d16cccf7d5bd8cdf0541d8d2f754106976f..926f043b87a90db59b80f4456c45982e9463939b 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2019  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2020  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -30,12 +30,15 @@ require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
 
 my %VULNERABILITIES = (
+       "itlb_multihit" => "$Lang::tr{'itlb multihit'} (CVE-2018-12207)",
        "l1tf" => "$Lang::tr{'foreshadow'} (CVE-2018-3620)",
        "mds" => "$Lang::tr{'fallout zombieload ridl'} (CVE-2018-12126, CVE-2018-12130, CVE-2018-12127, CVE-2019-11091)",
        "meltdown" => "$Lang::tr{'meltdown'} (CVE-2017-5754)",
        "spec_store_bypass" => "$Lang::tr{'spectre variant 4'} (CVE-2018-3639)",
        "spectre_v1" => "$Lang::tr{'spectre variant 1'} (CVE-2017-5753)",
        "spectre_v2" => "$Lang::tr{'spectre variant 2'} (CVE-2017-5715)",
+       "srbds" => "$Lang::tr{'srbds'} (CVE-2020-0543)",
+       "tsx_async_abort" => "$Lang::tr{'taa zombieload2'} (CVE-2019-11135)",
 );
 
 my $errormessage = "";
@@ -44,7 +47,7 @@ my $notice = "";
 my %mainsettings = ();
 my %color = ();
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 my %settings = (
        "ENABLE_SMT" => "auto",
@@ -117,7 +120,7 @@ for my $vuln (sort keys %VULNERABILITIES) {
        if ($status eq "Not affected") {
                $status_message = $Lang::tr{'not affected'};
                $colour = "white";
-               $bgcolour = ${Header::colourblack};
+               $bgcolour = ${Header::colourgreen};
 
        # Vulnerable
        } elsif ($status eq "Vulnerable") {
@@ -128,11 +131,14 @@ for my $vuln (sort keys %VULNERABILITIES) {
        # Mitigated
        } elsif ($status eq "Mitigation") {
                $status_message = $Lang::tr{'mitigated'};
-               $colour = "black";
-               $bgcolour = ${Header::colourorange};
+               $colour = "white";
+               $bgcolour = ${Header::colourblue};
 
+       # Unknown report from kernel
        } else {
-               next;
+               $status_message = $status;
+               $colour = "black";
+               $bgcolour = ${Header::colouryellow};
        }
 
        my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
@@ -147,7 +153,7 @@ for my $vuln (sort keys %VULNERABILITIES) {
                                <font color="$colour">
 END
        if ($message) {
-               print "<strong>$status_message</strong>: $message";
+               print "<strong>$status_message</strong> - $message";
        } else {
                print "<strong>$status_message</strong>";
        }
@@ -170,12 +176,20 @@ print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
 
 &Header::openbox('100%', 'center', $Lang::tr{'settings'});
 
+my $smt_status = &smt_status();
+
 print <<END;
        <table class="tbl" width="66%">
                <tbody>
+                       <tr>
+                               <th colspan="2" align="center">
+                                       <strong>$smt_status</strong>
+                               </th>
+                       </tr>
+
                        <tr>
                                <td width="50%" align="left">
-                                       <strong>$Lang::tr{'enable smt'}</strong>
+                                       $Lang::tr{'enable smt'}
                                </td>
 
                                <td width="50%" align="center">
@@ -216,9 +230,34 @@ sub check_status($) {
        my $status = <FILE>;
        close(FILE);
 
-       if ($status =~ /^(Mitigation): (.*)$/) {
+       chomp($status);
+
+       # Fix status when something has been mitigated, but not fully, yet
+       if ($status =~ /^(Mitigation): (.*vulnerable.*)$/) {
+               return ("Vulnerable", $status);
+       }
+
+       if ($status =~ /^(Vulnerable|Mitigation): (.*)$/) {
                return ($1, $2);
        } 
 
        return $status;
 }
+
+sub smt_status() {
+       open(FILE, "/sys/devices/system/cpu/smt/control");
+       my $status = <FILE>;
+       close(FILE);
+
+       chomp($status);
+
+       if ($status eq "on") {
+               return $Lang::tr{'smt enabled'};
+       } elsif (($status eq "off") || ($status eq "forceoff")) {
+               return $Lang::tr{'smt disabled'};
+       } elsif ($status eq "notsupported") {
+               return $Lang::tr{'smt not supported'};
+       }
+
+       return $status;
+}