Commit Graph

82 Commits

Author SHA1 Message Date
Mathias Krause 62394b6c1c helper/linux: va2pa - handle ioctl() errors
Handle translation errors in ioctl(IOCTL_VA2PA) gracefully to avoid
throwing an exception.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
2022-02-28 15:39:19 -08:00
Mathias Krause d89210f5b4 helper/linux: don't unnecessary (un)load the kernel module
When the kernel module is already loaded, don't unload and try to load
it again.

This is not only useful during development where one might change the
kernel module code often and load it manually but also for setups that
lift the strict access restrictions to /dev/chipsec, e.g. to allow a
non-root group access to its interface.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
2022-02-16 08:22:33 -08:00
brentholtsclaw b7bd40c9b0 Fixes for checker alerts
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2021-08-26 10:50:51 -07:00
brentholtsclaw 0e53326a83 Create exceptions.py for chipsec exceptions
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2021-08-26 10:50:51 -07:00
Nathaniel Mitchell c8c14e21be Remove shebang from all but the entry points. Update ep to py3
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2021-08-12 08:27:33 -07:00
Aaron Frinzell ea05c39fd5 Minor formatting 2021-05-05 21:05:32 -07:00
Aaron Frinzell 9a24294322 One additional status_dict 2021-05-05 21:05:32 -07:00
Aaron Frinzell ad3eb433aa linuxhelper.py minor improvements 2021-05-05 21:05:32 -07:00
Nicolas Oliver bf2f71e9a4 Change tostring to tobytes in linuxhelper.py
Makes Python 3.9 happy
Fixes #1164

Signed-off-by: Nicolas Oliver <nicolasoliver03@gmail.com>
2021-04-30 14:49:03 -07:00
Nicolas Iooss a9204f48e0 Fix error message when the Linux kernel module fails to load
On Arch Linux, `chipsec_main` fails:

    ################################################################
    ##                                                            ##
    ##  CHIPSEC: Platform Hardware Security Assessment Framework  ##
    ##                                                            ##
    ################################################################
    [CHIPSEC] Version 1.5.10
    [CHIPSEC] Arguments:

    insmod: ERROR: could not insert module /var/lib/dkms/chipsec/1.5.10/
    5.11.6-arch1-1/x86_64/module/chipsec.ko.xz: Operation not permitted
    ERROR: Message: "Could not start Linux Helper, are you running as Admin/root?
            {}.format(err)"

Showing `{}.format(err)` is a bug caused by a misplaced quote. With the
quote in the right position, the error is clearer:

    ERROR: Message: "Could not start Linux Helper, are you running as Admin/root?
        Command '['insmod', '/var/lib/dkms/chipsec/1.5.10/5.11.6-arch1-1/
        x86_64/module/chipsec.ko.xz', '', '']' returned non-zero exit
        status 1."
2021-03-31 11:50:32 -07:00
Ignacio Hernandez e62f63f716 Fix to mmio access in native mode
mmap() makes all the accesses to memory using a byte granularity,
when dealing with mmio registers that is not optimal and need to
perform the access at dword granularity

Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2021-03-25 10:25:29 -07:00
Ignacio Hernandez c93391c09a Fix native writemsr for linux
Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-10-28 10:11:30 -07:00
brentholtsclaw 9428fd498c Fixes to uefi_cmd so functions work properly
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-10-28 09:52:41 -07:00
Assaf Carlsbad 95ae69af1f Use 'enabled' instead of 'supported'. 2020-09-24 09:53:03 -07:00
Assaf Carlsbad 8560ee253e Spectre_v2: check for the presence of the Retpoline mitigation on Windows platforms. 2020-09-24 09:53:03 -07:00
Aaron Frinzell 888af1ac4c Specify cpuid.py encoding 2020-08-27 11:05:52 -07:00
Ignacio Hernandez 05ccd4dcdb Rework affinity functions for Linux
Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-08-27 11:01:12 -07:00
brentholtsclaw f7fe1be074 More whitespace cleanup
E231, E201, E226

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-07-31 13:46:13 -07:00
Ignacio Hernandez 722538b8f9 A couple fixes to native mode
Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-07-30 09:21:02 -07:00
Ignacio Hernandez 732146efd8 Explicitly open efivars files as binary for python3
Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-07-28 11:31:04 -07:00
brentholtsclaw af7fa737ee Clean up indentation
E111

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-07-01 16:35:07 -07:00
brentholtsclaw a00b2838e5 Cleanup trailing whitespace
W291,W293,W391

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-07-01 15:44:21 -07:00
Nathaniel Mitchell ae9e6b2b12 Fixed error condition of get_affinity
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2020-06-30 14:20:02 -07:00
brentholtsclaw 53003b1a07 Handle if python2 is still being used
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-06-30 11:12:23 -07:00
brentholtsclaw cd7bc14ea6 Fix from comments
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-06-30 11:12:23 -07:00
brentholtsclaw 66f93f1b3d Modify linux helper get/set_affinity functions
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-06-30 11:12:23 -07:00
Ignacio Hernandez 66bbcc3d04 Adding a legacy pci method for read/write registers on native mode
This method is only usable when kernel does not enumerate device

Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-06-29 09:35:35 -07:00
Ignacio Hernandez 9b7aebd04c Adding a linux native cpuid helper function
Adapted from github repository https://github.com/flababah/cpuid.py

Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-06-29 09:35:35 -07:00
brentholtsclaw 8106f9718a Helper LGTM fixes
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2020-04-17 09:13:26 -07:00
Ignacio Hernandez 87185860e3 Changed the method used for counting the number of threads
The current method breaks when 'process' is found in the CPU
brand string. Instead use the multiprocessing module to collect
this information.

