Security improvements

Improvements include
* adding additional build flags that warn about stack-smashing
and type conversion errors
* run-time checks for valid function input values and adquate
space for the result of arithmetic operations.
* make sure default case for switch statements do something
besides just assert
* disable using env. var. debugging in release mode

Change-Id: I5f048310c5c56e05d9ec31bcc273404d6a0dd646


[ROCm/amdsmi commit: d00b9ac07d]
This commit is contained in:
Chris Freehill
2020-01-14 15:37:52 -06:00
parent 4c34034ec9
commit 3aef34b9b1
11 changed files with 278 additions and 89 deletions
+4 -3
View File
@@ -116,7 +116,8 @@ typedef enum {
//!< was read
RSMI_STATUS_NO_DATA, //!< No data was found for a given
//!< input
RSMI_STATUS_UNEXPECTED_DATA, //!< The data read or provided to
//!< function is not what was expected
RSMI_STATUS_UNKNOWN_ERROR = 0xFFFFFFFF, //!< An unknown error occurred
} rsmi_status_t;
@@ -867,7 +868,7 @@ rsmi_status_t rsmi_dev_name_get(uint32_t dv_ind, char *name, size_t len);
* provided arguments.
*
* @param[in] len the length of the caller provided buffer @p brand.
*
* @retval ::RSMI_STATUS_SUCCESS call was successful
* @retval ::RSMI_STATUS_NOT_SUPPORTED installed software or hardware does not
* support this function with the given arguments
@@ -901,7 +902,7 @@ rsmi_status_t rsmi_dev_brand_get(uint32_t dv_ind, char *brand, uint32_t len);
* ::RSMI_STATUS_INVALID_ARGS if the function is supported with the provided,
* arguments and ::RSMI_STATUS_NOT_SUPPORTED if it is not supported with the
* provided arguments.
*
* @param[in] len the length of the caller provided buffer @p name.
*
* @retval ::RSMI_STATUS_SUCCESS call was successful
@@ -49,6 +49,14 @@
#include <exception>
#include <string>
#include "rocm_smi/rocm_smi.h"
#define THROW_IF_NULLPTR_DEREF(PTR) \
assert((PTR) != nullptr); \
if ((PTR) == nullptr) { \
throw amd::smi::rsmi_exception(RSMI_STATUS_INVALID_ARGS, __FUNCTION__); \
}
namespace amd {
namespace smi {