Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Carles Pey <[email protected]>
  • Loading branch information
cpey committed Apr 23, 2024
1 parent eaad11a commit 797e09c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions chipsec/modules/tools/smm/smm_ptr.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ def clear(self):
self.confirmed = False

def add(self, duration, code, data, gprs, confirmed=False):
if duration is None:
return
if not self.code:
self.code = code
outlier = self.is_outlier(duration)
Expand Down Expand Up @@ -444,6 +446,7 @@ def smi_fuzz_iter(self, thread_id, _addr, _smi_desc, fill_contents=True, restore
if not scan:
self.send_smi(thread_id, _smi_desc.smi_code, _smi_desc.smi_data, _smi_desc.name, _smi_desc.desc, _rax, _rbx, _rcx, _rdx, _rsi, _rdi)
else:
duration = None
_, duration = self.send_smi_timed(thread_id, _smi_desc.smi_code, _smi_desc.smi_data, _smi_desc.name, _smi_desc.desc, _rax, _rbx, _rcx, _rdx, _rsi, _rdi)
#
# Re-do the call if it was identified as an outlier, due to periodic SMI delays
Expand Down Expand Up @@ -484,7 +487,7 @@ def test_config(self, thread_id, _smi_config_fname, _addr, _addr1):
for line in fcfg:
if '' == line.strip():
self.logger.log(f'\n[*] Testing SMI# 0x{_smi_desc.smi_code:02X} (data: 0x{_smi_desc.smi_data:02X}) {_smi_desc.name} ({_smi_desc.desc})')
if selfsmi_fuzz_iter(thread_id, _addr, _smi_desc):
if self.smi_fuzz_iter(thread_id, _addr, _smi_desc):
bad_ptr_cnt += 1
_smi_desc = None
_smi_desc = smi_desc()
Expand Down Expand Up @@ -608,7 +611,7 @@ def test_fuzz(self, thread_id, smic_start, smic_end, _addr, _addr1, scan_mode=Tr
if scan and scan.skip():
break
if scan_mode:
msg = scan.log_smi_result(self.logger)
scan.log_smi_result(self.logger)
scan.clear()

return bad_ptr_cnt, scan
Expand Down Expand Up @@ -709,12 +712,13 @@ def run(self, module_argv):
bad_ptr_cnt, _ = self.test_fuzz(thread_id, smic_start, smic_end, _addr, _addr1)
elif test_mode in ['scan']:
scan_mode = True
scan = None
bad_ptr_cnt, scan = self.test_fuzz(thread_id, smic_start, smic_end, _addr, _addr1, True)
except BadSMIDetected as msg:
bad_ptr_cnt = 1
self.logger.log_important("Potentially bad SMI detected! Stopped fuzing (see FUZZ_BAIL_ON_1ST_DETECT option)")

if scan_mode:
if scan_mode and scan:
self.logger.log_good(f'<<< Done: found {scan.get_total_outliers()} long-running SMIs')
if bad_ptr_cnt > 0:
self.logger.log_bad(f'<<< Done: found {bad_ptr_cnt:d} potential occurrences of unchecked input pointers')
Expand Down

0 comments on commit 797e09c

Please sign in to comment.