hashcat icon indicating copy to clipboard operation
hashcat copied to clipboard

Segmentation fault on NixOS

Open Mag1cByt3s opened this issue 1 year ago • 1 comments

Describe the bug A segmentation fault is encountered if I run hashcat on NixOS with an Intel CPU.

To Reproduce For example I used the following AS-REP hash file:

[email protected]:72b67b5955b338756f7b547081ede581$d9e112aebab2e9dd2360b0746e9b718c1114e3e1e86aac9a24d809a226d67ee7636d2fc0ed83dd6afd0159a817438dce603baf18aece570c6820f9733c48f54ce0b9841d5b8cfab879e8581892e9ad61e055ca28fefd6aa81cf4cd443183f0d3b8020c68cce1b714932575d634f11d8329314b5eb20da93b15c9ed9c75f21a4b597ed8ae2ed75c5b4980918e046b4d0ec923fb02919f2ec3146ea4bc1af59fbbdc5c8fc0c3a8df64930c1ff48c58f6804268791610aba3355dd44127a0897666479ec7dbd0bfbc721ab1aa2dd09df12adf28b748c3969cbcfd1d7f72172d93112dec81ecf81d

Then I tried to crack the hash with hashcat using the wordlist rockyou.txt:

hashcat -a 0 -m 18200 svc-alfresco.hash /usr/share/wordlists/rockyou.txt
hashcat (6.2.6) starting

OpenCL API (OpenCL 2.0 LINUX) - Platform #1 [Intel(R) Corporation]
==================================================================
* Device #1: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz, 15938/31941 MB (3992 MB allocatable), 8MCU

Minimum password length supported by kernel: 0
Maximum password length supported by kernel: 256

Hashes: 1 digests; 1 unique digests, 1 unique salts
Bitmaps: 16 bits, 65536 entries, 0x0000ffff mask, 262144 bytes, 5/13 rotates
Rules: 1

Optimizers applied:
* Zero-Byte
* Not-Iterated
* Single-Hash
* Single-Salt

ATTENTION! Pure (unoptimized) backend kernels selected.
Pure kernels can crack longer passwords, but drastically reduce performance.
If you want to switch to optimized kernels, append -O to your commandline.
See the above message to find out about the exact limits.

Watchdog: Temperature abort trigger set to 90c

Initializing backend runtime for device #1. Please be patient...Stack dump:
0.      Running pass 'Intel OpenCL Vectorizer' on module 'main'.
1.      Running pass 'Intel OpenCL VectorizerCore' on function '@__Vectorized_.gpu_utf8_to_utf16'
2.      Running pass 'Predicator' on function '@__Vectorized_.gpu_utf8_to_utf16'
[1]    9546 segmentation fault  hashcat -a 0 -m 18200 svc-alfresco.hash /usr/share/wordlists/rockyou.txt

From the output above we can see a segmentation fault.

Expected behavior Hashcat is supposed to crack the hash without any issues. Instead a segfault happens.

Hardware/Compute device (please complete the following information):

  • Compute device name: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz, 15938/31941 MB (3992 MB allocatable), 8MCU
  • OpenCL/CUDA driver name: Intel(R) OpenCL
  • OpenCL/CUDA driver version: 1.2.0.475
  • OpenCL/CUDA driver source: installed on NixOS via nix:
{ config, lib, pkgs, modulesPath, ... }:

{
  ## Intel GPU config

  # Set initramfs kernel modules
  # Enable Intel video driver via early KMS
  boot.initrd.kernelModules = [
      "i915"
  ];

  # X11 / Wayland settings
  services.xserver = {
     enable = true;
     videoDrivers = [ "intel" ];
  };

  # Load libva driver for accelerated video
  nixpkgs.config.packageOverrides = pkgs: {
    intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
  };

  # OpenGL settings
  hardware.graphics = {
    enable = true;

    extraPackages = with pkgs; [
      intel-media-driver # LIBVA_DRIVER_NAME=iHD
      intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
      libvdpau-va-gl
      intel-ocl
      intel-compute-runtime
      ocl-icd
      vpl-gpu-rt
    ];
    extraPackages32 = with pkgs.pkgsi686Linux; [ intel-vaapi-driver ];
  };

  environment.sessionVariables = { LIBVA_DRIVER_NAME = "iHD"; }; # Force intel-media-driver
  
  environment.variables = {
    VDPAU_DRIVER = "va_gl";
  };
  
}

