blob: 64f9cf52cb4d9ac3d34c927af3332a42b9f9ffea [file] [log] [blame]
Vernon Mauery8b7c1562022-09-27 16:10:38 -07001#include <ipmi-allowlist.hpp>
Vernon Mauery0d0cd162020-01-31 10:04:10 -08002#include <ipmid/api.hpp>
3#include <ipmid/utils.hpp>
Vernon Mauery0d0cd162020-01-31 10:04:10 -08004#include <phosphor-logging/log.hpp>
5#include <xyz/openbmc_project/Control/Security/RestrictionMode/server.hpp>
6
James Feistfcd2d3a2020-05-28 10:38:15 -07007#include <algorithm>
8#include <array>
9
Vernon Mauery0d0cd162020-01-31 10:04:10 -080010using namespace phosphor::logging;
Vernon Mauery0d0cd162020-01-31 10:04:10 -080011using namespace sdbusplus::xyz::openbmc_project::Control::Security::server;
12
13namespace ipmi
14{
15
16// put the filter provider in an unnamed namespace
17namespace
18{
19
Vernon Mauery8b7c1562022-09-27 16:10:38 -070020/** @class AllowlistFilter
Vernon Mauery0d0cd162020-01-31 10:04:10 -080021 *
22 * Class that implements an IPMI message filter based
23 * on incoming interface and a restriction mode setting
24 */
Vernon Mauery8b7c1562022-09-27 16:10:38 -070025class AllowlistFilter
Vernon Mauery0d0cd162020-01-31 10:04:10 -080026{
Vernon Mauery0d0cd162020-01-31 10:04:10 -080027 public:
Vernon Mauery8b7c1562022-09-27 16:10:38 -070028 AllowlistFilter();
29 ~AllowlistFilter() = default;
Patrick Williamsb37abfb2023-05-10 07:50:33 -050030 AllowlistFilter(const AllowlistFilter&) = delete;
Vernon Mauery8b7c1562022-09-27 16:10:38 -070031 AllowlistFilter(AllowlistFilter&&) = delete;
Patrick Williamsb37abfb2023-05-10 07:50:33 -050032 AllowlistFilter& operator=(const AllowlistFilter&) = delete;
Vernon Mauery8b7c1562022-09-27 16:10:38 -070033 AllowlistFilter& operator=(AllowlistFilter&&) = delete;
Vernon Mauery0d0cd162020-01-31 10:04:10 -080034
35 private:
36 void postInit();
37 void cacheRestrictedAndPostCompleteMode();
Patrick Williamsf944d2e2022-07-22 19:26:52 -050038 void handleRestrictedModeChange(sdbusplus::message_t& m);
39 void handlePostCompleteChange(sdbusplus::message_t& m);
Vernon Mauery0d0cd162020-01-31 10:04:10 -080040 void updatePostComplete(const std::string& value);
41 void updateRestrictionMode(const std::string& value);
42 ipmi::Cc filterMessage(ipmi::message::Request::ptr request);
Patrick Williamsf944d2e2022-07-22 19:26:52 -050043 void handleCoreBiosDoneChange(sdbusplus::message_t& m);
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +053044 void cacheCoreBiosDone();
Vernon Mauery0d0cd162020-01-31 10:04:10 -080045
46 // the BMC KCS Policy Control Modes document uses different names
47 // than the RestrictionModes D-Bus interface; use aliases
48 static constexpr RestrictionMode::Modes restrictionModeAllowAll =
49 RestrictionMode::Modes::Provisioning;
50 static constexpr RestrictionMode::Modes restrictionModeRestricted =
51 RestrictionMode::Modes::ProvisionedHostWhitelist;
52 static constexpr RestrictionMode::Modes restrictionModeDenyAll =
53 RestrictionMode::Modes::ProvisionedHostDisabled;
54
55 RestrictionMode::Modes restrictionMode = restrictionModeRestricted;
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +053056 bool postCompleted = true;
57 bool coreBIOSDone = true;
arun-pm849c3192020-02-12 18:10:32 +053058 int channelSMM = -1;
Vernon Mauery0d0cd162020-01-31 10:04:10 -080059 std::shared_ptr<sdbusplus::asio::connection> bus;
Patrick Williamsf944d2e2022-07-22 19:26:52 -050060 std::unique_ptr<sdbusplus::bus::match_t> modeChangeMatch;
61 std::unique_ptr<sdbusplus::bus::match_t> modeIntfAddedMatch;
62 std::unique_ptr<sdbusplus::bus::match_t> postCompleteMatch;
63 std::unique_ptr<sdbusplus::bus::match_t> postCompleteIntfAddedMatch;
64 std::unique_ptr<sdbusplus::bus::match_t> platStateChangeMatch;
65 std::unique_ptr<sdbusplus::bus::match_t> platStateIntfAddedMatch;
Vernon Mauery0d0cd162020-01-31 10:04:10 -080066
67 static constexpr const char restrictionModeIntf[] =
68 "xyz.openbmc_project.Control.Security.RestrictionMode";
69 static constexpr const char* systemOsStatusIntf =
70 "xyz.openbmc_project.State.OperatingSystem.Status";
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +053071 static constexpr const char* hostMiscIntf =
72 "xyz.openbmc_project.State.Host.Misc";
Arun P. Mohanan31c45f62021-10-18 21:52:39 +053073 static constexpr const char* restrictionModePath =
74 "/xyz/openbmc_project/control/security/restriction_mode";
75 static constexpr const char* systemOsStatusPath =
76 "/xyz/openbmc_project/state/os";
Vernon Mauery0d0cd162020-01-31 10:04:10 -080077};
78
arun-pm849c3192020-02-12 18:10:32 +053079static inline uint8_t getSMMChannel()
80{
81 ipmi::ChannelInfo chInfo;
82
83 for (int channel = 0; channel < ipmi::maxIpmiChannels; channel++)
84 {
85 if (ipmi::getChannelInfo(channel, chInfo) != ipmi::ccSuccess)
86 {
87 continue;
88 }
89
90 if (static_cast<ipmi::EChannelMediumType>(chInfo.mediumType) ==
91 ipmi::EChannelMediumType::systemInterface &&
92 channel != ipmi::channelSystemIface)
93 {
94 log<level::INFO>("SMM channel number",
95 entry("CHANNEL=%d", channel));
96 return channel;
97 }
98 }
99 log<level::ERR>("Unable to find SMM Channel Info");
100 return -1;
101}
102
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700103AllowlistFilter::AllowlistFilter()
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800104{
105 bus = getSdBus();
106
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700107 log<level::INFO>("Loading Allowlist filter");
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800108
109 ipmi::registerFilter(ipmi::prioOpenBmcBase,
110 [this](ipmi::message::Request::ptr request) {
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500111 return filterMessage(request);
112 });
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800113
arun-pm849c3192020-02-12 18:10:32 +0530114 channelSMM = getSMMChannel();
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800115 // wait until io->run is going to fetch RestrictionMode
116 post_work([this]() { postInit(); });
117}
118
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700119void AllowlistFilter::cacheRestrictedAndPostCompleteMode()
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800120{
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800121 try
122 {
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500123 auto service = ipmi::getService(*bus, restrictionModeIntf,
124 restrictionModePath);
Arun P. Mohanan31c45f62021-10-18 21:52:39 +0530125 ipmi::Value v =
126 ipmi::getDbusProperty(*bus, service, restrictionModePath,
127 restrictionModeIntf, "RestrictionMode");
128 auto& mode = std::get<std::string>(v);
129 restrictionMode = RestrictionMode::convertModesFromString(mode);
130 log<level::INFO>("Read restriction mode",
131 entry("VALUE=%d", static_cast<int>(restrictionMode)));
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800132 }
133 catch (const std::exception&)
134 {
Arun P. Mohanan31c45f62021-10-18 21:52:39 +0530135 log<level::ERR>("Could not initialize provisioning mode, "
136 "defaulting to restricted",
137 entry("VALUE=%d", static_cast<int>(restrictionMode)));
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800138 }
139
Arun P. Mohanan31c45f62021-10-18 21:52:39 +0530140 try
141 {
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500142 auto service = ipmi::getService(*bus, systemOsStatusIntf,
143 systemOsStatusPath);
144 ipmi::Value v = ipmi::getDbusProperty(*bus, service, systemOsStatusPath,
145 systemOsStatusIntf,
146 "OperatingSystemState");
Arun P. Mohanan31c45f62021-10-18 21:52:39 +0530147 auto& value = std::get<std::string>(v);
Andrei Kartashevbc9a82d2021-12-27 17:21:50 +0300148 updatePostComplete(value);
Arun P. Mohanan31c45f62021-10-18 21:52:39 +0530149 log<level::INFO>("Read POST complete value",
150 entry("VALUE=%d", postCompleted));
151 }
152 catch (const std::exception&)
153 {
154 log<level::ERR>("Error in OperatingSystemState Get");
155 postCompleted = true;
156 }
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800157}
158
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700159void AllowlistFilter::updateRestrictionMode(const std::string& value)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800160{
161 restrictionMode = RestrictionMode::convertModesFromString(value);
162 log<level::INFO>("Updated restriction mode",
163 entry("VALUE=%d", static_cast<int>(restrictionMode)));
164}
165
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700166void AllowlistFilter::handleRestrictedModeChange(sdbusplus::message_t& m)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800167{
168 std::string signal = m.get_member();
169 if (signal == "PropertiesChanged")
170 {
171 std::string intf;
172 std::vector<std::pair<std::string, ipmi::Value>> propertyList;
173 m.read(intf, propertyList);
174 for (const auto& property : propertyList)
175 {
176 if (property.first == "RestrictionMode")
177 {
178 updateRestrictionMode(std::get<std::string>(property.second));
179 }
180 }
181 }
182 else if (signal == "InterfacesAdded")
183 {
184 sdbusplus::message::object_path path;
185 DbusInterfaceMap restModeObj;
186 m.read(path, restModeObj);
187 auto intfItr = restModeObj.find(restrictionModeIntf);
188 if (intfItr == restModeObj.end())
189 {
190 return;
191 }
192 PropertyMap& propertyList = intfItr->second;
193 auto itr = propertyList.find("RestrictionMode");
194 if (itr == propertyList.end())
195 {
196 return;
197 }
198 updateRestrictionMode(std::get<std::string>(itr->second));
199 }
200}
201
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700202void AllowlistFilter::updatePostComplete(const std::string& value)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800203{
Andrei Kartashevbc9a82d2021-12-27 17:21:50 +0300204 // The short string "Standby" is deprecated in favor of the full enum string
205 // Support for the short string will be removed in the future.
206 postCompleted = (value == "Standby") ||
207 (value == "xyz.openbmc_project.State.OperatingSystem."
208 "Status.OSStatus.Standby");
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800209 log<level::INFO>(postCompleted ? "Updated to POST Complete"
210 : "Updated to !POST Complete");
211}
212
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700213void AllowlistFilter::handlePostCompleteChange(sdbusplus::message_t& m)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800214{
215 std::string signal = m.get_member();
216 if (signal == "PropertiesChanged")
217 {
218 std::string intf;
219 std::vector<std::pair<std::string, ipmi::Value>> propertyList;
220 m.read(intf, propertyList);
221 for (const auto& property : propertyList)
222 {
223 if (property.first == "OperatingSystemState")
224 {
225 updatePostComplete(std::get<std::string>(property.second));
226 }
227 }
228 }
229 else if (signal == "InterfacesAdded")
230 {
231 sdbusplus::message::object_path path;
232 DbusInterfaceMap postCompleteObj;
233 m.read(path, postCompleteObj);
234 auto intfItr = postCompleteObj.find(systemOsStatusIntf);
235 if (intfItr == postCompleteObj.end())
236 {
237 return;
238 }
239 PropertyMap& propertyList = intfItr->second;
240 auto itr = propertyList.find("OperatingSystemState");
241 if (itr == propertyList.end())
242 {
243 return;
244 }
245 updatePostComplete(std::get<std::string>(itr->second));
246 }
247}
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530248
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700249void AllowlistFilter::cacheCoreBiosDone()
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530250{
251 std::string coreBiosDonePath;
252 std::string coreBiosDoneService;
253 try
254 {
255 ipmi::DbusObjectInfo coreBiosDoneObj =
256 ipmi::getDbusObject(*bus, hostMiscIntf);
257
258 coreBiosDonePath = coreBiosDoneObj.first;
259 coreBiosDoneService = coreBiosDoneObj.second;
260 }
261 catch (const std::exception&)
262 {
263 log<level::ERR>("Could not initialize CoreBiosDone, "
264 "coreBIOSDone asserted as default");
265 return;
266 }
267
268 bus->async_method_call(
269 [this](boost::system::error_code ec, const ipmi::Value& v) {
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500270 if (ec)
271 {
272 log<level::ERR>(
273 "async call failed, coreBIOSDone asserted as default");
274 return;
275 }
276 coreBIOSDone = std::get<bool>(v);
277 log<level::INFO>("Read CoreBiosDone",
278 entry("VALUE=%d", static_cast<int>(coreBIOSDone)));
Patrick Williams87381412023-10-20 11:18:48 -0500279 },
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530280 coreBiosDoneService, coreBiosDonePath,
281 "org.freedesktop.DBus.Properties", "Get", hostMiscIntf, "CoreBiosDone");
282}
283
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700284void AllowlistFilter::handleCoreBiosDoneChange(sdbusplus::message_t& msg)
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530285{
286 std::string signal = msg.get_member();
287 if (signal == "PropertiesChanged")
288 {
289 std::string intf;
290 std::vector<std::pair<std::string, ipmi::Value>> propertyList;
291 msg.read(intf, propertyList);
292 auto it =
293 std::find_if(propertyList.begin(), propertyList.end(),
294 [](const std::pair<std::string, ipmi::Value>& prop) {
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500295 return prop.first == "CoreBiosDone";
Patrick Williams87381412023-10-20 11:18:48 -0500296 });
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530297
298 if (it != propertyList.end())
299 {
300 coreBIOSDone = std::get<bool>(it->second);
301 log<level::INFO>(coreBIOSDone ? "coreBIOSDone asserted"
302 : "coreBIOSDone not asserted");
303 }
304 }
305 else if (signal == "InterfacesAdded")
306 {
307 sdbusplus::message::object_path path;
308 DbusInterfaceMap eSpiresetObj;
309 msg.read(path, eSpiresetObj);
310 auto intfItr = eSpiresetObj.find(hostMiscIntf);
311 if (intfItr == eSpiresetObj.end())
312 {
313 return;
314 }
315 PropertyMap& propertyList = intfItr->second;
316 auto itr = propertyList.find("CoreBiosDone");
317 if (itr == propertyList.end())
318 {
319 return;
320 }
321 coreBIOSDone = std::get<bool>(itr->second);
322 log<level::INFO>(coreBIOSDone ? "coreBIOSDone asserted"
323 : "coreBIOSDone not asserted");
324 }
325}
326
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700327void AllowlistFilter::postInit()
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800328{
329 // Wait for changes on Restricted mode
330 namespace rules = sdbusplus::bus::match::rules;
331 const std::string filterStrModeChange =
332 rules::type::signal() + rules::member("PropertiesChanged") +
333 rules::interface("org.freedesktop.DBus.Properties") +
334 rules::argN(0, restrictionModeIntf);
335
336 const std::string filterStrModeIntfAdd =
337 rules::interfacesAdded() +
338 rules::argNpath(
339 0, "/xyz/openbmc_project/control/security/restriction_mode");
340
341 const std::string filterStrPostComplete =
342 rules::type::signal() + rules::member("PropertiesChanged") +
343 rules::interface("org.freedesktop.DBus.Properties") +
344 rules::argN(0, systemOsStatusIntf);
345
346 const std::string filterStrPostIntfAdd =
347 rules::interfacesAdded() +
348 rules::argNpath(0, "/xyz/openbmc_project/state/os");
349
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530350 const std::string filterStrPlatStateChange =
351 rules::type::signal() + rules::member("PropertiesChanged") +
352 rules::interface("org.freedesktop.DBus.Properties") +
353 rules::argN(0, hostMiscIntf);
354
355 const std::string filterStrPlatStateIntfAdd =
356 rules::interfacesAdded() +
357 rules::argNpath(0, "/xyz/openbmc_project/misc/platform_state");
358
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500359 modeChangeMatch = std::make_unique<sdbusplus::bus::match_t>(
360 *bus, filterStrModeChange,
361 [this](sdbusplus::message_t& m) { handleRestrictedModeChange(m); });
362 modeIntfAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
363 *bus, filterStrModeIntfAdd,
364 [this](sdbusplus::message_t& m) { handleRestrictedModeChange(m); });
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800365
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500366 postCompleteMatch = std::make_unique<sdbusplus::bus::match_t>(
367 *bus, filterStrPostComplete,
368 [this](sdbusplus::message_t& m) { handlePostCompleteChange(m); });
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800369
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500370 postCompleteIntfAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
371 *bus, filterStrPostIntfAdd,
372 [this](sdbusplus::message_t& m) { handlePostCompleteChange(m); });
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800373
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500374 platStateChangeMatch = std::make_unique<sdbusplus::bus::match_t>(
375 *bus, filterStrPlatStateChange,
376 [this](sdbusplus::message_t& m) { handleCoreBiosDoneChange(m); });
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530377
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500378 platStateIntfAddedMatch = std::make_unique<sdbusplus::bus::match_t>(
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530379 *bus, filterStrPlatStateIntfAdd,
Patrick Williamsf944d2e2022-07-22 19:26:52 -0500380 [this](sdbusplus::message_t& m) { handleCoreBiosDoneChange(m); });
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530381
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800382 // Initialize restricted mode
383 cacheRestrictedAndPostCompleteMode();
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530384 // Initialize CoreBiosDone
385 cacheCoreBiosDone();
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800386}
387
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700388ipmi::Cc AllowlistFilter::filterMessage(ipmi::message::Request::ptr request)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800389{
390 auto channelMask = static_cast<unsigned short>(1 << request->ctx->channel);
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700391 bool Allowlisted = std::binary_search(
392 allowlist.cbegin(), allowlist.cend(),
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800393 std::make_tuple(request->ctx->netFn, request->ctx->cmd, channelMask),
394 [](const netfncmd_tuple& first, const netfncmd_tuple& value) {
Patrick Williamsb37abfb2023-05-10 07:50:33 -0500395 return (std::get<2>(first) & std::get<2>(value))
396 ? first < std::make_tuple(std::get<0>(value),
397 std::get<1>(value),
398 std::get<2>(first))
399 : first < value;
Patrick Williams87381412023-10-20 11:18:48 -0500400 });
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800401
402 // no special handling for non-system-interface channels
arun-pm849c3192020-02-12 18:10:32 +0530403 if (!(request->ctx->channel == ipmi::channelSystemIface ||
404 request->ctx->channel == channelSMM))
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800405 {
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700406 if (!Allowlisted)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800407 {
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700408 log<level::INFO>("Channel/NetFn/Cmd not Allowlisted",
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800409 entry("CHANNEL=0x%X", request->ctx->channel),
410 entry("NETFN=0x%X", int(request->ctx->netFn)),
411 entry("CMD=0x%X", int(request->ctx->cmd)));
Snehalatha V65b66ad2020-07-09 14:58:39 +0000412 return ipmi::ccInsufficientPrivilege;
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800413 }
414 return ipmi::ccSuccess;
415 }
416
417 // for system interface, filtering is done as follows:
418 // Allow All: preboot ? ccSuccess : ccSuccess
419 // Restricted: preboot ? ccSuccess :
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700420 // ( Allowlist ? ccSuccess : ccInsufficientPrivilege )
Snehalatha V65b66ad2020-07-09 14:58:39 +0000421 // Deny All: preboot ? ccSuccess : ccInsufficientPrivilege
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800422
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530423 if (!(postCompleted || coreBIOSDone))
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800424 {
Arun P. Mohanana4cea1a2020-03-18 16:01:57 +0530425 // Allow all commands, till POST or CoreBiosDone is completed
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800426 return ipmi::ccSuccess;
427 }
428
429 switch (restrictionMode)
430 {
431 case RestrictionMode::Modes::None:
432 case restrictionModeAllowAll:
433 {
434 // Allow All
435 return ipmi::ccSuccess;
436 break;
437 }
438 case restrictionModeRestricted:
439 {
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700440 // Restricted - follow Allowlist
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800441 break;
442 }
443 case restrictionModeDenyAll:
444 {
445 // Deny All
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700446 Allowlisted = false;
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800447 break;
448 }
Matt Simmering80d4d5f2023-02-15 15:18:51 -0800449 default: // for Allowlist and Blocklist
Snehalatha V65b66ad2020-07-09 14:58:39 +0000450 return ipmi::ccInsufficientPrivilege;
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800451 }
452
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700453 if (!Allowlisted)
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800454 {
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700455 log<level::INFO>("Channel/NetFn/Cmd not allowlisted",
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800456 entry("CHANNEL=0x%X", request->ctx->channel),
457 entry("NETFN=0x%X", int(request->ctx->netFn)),
458 entry("CMD=0x%X", int(request->ctx->cmd)));
Snehalatha V65b66ad2020-07-09 14:58:39 +0000459 return ipmi::ccInsufficientPrivilege;
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800460 }
461 return ipmi::ccSuccess;
462} // namespace
463
Vernon Mauery8b7c1562022-09-27 16:10:38 -0700464// instantiate the AllowlistFilter when this shared object is loaded
465AllowlistFilter allowlistFilter;
Vernon Mauery0d0cd162020-01-31 10:04:10 -0800466
467} // namespace
468
469} // namespace ipmi