We could get the information from the MSR but that method does
not work when one or more CPUs are offline.

Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2020-04-16 12:02:18 -07:00
Patrick Rudolph a50813d6a4 linuxhelper: Support distros that compress kernel modules
Fedora compresses kernel modules using xz and thus probe for
chipsec.ko.xz, too.

Tested on Fedora 31. Chipsec no longer fails to load DKMS provided
chipsec kernel module.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2020-03-20 17:48:06 -07:00
BrentHoltsclaw 49d40e8397 Fix error messages and helper loading
Remove dependency for win32helper to find .sys file within init
Fixup logic to better display when driver file cannot be found

Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-11-20 10:13:26 -08:00
BrentHoltsclaw 7562a21a59 Add helper/driver information to chipsec_main and chipsec_util
Add self.name and self.driverpath to Helper baseclass
Add get_info function into Helper baseclass which returns self.name and self.driverpath
Modify helpers to have proper name and driver location for driver loaded

Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-11-18 15:22:09 -08:00
Erik Bjorge f20fb71843 Fixed missing () when calling error method
Signed-off-by: Erik Bjorge <erik.c.bjorge@intel.com>
2019-10-24 14:08:41 -07:00
Erik Bjorge 694b1b53ca Converted prints to debug logger messages
Signed-off-by: Erik Bjorge <erik.c.bjorge@intel.com>
2019-10-21 14:48:54 -07:00
Nicholas Armour a0c8a4666e dont convert variable data to string, keep as bytes 2019-10-21 14:48:22 -07:00
BrentHoltsclaw 9094dacdf8 Fix compiler warning with cores.c
Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-09-03 10:07:35 -07:00
BrentHoltsclaw 877ecb1ad8 Fixes to make uefivar_fuzz python3 compatible
Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-09-03 10:06:46 -07:00
BrentHoltsclaw 1d7fc4efe4 Filehelper use python2/3 compatable features
Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-08-19 13:15:30 -07:00
BrentHoltsclaw 2efeda4345 Merge python3-rc2 branch into master (#656) 2019-08-15 14:11:20 -07:00
BrentHoltsclaw 7e95c0e546 Fixes for EFI_SECTION_COMPRESSION logic within decompress routine
added COMPRESSION_ALGORITHMS within chipsec/defines
modified logic witin spi_uefi to rotate through valid algorithms until one is found
modified error within helpers where a list was put inside a list
modified linux helper to use subprocess.call opposed to subprocess.check_output
fixes issues #609, #610, #611

Signed-off-by: BrentHoltsclaw <brent.holtsclaw@intel.com>
2019-07-17 10:10:12 -07:00
Federico Perez 25b390f5cc Fix trailing whitespace on TianoDecompress command call 2019-07-17 10:03:21 -07:00
nha 79506dcecf Native IO read/write fixes 2019-06-10 13:43:51 -07:00
BrentHoltsclaw 9427f40a0a Fixup chipsec_tools path within linux helper 2019-06-06 11:25:53 -07:00
Richard Hughes c31daf5cb8 Use the correct path when trying to find the decompression tools
When started with ~/chipsec/chipsec_util.py we want to use the decompression
tools built in ~/chipsec/chipsec_tools/compression/bin rather than the ones in
the current path.
2019-05-29 09:34:30 -07:00
BrentHoltsclaw ab2016af72 Fix up MacOS helper to support compress and decompress
also fixed up Windows and Linux helper to correctly call tianocompress with --uefi flag
2019-05-10 11:23:47 -07:00
BrentHoltsclaw 0741c1c557 Linux helper cleanup 2019-05-10 11:23:47 -07:00
BrentHoltsclaw c73f1101a2 Compression Changes
-------------------
1. Removed previous compression methodology
  a. All files were removed
2. Using compression tools directly from tianocore/edk2/BaseTools
  a. Downloaded from master branch
  b. Changed Makefiles to build within Chipsec
  c. Added BrotliCompress
3. Reworked Windows and Linux Helper to utilize tools built from compression tools
  a. Both helpers utilize same logic of calling compression tools
  b. Updated to support BrotliCompress
4. Modified GUID functionality within uefi_common to unpack struct as strings opposed to numbers
2019-05-10 11:23:47 -07:00
BrentHoltsclaw 66710206e7 Changes based upon comments 2019-04-25 14:19:08 -07:00
BrentHoltsclaw 789314a142 Normalizing logging for various sections of chipsec:
HAL now only use logger().HAL
helpers now only use logger.DEBUG
modules now only use logger.VERBOSE
2019-04-25 14:19:08 -07:00