Hashcat version (please complete the following information):

  • OS: Linux
  • Distribution: NixOS Unstable
  • Version: 6.2.6

Diagnostic output compute devices:

❯ clinfo
Number of platforms                               1
  Platform Name                                   Intel(R) OpenCL
  Platform Vendor                                 Intel(R) Corporation
  Platform Version                                OpenCL 2.0 LINUX
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer 
  Platform Extensions function suffix             INTEL

  Platform Name                                   Intel(R) OpenCL
Number of devices                                 1
  Device Name                                     Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
  Device Vendor                                   Intel(R) Corporation
  Device Vendor ID                                0x8086
  Device Version                                  OpenCL 2.0 (Build 475)
  Driver Version                                  1.2.0.475
  Device OpenCL C Version                         OpenCL C 2.0 
  Device Type                                     CPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               8
  Max clock frequency                             1700MHz
  Device Partition                                (core)
    Max number of sub-devices                     8
    Supported partition types                     by counts, equally, by names (Intel)
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             8192x8192x8192
  Max work group size                             8192
  Preferred work group size multiple (kernel)     128
  Preferred / native vector sizes                 
    char                                                 1 / 32      
    short                                                1 / 16      
    int                                                  1 / 8       
    long                                                 1 / 4       
    half                                                 0 / 0        (n/a)
    float                                                1 / 8       
    double                                               1 / 4        (cl_khr_fp64)
  Half-precision Floating-point support           (n/a)
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 No
    Round to infinity                             No
    IEEE754-2008 fused multiply-add               No
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  No
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              33492631552 (31.19GiB)
  Error Correction support                        No
  Max memory allocation                           8373157888 (7.798GiB)
  Unified memory for Host and Device              Yes
  Shared Virtual Memory (SVM) capabilities        (core)
    Coarse-grained buffer sharing                 Yes
    Fine-grained buffer sharing                   Yes
    Fine-grained system sharing                   Yes
    Atomics                                       Yes
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Preferred alignment for atomics                 
    SVM                                           64 bytes
    Global                                        64 bytes
    Local                                         0 bytes
  Max size for global variable                    65536 (64KiB)
  Preferred total size of global vars             65536 (64KiB)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        262144 (256KiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             480
    Max size for 1D images from buffer            523322368 pixels
    Max 1D or 2D image array size                 2048 images
    Base address alignment for 2D image buffers   64 bytes
    Pitch alignment for 2D image buffers          64 pixels
    Max 2D image size                             16384x16384 pixels
    Max 3D image size                             2048x2048x2048 pixels
    Max number of read image args                 480
    Max number of write image args                480
    Max number of read/write image args           480
  Max number of pipe args                         16
  Max active pipe reservations                    32767
  Max pipe packet size                            1024
  Local memory type                               Global
  Local memory size                               32768 (32KiB)
  Max number of constant args                     480
  Max constant buffer size                        131072 (128KiB)
  Max size of kernel argument                     3840 (3.75KiB)
  Queue properties (on host)                      
    Out-of-order execution                        Yes
    Profiling                                     Yes
    Local thread execution (Intel)                Yes
  Queue properties (on device)                    
    Out-of-order execution                        Yes
    Profiling                                     Yes
    Preferred size                                4294967295 (4GiB)
    Max size                                      4294967295 (4GiB)
  Max queues on device                            4294967295
  Max events on device                            4294967295
  Prefer user sync for interop                    No
  Profiling timer resolution                      1ns
  Execution capabilities                          
    Run OpenCL kernels                            Yes
    Run native kernels                            Yes
    SPIR versions                                 1.2
  printf() buffer size                            1048576 (1024KiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 cl_khr_image2d_from_buffer 

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  Intel(R) OpenCL
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   Success [INTEL]
  clCreateContext(NULL, ...) [default]            Success [INTEL]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 Intel(R) OpenCL
    Device Name                                   Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  Success (1)
    Platform Name                                 Intel(R) OpenCL
    Device Name                                   Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Intel(R) OpenCL
    Device Name                                   Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz

ICD loader properties
  ICD loader Name                                 OpenCL ICD Loader
  ICD loader Vendor                               OCL Icd free software
  ICD loader Version                              2.3.2
  ICD loader Profile                              OpenCL 3.0
❯ hashcat -I
hashcat (6.2.6) starting in backend information mode

OpenCL Info:
============

OpenCL Platform ID #1
  Vendor..: Intel(R) Corporation
  Name....: Intel(R) OpenCL
  Version.: OpenCL 2.0 LINUX

  Backend Device ID #1
    Type...........: CPU
    Vendor.ID......: 8
    Vendor.........: Intel(R) Corporation
    Name...........: Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz
    Version........: OpenCL 2.0 (Build 475)
    Processor(s)...: 8
    Clock..........: 1700
    Memory.Total...: 31941 MB (limited to 3992 MB allocatable in one block)
    Memory.Free....: 15938 MB
    Local.Memory...: 32 KB
    OpenCL.Version.: OpenCL C 2.0 
    Driver.Version.: 1.2.0.475
❯ lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v6/7th Gen Core Processor Host Bridge/DRAM Registers (rev 08)
00:02.0 VGA compatible controller: Intel Corporation UHD Graphics 620 (rev 07)
00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 08)
00:08.0 System peripheral: Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
00:16.0 Communication controller: Intel Corporation Sunrise Point-LP CSME HECI #1 (rev 21)
00:1c.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #1 (rev f1)
00:1c.4 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #5 (rev f1)
00:1c.6 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #7 (rev f1)
00:1d.0 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #9 (rev f1)
00:1d.2 PCI bridge: Intel Corporation Sunrise Point-LP PCI Express Root Port #11 (rev f1)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point LPC/eSPI Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (4) I219-LM (rev 21)
03:00.0 Non-Volatile memory controller: Sandisk Corp PC SN520 x2 M.2 2242 NVMe SSD (rev 01)
04:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)
40:00.0 Non-Volatile memory controller: Samsung Electronics Co Ltd NVMe SSD Controller SM981/PM981/PM983

