From 3156b487b74e1309b8009c7a40b229c4046560c1 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Wed, 9 Feb 2022 22:25:07 +0000 Subject: [PATCH 1/3] Avoid quoting OpenCL include path when it's not required to --- src/backend.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/backend.c b/src/backend.c index f370dca28..4db54c13a 100644 --- a/src/backend.c +++ b/src/backend.c @@ -9392,22 +9392,23 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) char *build_options_buf = (char *) hcmalloc (build_options_sz); - int build_options_len = 0; + int build_options_len = snprintf (build_options_buf, build_options_sz, "-D KERNEL_STATIC "); if ((device_param->is_cuda == true) || (device_param->is_hip == true)) { // using a path with a space will break nvrtc_make_options_array_from_string() // we add it to options array in a clean way later - - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC "); } else { // when is builded with cygwin and msys, cpath_real doesn't work + #if defined (_WIN) || defined (__CYGWIN__) || defined (__MSYS__) - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -D INCLUDE_PATH=%s ", "OpenCL"); + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D INCLUDE_PATH=%s ", "OpenCL"); #else - build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D KERNEL_STATIC -D INCLUDE_PATH=\"%s\" ", folder_config->cpath_real); + const char *build_options_include_fmt = (strchr (folder_config->cpath_real, ' ') != NULL) ? "-D INCLUDE_PATH=\"%s\" " : "-D INCLUDE_PATH=%s "; + + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, build_options_include_fmt, folder_config->cpath_real); #endif build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D XM2S(x)=#x "); From c49238e9cd98d784792de89d5fc869b5e3f91e7f Mon Sep 17 00:00:00 2001 From: Giulio Garzia <32651700+ozozuz@users.noreply.github.com> Date: Sat, 19 Feb 2022 15:49:41 +0000 Subject: [PATCH 2/3] OpenCL include-path workaround for Windows with AMD GPU --- src/backend.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/backend.c b/src/backend.c index 4db54c13a..bc1070b86 100644 --- a/src/backend.c +++ b/src/backend.c @@ -9401,9 +9401,14 @@ int backend_session_begin (hashcat_ctx_t *hashcat_ctx) } else { - // when is builded with cygwin and msys, cpath_real doesn't work - #if defined (_WIN) || defined (__CYGWIN__) || defined (__MSYS__) + // workaround for AMD + if (device_param->opencl_platform_vendor_id == VENDOR_ID_AMD && device_param->opencl_device_vendor_id == VENDOR_ID_AMD) + { + build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-I . "); + } + + // when built with cygwin or msys, cpath_real doesn't work build_options_len += snprintf (build_options_buf + build_options_len, build_options_sz - build_options_len, "-D INCLUDE_PATH=%s ", "OpenCL"); #else const char *build_options_include_fmt = (strchr (folder_config->cpath_real, ' ') != NULL) ? "-D INCLUDE_PATH=\"%s\" " : "-D INCLUDE_PATH=%s "; From 919ad5a1fd084fa52f1791901a10e2f2b21cfeaa Mon Sep 17 00:00:00 2001 From: Will Crozier Date: Sun, 20 Feb 2022 16:27:42 +0000 Subject: [PATCH 3/3] warn/skip for AMD devices on Linux when OpenCL/HIP include-path has spaces --- src/backend.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/backend.c b/src/backend.c index bc1070b86..e91347e2c 100644 --- a/src/backend.c +++ b/src/backend.c @@ -5613,6 +5613,26 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) continue; } + #if defined (__linux__) + if (strchr (folder_config->cpath_real, ' ') != NULL) + { + if (user_options->force == false) + { + event_log_error (hashcat_ctx, "* Device #%u: Unusable HIP include-path! (spaces detected)", device_id + 1); + + if (user_options->quiet == false) + { + event_log_warning (hashcat_ctx, "Consider moving hashcat to a path with no spaces."); + event_log_warning (hashcat_ctx, "You can use --force to override, but do not report related errors."); + event_log_warning (hashcat_ctx, NULL); + } + + device_param->skipped = true; + continue; + } + } + #endif + /** * activate device */ @@ -6628,6 +6648,28 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime) } } + #if defined (__linux__) + if (opencl_platform_vendor_id == VENDOR_ID_AMD) + { + if (strchr (folder_config->cpath_real, ' ') != NULL) + { + if (user_options->force == false) + { + event_log_error (hashcat_ctx, "* Device #%u: Unusable OpenCL include-path! (spaces detected)", device_id + 1); + + if (user_options->quiet == false) + { + event_log_warning (hashcat_ctx, "Consider moving hashcat to a path with no spaces."); + event_log_warning (hashcat_ctx, "You can use --force to override, but do not report related errors."); + event_log_warning (hashcat_ctx, NULL); + } + + device_param->skipped = true; + } + } + } + #endif + char *opencl_device_version_lower = hcstrdup (opencl_device_version); lowercase ((u8 *) opencl_device_version_lower, strlen (opencl_device_version_lower));