Commit Graph

115 Commits

Author SHA1 Message Date
Disconnect3d 3cf02e1198 Change file permission mode to octal format
Fix likely incorrect chmod permission since decimal numbers != hexadecimal numbers

TL;DR: I gave a talk on this here: https://www.youtube.com/watch?v=tRtxCCRdZOs&t=35227s
2026-04-30 14:15:36 -07:00
Nathaniel Mitchell 789284e47f Add name to log error when reading uefi fars in linux
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-03-10 11:57:25 -07:00
Tamas K Lengyel 0f55fedd47 linuxhelper: assign default value if None is being passed in
linuxhelper's kern_set_EFI_variable only sets default value for attr if no
value has been passed in. In some call-chains (uefi var-write) however None
is being passed in, resulting in the following error from:

struct.error: required argument is not an integer

Make attr optional input and override if value is None with default value.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>
2026-01-29 11:59:38 -08:00
Tamas K Lengyel 1c30511638 Make uefi variable modification test more configurable
Currently the common.uefi.access_uefispec -a modify test modifications to variables
with the default variable attribute of nv | bs | rs (0x7). In this patch we make
this behavior more configurable.

By default the -a modify option will attempt to modify only the content of the variable,
but will not attempt to change the existing attributes of the variable. We have observed
cases where the test used this way uncovered more issues on variables where different
attributes were used and we did not attempt changing the attribute.

By specifying an optional attribute with -a modify,<attribute> the user can now test
variable modification with any attribute instead of just the currently hard-coded one.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>
2026-01-29 11:59:38 -08:00
Tamas K Lengyel 913c383b1a Convert str to byte object in linuxhelper's kern_set_EFI_variable (#2536)
* Convert str to byte object in linuxhelper's kern_set_EFI_variable

This is required to be able to successfuly run the common.uefi.access_uefispec -a modify
test from under Linux and resolve the following error:

ERROR: Exception occurred during chipsec.modules.common.uefi.access_uefispec.run(): 'argument for 's' must be a bytes object'

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>

* Use recommended best practice isinstance for type checking

Co-authored-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>

---------

Signed-off-by: Tamas K Lengyel <tamas.lengyel@oracle.com>
Co-authored-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2026-01-29 11:59:38 -08:00
William Leara c9b3f00344 remove unused imports from linuxhelper.py
These imports are not used within this module.  Also, fix tabs -> spaces.