Additional context I have no issues with the same hashcat version 6.2.6 on the same hardware on arch linux.

Mag1cByt3s avatar Nov 10 '24 13:11 Mag1cByt3s

Same problem:

❯ clinfo Number of platforms 1 Platform Name Intel(R) OpenCL Platform Vendor Intel(R) Corporation Platform Version OpenCL 1.2 LINUX Platform Profile FULL_PROFILE Platform Extensions cl_khr_icd cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_byte_addressable_store cl_khr_depth_images cl_khr_3d_image_writes cl_intel_exec_by_local_thread cl_khr_spir cl_khr_fp64 Platform Extensions function suffix INTEL

Platform Name Intel(R) OpenCL Number of devices 1 Device Name Intel(R) Core(TM) i5-4570 CPU @ 3.20GHz Device Vendor Intel(R) Corporation Device Vendor ID 0x8086 Device Version OpenCL 1.2 (Build 475) Driver Version 1.2.0.475 Device OpenCL C Version OpenCL C 1.2 Device Type CPU Device Profile FULL_PROFILE Device Available Yes Compiler Available Yes Linker Available Yes Max compute units 4 Max clock frequency 3200MHz

ZAZPRO avatar Feb 19 '25 10:02 ZAZPRO

We have updated hashcat to v7.0.0 and reworked lot's of stuff. Please retry with latest version and close the issue if solved.

