]> git.ipfire.org Git - ipfire-2.x.git/blame - html/cgi-bin/vulnerabilities.cgi
vulnerabilities.cgi: Add MMIO Stale Data
[ipfire-2.x.git] / html / cgi-bin / vulnerabilities.cgi
CommitLineData
65871d1a
MT
1#!/usr/bin/perl
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
34798dcd 5# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
65871d1a
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
21
22use strict;
23
24# enable only the following on debugging purpose
f238e251
MT
25#use warnings;
26#use CGI::Carp 'fatalsToBrowser';
65871d1a
MT
27
28require '/var/ipfire/general-functions.pl';
29require "${General::swroot}/lang.pl";
30require "${General::swroot}/header.pl";
31
32my %VULNERABILITIES = (
6fb52ca1 33 "itlb_multihit" => "$Lang::tr{'itlb multihit'} (CVE-2018-12207)",
65871d1a
MT
34 "l1tf" => "$Lang::tr{'foreshadow'} (CVE-2018-3620)",
35 "mds" => "$Lang::tr{'fallout zombieload ridl'} (CVE-2018-12126, CVE-2018-12130, CVE-2018-12127, CVE-2019-11091)",
36 "meltdown" => "$Lang::tr{'meltdown'} (CVE-2017-5754)",
34798dcd 37 "mmio_stale_data" => "$Lang::tr{'mmio stale data'} (CVE-2022-21123, CVE-2022-21125, CVE-2022-21127, CVE-2022-21166)",
65871d1a
MT
38 "spec_store_bypass" => "$Lang::tr{'spectre variant 4'} (CVE-2018-3639)",
39 "spectre_v1" => "$Lang::tr{'spectre variant 1'} (CVE-2017-5753)",
40 "spectre_v2" => "$Lang::tr{'spectre variant 2'} (CVE-2017-5715)",
e9c62e37 41 "srbds" => "$Lang::tr{'srbds'} (CVE-2020-0543)",
6fb52ca1 42 "tsx_async_abort" => "$Lang::tr{'taa zombieload2'} (CVE-2019-11135)",
65871d1a
MT
43);
44
45my $errormessage = "";
46my $notice = "";
47
48my %mainsettings = ();
49my %color = ();
50&General::readhash("${General::swroot}/main/settings", \%mainsettings);
8186b372 51&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
65871d1a
MT
52
53my %settings = (
54 "ENABLE_SMT" => "auto",
55);
56&General::readhash("${General::swroot}/main/security", \%settings);
57
58&Header::showhttpheaders();
59
60&Header::getcgihash(\%settings);
61
62if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
63 if ($settings{'ENABLE_SMT'} !~ /^(auto|on)$/) {
64 $errormessage = $Lang::tr{'invalid input'};
65 }
66
67 unless ($errormessage) {
68 &General::writehash("${General::swroot}/main/security", \%settings);
69 $notice = $Lang::tr{'please reboot to apply your changes'};
70 }
71}
72
73my %checked = ();
74$checked{'ENABLE_SMT'}{'auto'} = '';
75$checked{'ENABLE_SMT'}{'on'} = '';
76$checked{'ENABLE_SMT'}{$settings{'ENABLE_SMT'}} = "checked";
77
78&Header::openpage($Lang::tr{'processor vulnerability mitigations'}, 1, '');
79
80&Header::openbigbox("100%", "left", "", $errormessage);
81
82if ($errormessage) {
83 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
84 print "<font color='red'>$errormessage</font>";
85 &Header::closebox();
86}
87
88if ($notice) {
89 &Header::openbox('100%', 'left', $Lang::tr{'notice'});
90 print "<font color='red'>$notice</font>";
91 &Header::closebox();
92}
93
94&Header::openbox('100%', 'center', $Lang::tr{'processor vulnerability mitigations'});
95
96print <<END;
97 <table class="tbl" width='100%'>
98 <thead>
99 <tr>
100 <th align="center">
101 <strong>$Lang::tr{'vulnerability'}</strong>
102 </th>
103 <th align="center">
104 <strong>$Lang::tr{'status'}</strong>
105 </th>
106 </tr>
107 </thead>
108 <tbody>
109END
110
111my $id = 0;
112for my $vuln (sort keys %VULNERABILITIES) {
113 my ($status, $message) = &check_status($vuln);
114 next if (!$status);
115
116 my $colour = "";
117 my $bgcolour = "";
118 my $status_message = "";
119
120 # Not affected
121 if ($status eq "Not affected") {
122 $status_message = $Lang::tr{'not affected'};
123 $colour = "white";
29abc2d0 124 $bgcolour = ${Header::colourgreen};
65871d1a
MT
125
126 # Vulnerable
127 } elsif ($status eq "Vulnerable") {
128 $status_message = $Lang::tr{'vulnerable'};
129 $colour = "white";
130 $bgcolour = ${Header::colourred};
131
132 # Mitigated
133 } elsif ($status eq "Mitigation") {
134 $status_message = $Lang::tr{'mitigated'};
984a6cab 135 $colour = "white";
29abc2d0 136 $bgcolour = ${Header::colourblue};
65871d1a 137
984a6cab 138 # Unknown report from kernel
65871d1a 139 } else {
b23db9b9 140 $status_message = $status;
984a6cab
AF
141 $colour = "black";
142 $bgcolour = ${Header::colouryellow};
65871d1a
MT
143 }
144
145 my $table_colour = ($id++ % 2) ? $color{'color22'} : $color{'color20'};
146
147 print <<END;
148 <tr bgcolor="$table_colour">
149 <td align="left">
150 <strong>$VULNERABILITIES{$vuln}</strong>
151 </td>
152
153 <td bgcolor="$bgcolour" align="center">
154 <font color="$colour">
155END
156 if ($message) {
e896a9bd 157 print "<strong>$status_message</strong> - $message";
65871d1a
MT
158 } else {
159 print "<strong>$status_message</strong>";
160 }
161
162 print <<END;
163 </font>
164 </td>
165 </tr>
166END
167 }
168
169print <<END;
170 </tbody>
171 </table>
172END
173
174&Header::closebox();
175
176print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n";
177
178&Header::openbox('100%', 'center', $Lang::tr{'settings'});
179
1cbcd044
MT
180my $smt_status = &smt_status();
181
65871d1a
MT
182print <<END;
183 <table class="tbl" width="66%">
184 <tbody>
1cbcd044
MT
185 <tr>
186 <th colspan="2" align="center">
187 <strong>$smt_status</strong>
188 </th>
189 </tr>
190
65871d1a
MT
191 <tr>
192 <td width="50%" align="left">
1cbcd044 193 $Lang::tr{'enable smt'}
65871d1a
MT
194 </td>
195
196 <td width="50%" align="center">
197 <label>
198 <input type="radio" name="ENABLE_SMT"
199 value="auto" $checked{'ENABLE_SMT'}{'auto'}>
200 $Lang::tr{'automatic'}
201 </label> /
202 <label>
203 <input type="radio" name="ENABLE_SMT"
204 value="on" $checked{'ENABLE_SMT'}{'on'}>
205 $Lang::tr{'force enable'} ($Lang::tr{'dangerous'})
206 </label>
207 </td>
208 </tr>
209
210 <tr>
211 <td colspan="2" align="right">
212 <input type="submit" name="ACTION" value="$Lang::tr{'save'}">
213 </td>
214 </tr>
215 </tbody>
216 </table>
217END
218
219&Header::closebox();
220
221print "</form>\n";
222
223&Header::closebigbox();
224
225&Header::closepage();
226
227sub check_status($) {
228 my $vuln = shift;
229
230 open(FILE, "/sys/devices/system/cpu/vulnerabilities/$vuln") or return undef;
231 my $status = <FILE>;
232 close(FILE);
233
e896a9bd
AF
234 chomp($status);
235
413f84e9 236 # Fix status when something has been mitigated, but not fully, yet
b23db9b9 237 if ($status =~ /^(Mitigation): (.*vulnerable.*)$/) {
e896a9bd 238 return ("Vulnerable", $status);
b23db9b9
AF
239 }
240
a96bcf41 241 if ($status =~ /^(Vulnerable|Mitigation): (.*)$/) {
65871d1a 242 return ($1, $2);
66c36198 243 }
65871d1a
MT
244
245 return $status;
246}
1cbcd044
MT
247
248sub smt_status() {
249 open(FILE, "/sys/devices/system/cpu/smt/control");
250 my $status = <FILE>;
251 close(FILE);
252
253 chomp($status);
254
255 if ($status eq "on") {
256 return $Lang::tr{'smt enabled'};
257 } elsif (($status eq "off") || ($status eq "forceoff")) {
258 return $Lang::tr{'smt disabled'};
259 } elsif ($status eq "notsupported") {
260 return $Lang::tr{'smt not supported'};
261 }
262
263 return $status;
264}