#!/usr/bin/perl ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2007-2019 IPFire Team # # # # 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 # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### use strict; # enable only the following on debugging purpose #use warnings; #use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; 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)", "tsx_async_abort" => "$Lang::tr{'taa zombieload2'} (CVE-2019-11135)", ); my $errormessage = ""; 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); my %settings = ( "ENABLE_SMT" => "auto", ); &General::readhash("${General::swroot}/main/security", \%settings); &Header::showhttpheaders(); &Header::getcgihash(\%settings); if ($settings{'ACTION'} eq $Lang::tr{'save'}) { if ($settings{'ENABLE_SMT'} !~ /^(auto|on)$/) { $errormessage = $Lang::tr{'invalid input'}; } unless ($errormessage) { &General::writehash("${General::swroot}/main/security", \%settings); $notice = $Lang::tr{'please reboot to apply your changes'}; } } my %checked = (); $checked{'ENABLE_SMT'}{'auto'} = ''; $checked{'ENABLE_SMT'}{'on'} = ''; $checked{'ENABLE_SMT'}{$settings{'ENABLE_SMT'}} = "checked"; &Header::openpage($Lang::tr{'processor vulnerability mitigations'}, 1, ''); &Header::openbigbox("100%", "left", "", $errormessage); if ($errormessage) { &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); print "$errormessage"; &Header::closebox(); } if ($notice) { &Header::openbox('100%', 'left', $Lang::tr{'notice'}); print "$notice"; &Header::closebox(); } &Header::openbox('100%', 'center', $Lang::tr{'processor vulnerability mitigations'}); print < $Lang::tr{'vulnerability'} $Lang::tr{'status'} END my $id = 0; for my $vuln (sort keys %VULNERABILITIES) { my ($status, $message) = &check_status($vuln); next if (!$status); my $colour = ""; my $bgcolour = ""; my $status_message = ""; # Not affected if ($status eq "Not affected") { $status_message = $Lang::tr{'not affected'}; $colour = "white"; $bgcolour = ${Header::colourgreen}; # Vulnerable } elsif ($status eq "Vulnerable") { $status_message = $Lang::tr{'vulnerable'}; $colour = "white"; $bgcolour = ${Header::colourred}; # Mitigated } elsif ($status eq "Mitigation") { $status_message = $Lang::tr{'mitigated'}; $colour = "white"; $bgcolour = ${Header::colourblue}; # Unknown report from kernel } else { $status_message = $status; $colour = "black"; $bgcolour = ${Header::colouryellow}; } my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'}; print < $VULNERABILITIES{$vuln} END if ($message) { print "$status_message - $message"; } else { print "$status_message"; } print < END } print < END &Header::closebox(); print "
\n"; &Header::openbox('100%', 'center', $Lang::tr{'settings'}); my $smt_status = &smt_status(); print < $smt_status $Lang::tr{'enable smt'} / END &Header::closebox(); print "\n"; &Header::closebigbox(); &Header::closepage(); sub check_status($) { my $vuln = shift; open(FILE, "/sys/devices/system/cpu/vulnerabilities/$vuln") or return undef; my $status = ; close(FILE); 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 = ; 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; }