CUDASecurity-CON03

Avoid race conditions when using library functions

Required inputs: IR

Based on: CertC-CON33

With excerpts from SEI CERT, Copyright (C) 1995-2021 Carnegie Mellon University. See 9.4 3rd-Party Licenses in the documentation for full details.

Possible Messages

Key

Text

Severity

Disabled

non_thread_safe_function_use

Avoid race conditions when using library functions.{}

None

False

Options

func_when_with_null

func_when_with_null

Type: dict[bauhaus.analysis.config.FunctionName, int]

Default:

{
   'ctermid': 0,
   'mbrlen': 2,
   'mbrtowc': 3,
   'mbsnrtowcs': 4,
   'mbsrtowcs': 3,
   'tmpnam': 0,
   'wcrtomb': 2,
   'wcsnrtombs': 4,
   'wcsrtombs': 3
}
functions need not be thread-safe if passed a NULL as n'th argument.
 

funcs

funcs : set[bauhaus.analysis.config.FunctionName] = {'round'}

functions need not be thread-safe.
 

remediations

remediations

Type: dict[bauhaus.analysis.config.FunctionName, str]

Default:

{
   'ATOMIC_VAR_INIT': 'Do not attempt to initialize an atomic variable from multiple threads',
   'asctime': 'Use asctime_s(), ctime_s() or gmtime_s()',
   'atomic_init': 'Do not attempt to initialize an atomic variable from multiple threads',
   'c16rtomb': 'Do not call with a null mbstate_t * argument',
   'c32rtomb': 'Do not call with a null mbstate_t * argument',
   'ctime': 'Use asctime_s(), ctime_s() or gmtime_s()',
   'getenv': 'Do not store pointers returned by certain functions',
   'getenv_s': 'Do not store pointers returned by certain functions',
   'gmtime': 'Use asctime_s(), ctime_s() or gmtime_s()',
   'localtime': 'Use asctime_s(), ctime_s() or gmtime_s()',
   'mbrtoc16': 'Do not call with a null mbstate_t * argument',
   'mbrtoc32': 'Do not call with a null mbstate_t * argument',
   'rand': 'Do not use the rand() function for generating pseudorandom numbers',
   'round': 'Use rint() in CUDA device code to round to a double-precision floating-point number as this maps to a single instruction',
   'setlocale': 'Protect multithreaded access to locale-specific functions with a mutex',
   'srand': 'Do not use the rand() function for generating pseudorandom numbers',
   'strerror': 'Use strerror_s() in C11 or strerror_r() in POSIX',
   'strtok': 'Use strerror_s() in C11 or strerror_r() in POSIX',
   'tmpnam': 'Use tmpnam_s()'
}
Mapping from function names to remediation descriptions.