Signed-off-by: William Leara <william.leara@dell.com>
2026-01-29 11:59:38 -08:00
BrentHoltsclaw 0165a61fec Dev/uefi hal (#2377)
* Add Win Cert types to uefi_fv and spi_uefi
* Move uefi search to library.uefi folder
* Move uefi_fv to library.uefi
* Move uefi_compression to library.uefi>
* Move uefi_common to library.uefi
* Move uefi_platform to library.uefi
* Move spi_uefi to library.uefi
* Add library.uefi.sleep_scripts file
* Move S3 functionality into sleep_state file
* Add varstore and variable files to library.uefi
* Fixup Flake8 suggestions
* Rename library uefi files to remove uefi_
* This change changes the filename of any file under the library.uefi to remove the uefi as part of the name.
* Fix Errors when testing changes

Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2025-02-12 09:13:50 -08:00
Nathaniel Mitchell f7409804b4 HAL Update - Enable multitenant HALs
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-12-03 12:50:36 -08:00
Frinzell, Aaron 2181416bd9 Update type hints
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2024-09-10 16:38:28 -07:00
Frinzell, Aaron 926f9da4f6 Helper fstrings
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2024-08-28 13:58:42 -07:00
jun2zhou 2f6e680c81 Remove empty () for helper banner (#2236)
* remove empty () for simic banner
* Move () to specified helper
---------

Signed-off-by: Jason Zhou <jun2.zhou@intel.com>
2024-07-30 14:22:31 -07:00
Nathaniel Mitchell 23f2eb517e Update Linux max phys mem write size from 0xFFFF to 0xFFFFFFFF
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-07-23 16:40:17 -07:00
Carles Pey 19e2553138 Add SMI enumeration mode to the smm_ptr module (#2141)
* Add SMI enumeration mode to the smm_ptr module

Signed-off-by: Carles Pey <carles.pey@nccgroup.com>
2024-05-29 10:19:42 -07:00
Nathaniel Mitchell ed9c6e2896 Update how ACPI Tables are found
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2024-04-17 15:27:21 -07:00
Dan Scott 0e8192cfd0 Move files to library folder 2024-03-22 14:26:59 -07:00
Dan Scott a933b1337d Update references to functions in new library files 2024-03-22 14:26:59 -07:00
corentin 7bdf194f9e LinuxHelper: open the device with buffering=0 to avoid caching when reading physical memory 2024-02-06 16:38:42 -08:00
Nathaniel Mitchell 27ee5eeb66 Clean up helper create/start/stop/delete functions
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-07-19 16:33:59 -07:00
Nathaniel Mitchell 5940959a19 Refactor msgbus_send_read/write_message to use msgbus_send_message
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-06-21 16:41:21 -07:00
Nathaniel Mitchell 4b38d41a29 Move helper.getcwd() from *helper to oshelper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-06-05 16:41:07 -07:00
Nicolas Iooss 9be66dadbd Replace print_buffer(bytestostring(data)) with print_buffer_bytes
`print_buffer_bytes` can directly handle bytes, instead of converting
them to a string.

While at it, replace buggy calls to `print_buffer(buffer)` (when
`buffer` uses type `bytes`) with `print_buffer_bytes(buffer)`.
This fixes `./chipsec_util.py idt 0`. Before it failed with:

    [CHIPSEC] Dumping IDT of 8 CPU threads
    [cpu0] Physical Address: 0x000000036639E000
    [cpu0] # of entries    : 256
    [cpu0] Contents (4 entries):
    Traceback (most recent call last):
      File "./chipsec_util.py", line 210, in <module>
        sys.exit(main())
      File "./chipsec_util.py", line 205, in main
        return chipsecMain.main()
      File "./chipsec_util.py", line 190, in main
        comm.run()
      File "chipsec/utilcmd/desc_cmd.py", line 84, in run
        self.cs.msr.IDT_all(4)
      File "chipsec/hal/msr.py", line 166, in IDT_all
        self.IDT(tid, num_entries)
      File "chipsec/hal/msr.py", line 158, in IDT
        return self.dump_Descriptor_Table(cpu_thread_id, DESCRIPTOR_TABLE_CODE_IDTR, num_entries)
      File "chipsec/hal/msr.py", line 144, in dump_Descriptor_Table
        print_buffer(dt)
      File "chipsec/logger.py", line 493, in print_buffer
        prt_str = bytes2string(arr, length)
      File "chipsec/logger.py", line 466, in bytes2string
        num_string += [f'{ord(c):02X} ']
    TypeError: ord() expected string of length 1, but int found

There was another bug in `hal/msr.py` where `ord(dt[...])` was used
instead of `dt`.

Signed-off-by: Nicolas Iooss <nicolas.iooss_git@polytechnique.org>
2023-05-31 16:39:35 -07:00
Nathaniel Mitchell 745ae9084e Clean up HALs and Helpers
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-05-26 18:33:08 -07:00
Nathaniel Mitchell 89be1b4ad8 Remove native and add linuxnative as seperate helper
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-05-17 16:36:30 -07:00
Nathaniel Mitchell 46b226f4b9 Fix helpers to return correct value for swsmi util
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-05-09 16:37:19 -07:00
Nathaniel Mitchell 4b9ab99839 Change the way helper loading is done
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2023-04-26 16:52:26 -07:00
Frinzell, Aaron a84f077277 Type Hint and f-string updates to linuxhelper.py
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2023-04-25 09:10:44 -07:00
brentholtsclaw 77c23784d0 Helper changes to remove compression functionality
Signed-off-by: brentholtsclaw <brent.holtsclaw@intel.com>
2022-12-05 16:34:48 -08:00
Dan Scott 0e2aea1369 Update pack formatting and improve readability 2022-08-26 09:49:21 -07:00
Frinzell, Aaron a7ca74c120 Clean up py2 class object
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-08-24 13:28:16 -07:00
Nathaniel Mitchell 291632c0ee Apply flake8 code formatting rules against repo
Signed-off-by: Nathaniel Mitchell <nathaniel.p.mitchell@intel.com>
2022-07-28 09:17:10 -07:00
Frinzell, Aaron 1bf402b906 Update logger.warn()
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-07-25 17:04:16 -07:00
Ignacio Hernandez b15829079c Don't create LEGACY_PCI objects on every access for native mode
When running on native mode the initial bus enumeration does 64k pci
accesses and each one creates an instance of LEGACY_PCI.

The LEGACY_PCI object can be reused for the full lifetime of the helper
saving a couple seconds on each chipsec invocation.

Signed-off-by: Ignacio Hernandez <ignacio.hernandez@intel.com>
2022-07-25 17:02:49 -07:00
Frinzell, Aaron 73d8836c0e Update logger.error() in helper files
Signed-off-by: Frinzell, Aaron <aaron.frinzell@intel.com>
2022-07-07 10:51:46 -05:00
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