summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu-Hsuan Hsu <yuhsuan@chromium.org>2021-03-17 11:28:14 +0800
committerCommit Bot <commit-bot@chromium.org>2021-03-17 09:09:45 +0000
commit667cccce6ef942466b79805af1021ba6558b23e4 (patch)
treeb2c1373f34138b4805156da9669dde9a5506a7ba
parentbd9b68406eb1d8f70d3147b3c5ff4f1c0bc41410 (diff)
downloadadhd-667cccce6ef942466b79805af1021ba6558b23e4.tar.gz
CRAS: Disable CFI-icall sanitize for libcras inline functions
The CFI-icall sanitize bans the usage of function pointers. Disable this sanitize to make libcras inline functions available. BUG=b:176570789 TEST=LaCrOS built with cfi-icall plays audio successfully. Change-Id: I40184d674672a63485f0a419aba8430b5992385b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2764116 Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org> Commit-Queue: Yu-Hsuan Hsu <yuhsuan@chromium.org> Tested-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
-rw-r--r--cras/src/libcras/cras_client.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/cras/src/libcras/cras_client.h b/cras/src/libcras/cras_client.h
index c0a214c8..f26a0814 100644
--- a/cras/src/libcras/cras_client.h
+++ b/cras/src/libcras/cras_client.h
@@ -1320,6 +1320,7 @@ int cras_client_set_num_active_streams_changed_callback(
* the order of functions in the structs.
* 4. Assign the pointer to the new function in cras_client.c.
* 5. Create the inline function in cras_client.h, which is used by clients.
+ * Remember to add DISABLE_CFI_ICALL on the inline function.
* 6. Add CHECK_VERSION in the inline function. If the api_version is smaller
* than the supported version, this inline function will return -ENOSYS.
*/
@@ -1330,6 +1331,12 @@ int cras_client_set_num_active_streams_changed_callback(
return -ENOSYS; \
}
+/*
+ * The inline functions use the indirect function call. Therefore, they are
+ * incompatible with CFI-icall.
+ */
+#define DISABLE_CFI_ICALL __attribute__((no_sanitize("cfi-icall")))
+
struct libcras_node_info {
int api_version;
struct cras_node_info *node_;
@@ -1427,6 +1434,7 @@ void libcras_client_destroy(struct libcras_client *client);
* Returns:
* 0 on success, or a negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_connect(struct libcras_client *client)
{
return client->connect(client->client_);
@@ -1440,6 +1448,7 @@ inline int libcras_client_connect(struct libcras_client *client)
* Returns:
* 0 on success, or a negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_connect_timeout(struct libcras_client *client,
unsigned int timeout_ms)
{
@@ -1461,6 +1470,7 @@ inline int libcras_client_connect_timeout(struct libcras_client *client,
* Returns:
* 0 on success, or a negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_connected_wait(struct libcras_client *client)
{
return client->connected_wait(client->client_);
@@ -1476,6 +1486,7 @@ inline int libcras_client_connected_wait(struct libcras_client *client)
* Returns:
* 0 on success, or a negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_run_thread(struct libcras_client *client)
{
return client->run_thread(client->client_);
@@ -1490,6 +1501,7 @@ inline int libcras_client_run_thread(struct libcras_client *client)
* 0 on success or if the thread was already stopped, -EINVAL if the client
* isn't valid.
*/
+DISABLE_CFI_ICALL
inline int libcras_client_stop(struct libcras_client *client)
{
return client->stop(client->client_);
@@ -1511,6 +1523,7 @@ inline int libcras_client_stop(struct libcras_client *client)
* Returns:
* 0 on success, negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_add_pinned_stream(
struct libcras_client *client, uint32_t dev_idx,
cras_stream_id_t *stream_id_out, struct libcras_stream_params *params)
@@ -1531,6 +1544,7 @@ inline int libcras_client_add_pinned_stream(
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_rm_stream(struct libcras_client *client,
cras_stream_id_t stream_id)
{
@@ -1549,6 +1563,7 @@ inline int libcras_client_rm_stream(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_set_stream_volume(struct libcras_client *client,
cras_stream_id_t stream_id,
float volume_scaler)
@@ -1569,6 +1584,7 @@ inline int libcras_client_set_stream_volume(struct libcras_client *client,
* 0 on success negative error code on failure (from errno.h).
* Remember to call libcras_node_info_array_destroy to free the array.
*/
+DISABLE_CFI_ICALL
inline int libcras_client_get_nodes(struct libcras_client *client,
enum CRAS_STREAM_DIRECTION direction,
struct libcras_node_info ***nodes,
@@ -1585,6 +1601,7 @@ inline int libcras_client_get_nodes(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_client_get_default_output_buffer_size(struct libcras_client *client,
int *size)
@@ -1600,6 +1617,7 @@ libcras_client_get_default_output_buffer_size(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_get_aec_group_id(struct libcras_client *client,
int *id)
{
@@ -1614,6 +1632,7 @@ inline int libcras_client_get_aec_group_id(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_get_aec_supported(struct libcras_client *client,
int *supported)
{
@@ -1628,6 +1647,7 @@ inline int libcras_client_get_aec_supported(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_get_system_muted(struct libcras_client *client,
int *muted)
{
@@ -1642,6 +1662,7 @@ inline int libcras_client_get_system_muted(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_set_system_mute(struct libcras_client *client,
int mute)
{
@@ -1656,6 +1677,7 @@ inline int libcras_client_set_system_mute(struct libcras_client *client,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_client_get_loopback_dev_idx(struct libcras_client *client,
int *idx)
{
@@ -1699,6 +1721,7 @@ void libcras_stream_params_destroy(struct libcras_stream_params *params);
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_stream_params_set(
struct libcras_stream_params *params,
enum CRAS_STREAM_DIRECTION direction, size_t buffer_frames,
@@ -1723,6 +1746,7 @@ inline int libcras_stream_params_set(
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_stream_params_set_channel_layout(struct libcras_stream_params *params,
int length, const int8_t *layout)
@@ -1737,6 +1761,7 @@ libcras_stream_params_set_channel_layout(struct libcras_stream_params *params,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_stream_params_enable_aec(struct libcras_stream_params *params)
{
@@ -1752,6 +1777,7 @@ libcras_stream_params_enable_aec(struct libcras_stream_params *params)
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_stream_cb_data_get_stream_id(struct libcras_stream_cb_data *data,
cras_stream_id_t *id)
@@ -1767,6 +1793,7 @@ libcras_stream_cb_data_get_stream_id(struct libcras_stream_cb_data *data,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_stream_cb_data_get_buf(struct libcras_stream_cb_data *data,
uint8_t **buf)
{
@@ -1781,6 +1808,7 @@ inline int libcras_stream_cb_data_get_buf(struct libcras_stream_cb_data *data,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_stream_cb_data_get_frames(struct libcras_stream_cb_data *data,
unsigned int *frames)
@@ -1796,6 +1824,7 @@ libcras_stream_cb_data_get_frames(struct libcras_stream_cb_data *data,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_stream_cb_data_get_latency(struct libcras_stream_cb_data *data,
struct timespec *latency)
@@ -1811,6 +1840,7 @@ libcras_stream_cb_data_get_latency(struct libcras_stream_cb_data *data,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_stream_cb_data_get_usr_arg(struct libcras_stream_cb_data *data,
void **user_arg)
@@ -1842,6 +1872,7 @@ void libcras_node_info_array_destroy(struct libcras_node_info **nodes,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_get_id(struct libcras_node_info *node,
uint64_t *id)
{
@@ -1856,6 +1887,7 @@ inline int libcras_node_info_get_id(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_get_dev_idx(struct libcras_node_info *node,
uint32_t *dev_idx)
{
@@ -1870,6 +1902,7 @@ inline int libcras_node_info_get_dev_idx(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_get_node_idx(struct libcras_node_info *node,
uint32_t *node_idx)
{
@@ -1884,6 +1917,7 @@ inline int libcras_node_info_get_node_idx(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int
libcras_node_info_get_max_supported_channels(struct libcras_node_info *node,
uint32_t *max_supported_channels)
@@ -1900,6 +1934,7 @@ libcras_node_info_get_max_supported_channels(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_is_plugged(struct libcras_node_info *node,
bool *plugged)
{
@@ -1914,6 +1949,7 @@ inline int libcras_node_info_is_plugged(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_is_active(struct libcras_node_info *node,
bool *active)
{
@@ -1928,6 +1964,7 @@ inline int libcras_node_info_is_active(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_get_type(struct libcras_node_info *node,
char **type)
{
@@ -1942,6 +1979,7 @@ inline int libcras_node_info_get_type(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_get_node_name(struct libcras_node_info *node,
char **name)
{
@@ -1956,6 +1994,7 @@ inline int libcras_node_info_get_node_name(struct libcras_node_info *node,
* Returns:
* 0 on success negative error code on failure (from errno.h).
*/
+DISABLE_CFI_ICALL
inline int libcras_node_info_get_dev_name(struct libcras_node_info *node,
char **name)
{