Some side note, your intel CPU runtime seems out of date. Latest runtime already supports OpenCL 3.0, so it's very likely the segfault is coming from the old runtime, not from hashcat.

Some log working:

atom@x870:~/hashcat$ ./hashcat -a 0 -m 18200 svc-alfresco.hash rockyou.txt -D 1 --backend-ignore-hip 
hashcat (v7.0.0-59-g5f2216ef3) starting

OpenCL API (OpenCL 3.0 LINUX) - Platform #1 [Intel(R) Corporation]
==================================================================
* Device #01: AMD Ryzen 9 9900X 12-Core Processor, 15581/31163 MB (7790 MB allocatable), 24MCU

...

[email protected]:72b67b5955b338756f7b547081ede581$d9e112aebab2e9dd2360b0746e9b718c1114e3e1e86aac9a24d809a226d67ee7636d2fc0ed83dd6afd0159a817438dce603baf18aece570c6820f9733c48f54ce0b9841d5b8cfab879e8581892e9ad61e055ca28fefd6aa81cf4cd443183f0d3b8020c68cce1b714932575d634f11d8329314b5eb20da93b15c9ed9c75f21a4b597ed8ae2ed75c5b4980918e046b4d0ec923fb02919f2ec3146ea4bc1af59fbbdc5c8fc0c3a8df64930c1ff48c58f6804268791610aba3355dd44127a0897666479ec7dbd0bfbc721ab1aa2dd09df12adf28b748c3969cbcfd1d7f72172d93112dec81ecf81d:s3rvice
                                                          
Session..........: hashcat
Status...........: Cracked
...

Started: Tue Aug  5 10:08:11 2025
Stopped: Tue Aug  5 10:08:24 2025

jsteube avatar Aug 05 '25 08:08 jsteube

I still get the same issues.

I feel like this is an OpenCL issue with my hardware.

* Device #1: Outdated or broken Intel OpenCL runtime '1.2.0.475' detected!

Initializing backend runtime for device #1. Please be patient...Stack dump:
0.      Running pass 'Intel OpenCL Vectorizer' on module 'main'.
1.      Running pass 'Intel OpenCL VectorizerCore' on function '@__Vectorized_.gpu_utf8_to_utf16'
2.      Running pass 'Predicator' on function '@__Vectorized_.gpu_utf8_to_utf16'
Segmentation fault         hashcat -a 0 -m 18200 svc-alfresco.hash /usr/share/wordlists/rockyou.txt -D 1 --backend-ignore-hip --force

Mag1cByt3s avatar Aug 05 '25 14:08 Mag1cByt3s

Yes, it's not hashcat that crashes, but the runtime. It's not a hardware issue, but the opencl runtime is ways too old.

jsteube avatar Aug 05 '25 14:08 jsteube

I have intel-compute-runtime installed. That package is on version 25.22.33944.8 => https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/in/intel-compute-runtime/package.nix

Mag1cByt3s avatar Aug 06 '25 12:08 Mag1cByt3s

I have intel-compute-runtime installed. That package is on version 25.22.33944.8 => https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/in/intel-compute-runtime/package.nix

Is old, check here: https://github.com/intel/compute-runtime

matrix avatar Aug 06 '25 13:08 matrix

I was able to fix my issues with hashcat by replacing intel-compute-runtime with intel-compute-runtime-legacy1.

Intel Graphics Compute Runtime oneAPI Level Zero and OpenCL with support for Gen8, Gen9 and Gen11 GPUs

See my commit here: https://github.com/Red-Flake/red-flake-nix/commit/e3c713fc6fb20738df0dbd1f6ca7ffdd3a6a4270


On NixOS i created an option to enable this for intel legacy GPUs:

self: super: {
  # replace intel-compute-runtime with intel-compute-runtime-legacy1 for legacy Gen8, Gen9 and Gen11 Intel GPUs
  intel-compute-runtime = super.intel-compute-runtime-legacy1;

  # create symlink for intel-opencl/libigdrcl_legacy1.so
  super.systemd.tmpfiles.rules =
    let
      createLink = src: dest: "L+ ${dest} - - - - ${src}";
    in
    [
      (createLink "${super.pkgs.intel-compute-runtime-legacy1}/lib/intel-opencl/libigdrcl_legacy1.so" "/usr/lib/x86_64-linux-gnu/intel-opencl/libigdrcl_legacy1.so")
    ];
}

