SWDEV-536287 - Detect SELinux mode and log error if enabled (#819)

* Detect SELinux mode and fail-fast

* Detect SELinux status by reading /sys/fs/selinux/enforce during initialization.
* Fix the verbose mode for HIP Stream events

* Add more information in the logs
Add information to the user about how to change the setting
Этот коммит содержится в:
Sajina PK
2025-09-03 09:16:36 -04:00
коммит произвёл GitHub
родитель c28acac74d
Коммит 2da209da7f
2 изменённых файлов: 26 добавлений и 11 удалений
+16
Просмотреть файл
@@ -410,6 +410,22 @@ rocprofsys_init_library_hidden()
static bool _once = false;
auto _debug_init = get_debug_init();
int _selinux_mode = 0;
{
std::ifstream _fenforcing{ "/sys/fs/selinux/enforce" };
if(!(_fenforcing >> _selinux_mode)) _selinux_mode = 0;
_fenforcing.close();
}
if(_selinux_mode == 1)
{
ROCPROFSYS_BASIC_VERBOSE(0, "/sys/fs/selinux/enforce has a value of %i. \n",
_selinux_mode);
std::cerr << "SELinux enforcing mode detected. Consider disabling SELinux "
<< "or configure permissive mode with 'sudo setenforce 0'. Aborting.\n";
std::exit(EXIT_FAILURE);
}
ROCPROFSYS_CONDITIONAL_BASIC_PRINT_F(_debug_init, "State is %s...\n",
std::to_string(get_state()).c_str());
+10 -11
Просмотреть файл
@@ -1851,14 +1851,11 @@ tool_hip_stream_callback(rocprofiler_callback_tracing_record_t record,
// STREAM_HANDLE_CREATE and DESTROY are no-ops
if(record.operation == ROCPROFILER_HIP_STREAM_CREATE)
{
ROCPROFSYS_VERBOSE_F(
2, "Entered hip_streams_callback function for ROCPROFILER_HIP_STREAM_CREATE");
ROCPROFSYS_VERBOSE_F(3, " operation = ROCPROFILER_HIP_STREAM_CREATE\n");
}
else if(record.operation == ROCPROFILER_HIP_STREAM_DESTROY)
{
ROCPROFSYS_VERBOSE_F(
2,
"Entered hip_streams_callback function for ROCPROFILER_HIP_STREAM_DESTROY");
ROCPROFSYS_VERBOSE_F(3, " operation = ROCPROFILER_HIP_STREAM_DESTROY\n");
}
else if(record.operation == ROCPROFILER_HIP_STREAM_SET)
{
@@ -1866,17 +1863,19 @@ tool_hip_stream_callback(rocprofiler_callback_tracing_record_t record,
// called
if(record.phase == ROCPROFILER_CALLBACK_PHASE_ENTER)
{
ROCPROFSYS_VERBOSE_F(
2, "Entered hip_streams_callback function for ROCPROFILER_HIP_STREAM_SET "
"with ROCPROFILER_CALLBACK_PHASE_ENTER");
ROCPROFSYS_VERBOSE_F(3,
" operation = ROCPROFILER_HIP_STREAM_SET, phase = "
"ROCPROFILER_CALLBACK_PHASE_ENTER, stream_id=%lu\n",
(unsigned long) stream_id.handle);
stream_id_push(stream_id);
}
// Pop stream ID off of stream stack after underlying HIP function is completed
else if(record.phase == ROCPROFILER_CALLBACK_PHASE_EXIT)
{
ROCPROFSYS_VERBOSE_F(
2, "Entered hip_stream_callback function for ROCPROFILER_HIP_STREAM_SET "
"with ROCPROFILER_CALLBACK_PHASE_EXIT");
ROCPROFSYS_VERBOSE_F(3,
"operation = ROCPROFILER_HIP_STREAM_SET, phase = "
"ROCPROFILER_CALLBACK_PHASE_EXIT, stream_id=%lu\n",
(unsigned long) stream_id.handle);
stream_id_pop();
}
}