clinfo now gives me the correct info:

❯ clinfo
Number of platforms                               1
  Platform Name                                   Intel(R) OpenCL Graphics
  Platform Vendor                                 Intel(R) Corporation
  Platform Version                                OpenCL 3.0 
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_byte_addressable_store cl_khr_device_uuid cl_khr_fp16 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_icd cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_intel_command_queue_families cl_intel_subgroups cl_intel_required_subgroup_size cl_intel_subgroups_short cl_khr_spir cl_intel_accelerator cl_intel_driver_diagnostics cl_khr_priority_hints cl_khr_throttle_hints cl_khr_create_command_queue cl_intel_subgroups_char cl_intel_subgroups_long cl_khr_il_program cl_intel_mem_force_host_memory cl_khr_subgroup_extended_types cl_khr_subgroup_non_uniform_vote cl_khr_subgroup_ballot cl_khr_subgroup_non_uniform_arithmetic cl_khr_subgroup_shuffle cl_khr_subgroup_shuffle_relative cl_khr_subgroup_clustered_reduce cl_intel_device_attribute_query cl_khr_extended_bit_ops cl_khr_suggested_local_work_size cl_intel_split_work_group_barrier cl_khr_fp64 cl_khr_subgroups cl_intel_spirv_media_block_io cl_intel_spirv_subgroups cl_khr_spirv_linkonce_odr cl_khr_spirv_no_integer_wrap_decoration cl_intel_unified_shared_memory cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_ext_float_atomics cl_khr_external_memory cl_intel_planar_yuv cl_intel_packed_yuv cl_intel_motion_estimation cl_intel_device_side_avc_motion_estimation cl_intel_spirv_device_side_avc_motion_estimation cl_intel_advanced_motion_estimation cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_image2d_from_buffer cl_khr_depth_images cl_khr_3d_image_writes cl_intel_media_block_io cl_khr_gl_sharing cl_khr_gl_depth_images cl_khr_gl_event cl_khr_gl_msaa_sharing cl_intel_va_api_media_sharing cl_intel_sharing_format_query cl_khr_pci_bus_info 
  Platform Extensions with Version                cl_khr_byte_addressable_store                                    0x400000 (1.0.0)
                                                  cl_khr_device_uuid                                               0x400000 (1.0.0)
                                                  cl_khr_fp16                                                      0x400000 (1.0.0)

.........................................SNIP................................................

And now hashcat works as expected on my machine:

❯ hashcat --benchmark
hashcat (7.0.0) starting in benchmark mode

Benchmarking uses hand-optimized kernel code by default.
You can use it in your cracking session by setting the -O option.
Note: Using optimized kernel code limits the maximum supported password length.
To disable the optimized kernel code in benchmark mode, use the -w option.

OpenCL API (OpenCL 3.0 ) - Platform #1 [Intel(R) Corporation]
=============================================================
* Device #01: Intel(R) UHD Graphics 620, 14782/29564 MB (2047 MB allocatable), 8MCU

Benchmark relevant options:
===========================
* --backend-devices-virtmulti=1
* --backend-devices-virthost=1
* --optimized-kernel-enable

-------------------
* Hash-Mode 0 (MD5)
-------------------

Speed.#01........:   494.1 MH/s (83.72ms) @ Accel:21 Loops:1024 Thr:256 Vec:1

----------------------
* Hash-Mode 100 (SHA1)
----------------------

Speed.#01........: 96366.5 kH/s (104.17ms) @ Accel:8 Loops:1024 Thr:256 Vec:1

.........................................SNIP................................................

Mag1cByt3s avatar Aug 06 '25 21:08 Mag1cByt3s