syscall: rename z_user_from_copy -> k_usermode_from_copy

Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2023-09-27 10:54:56 +00:00 committed by Carles Cufí
parent 6ba8176e33
commit 56fddd805a
19 changed files with 65 additions and 65 deletions

View file

@ -377,7 +377,7 @@ The proper procedure to mitigate these attacks is to make a copies in the
verification function, and only perform parameter checks on the copies, which
user threads will never have access to. The implementation functions get passed
the copy and not the original data sent by the user. The
:c:func:`z_user_to_copy()` and :c:func:`z_user_from_copy()` APIs exist for
:c:func:`z_user_to_copy()` and :c:func:`k_usermode_from_copy()` APIs exist for
this purpose.
There is one exception in place, with respect to large data buffers which are
@ -433,7 +433,7 @@ bytes processed. This too should use a stack copy:
size_t size;
int ret;
Z_OOPS(z_user_from_copy(&size, size_ptr, sizeof(size));
Z_OOPS(k_usermode_from_copy(&size, size_ptr, sizeof(size));
ret = z_impl_in_out_syscall(&size);
Z_OOPS(z_user_to_copy(size_ptr, &size, sizeof(size)));
return ret;
@ -461,11 +461,11 @@ be copied. Typically this is done by allocating copies on the stack:
struct bar bar_right_copy;
struct bar bar_left_copy;
Z_OOPS(z_user_from_copy(&foo_copy, foo, sizeof(*foo)));
Z_OOPS(z_user_from_copy(&bar_right_copy, foo_copy.bar_right,
Z_OOPS(k_usermode_from_copy(&foo_copy, foo, sizeof(*foo)));
Z_OOPS(k_usermode_from_copy(&bar_right_copy, foo_copy.bar_right,
sizeof(struct bar)));
foo_copy.bar_right = &bar_right_copy;
Z_OOPS(z_user_from_copy(&bar_left_copy, foo_copy.bar_left,
Z_OOPS(k_usermode_from_copy(&bar_left_copy, foo_copy.bar_left,
sizeof(struct bar)));
foo_copy.bar_left = &bar_left_copy;
@ -500,7 +500,7 @@ should never be used to verify if resource allocation has been successful.
size_t bar_list_bytes;
/* Safely copy foo into foo_copy */
Z_OOPS(z_user_from_copy(&foo_copy, foo, sizeof(*foo)));
Z_OOPS(k_usermode_from_copy(&foo_copy, foo, sizeof(*foo)));
/* Bounds check the count member, in the copy we made */
if (foo_copy.count > 32) {
@ -514,7 +514,7 @@ should never be used to verify if resource allocation has been successful.
if (bar_list_copy == NULL) {
return -ENOMEM;
}
Z_OOPS(z_user_from_copy(bar_list_copy, foo_copy.bar_list,
Z_OOPS(k_usermode_from_copy(bar_list_copy, foo_copy.bar_list,
bar_list_bytes));
foo_copy.bar_list = bar_list_copy;
@ -566,7 +566,7 @@ conventions are as follows:
invokes :c:macro:`Z_OOPS()`.
#. Any invalid access to memory found by the set of ``Z_SYSCALL_MEMORY`` APIs,
:c:func:`z_user_from_copy()`, :c:func:`z_user_to_copy()`
:c:func:`k_usermode_from_copy()`, :c:func:`z_user_to_copy()`
should trigger a :c:macro:`Z_OOPS`. This happens when the caller doesn't have
appropriate permissions on the memory buffer or some size calculation
overflowed.

View file

@ -14,7 +14,7 @@ static inline int z_vrfy_adc_channel_setup(const struct device *dev,
struct adc_channel_cfg channel_cfg;
Z_OOPS(Z_SYSCALL_DRIVER_ADC(dev, channel_setup));
Z_OOPS(z_user_from_copy(&channel_cfg,
Z_OOPS(k_usermode_from_copy(&channel_cfg,
(struct adc_channel_cfg *)user_channel_cfg,
sizeof(struct adc_channel_cfg)));
@ -27,13 +27,13 @@ static bool copy_sequence(struct adc_sequence *dst,
struct adc_sequence_options *options,
struct adc_sequence *src)
{
if (z_user_from_copy(dst, src, sizeof(struct adc_sequence)) != 0) {
if (k_usermode_from_copy(dst, src, sizeof(struct adc_sequence)) != 0) {
printk("couldn't copy adc_sequence struct\n");
return false;
}
if (dst->options) {
if (z_user_from_copy(options, dst->options,
if (k_usermode_from_copy(options, dst->options,
sizeof(struct adc_sequence_options)) != 0) {
printk("couldn't copy adc_options struct\n");
return false;

View file

@ -14,7 +14,7 @@ static int z_vrfy_can_calc_timing(const struct device *dev, struct can_timing *r
int err;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, get_core_clock));
Z_OOPS(z_user_from_copy(&res_copy, res, sizeof(res_copy)));
Z_OOPS(k_usermode_from_copy(&res_copy, res, sizeof(res_copy)));
err = z_impl_can_calc_timing(dev, &res_copy, bitrate, sample_pnt);
Z_OOPS(z_user_to_copy(res, &res_copy, sizeof(*res)));
@ -29,7 +29,7 @@ static inline int z_vrfy_can_set_timing(const struct device *dev,
struct can_timing timing_copy;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, set_timing));
Z_OOPS(z_user_from_copy(&timing_copy, timing, sizeof(timing_copy)));
Z_OOPS(k_usermode_from_copy(&timing_copy, timing, sizeof(timing_copy)));
return z_impl_can_set_timing(dev, &timing_copy);
}
@ -81,7 +81,7 @@ static int z_vrfy_can_calc_timing_data(const struct device *dev, struct can_timi
int err;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, get_core_clock));
Z_OOPS(z_user_from_copy(&res_copy, res, sizeof(res_copy)));
Z_OOPS(k_usermode_from_copy(&res_copy, res, sizeof(res_copy)));
err = z_impl_can_calc_timing_data(dev, &res_copy, bitrate, sample_pnt);
Z_OOPS(z_user_to_copy(res, &res_copy, sizeof(*res)));
@ -112,7 +112,7 @@ static inline int z_vrfy_can_set_timing_data(const struct device *dev,
struct can_timing timing_data_copy;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, set_timing_data));
Z_OOPS(z_user_from_copy(&timing_data_copy, timing_data, sizeof(timing_data_copy)));
Z_OOPS(k_usermode_from_copy(&timing_data_copy, timing_data, sizeof(timing_data_copy)));
return z_impl_can_set_timing_data(dev, &timing_data_copy);
}
@ -188,7 +188,7 @@ static inline int z_vrfy_can_send(const struct device *dev,
struct can_frame frame_copy;
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, send));
Z_OOPS(z_user_from_copy(&frame_copy, frame, sizeof(frame_copy)));
Z_OOPS(k_usermode_from_copy(&frame_copy, frame, sizeof(frame_copy)));
Z_OOPS(K_SYSCALL_VERIFY_MSG(callback == NULL, "callbacks may not be set from user mode"));
return z_impl_can_send(dev, &frame_copy, timeout, callback, user_data);
@ -203,7 +203,7 @@ static inline int z_vrfy_can_add_rx_filter_msgq(const struct device *dev,
Z_OOPS(Z_SYSCALL_DRIVER_CAN(dev, add_rx_filter));
Z_OOPS(Z_SYSCALL_OBJ(msgq, K_OBJ_MSGQ));
Z_OOPS(z_user_from_copy(&filter_copy, filter, sizeof(filter_copy)));
Z_OOPS(k_usermode_from_copy(&filter_copy, filter, sizeof(filter_copy)));
return z_impl_can_add_rx_filter_msgq(dev, msgq, &filter_copy);
}

View file

@ -30,7 +30,7 @@ static inline int z_vrfy_charger_set_prop(const struct device *dev, const charge
Z_OOPS(Z_SYSCALL_DRIVER_CHARGER(dev, set_property));
Z_OOPS(z_user_from_copy(&k_val, val, sizeof(union charger_propval)));
Z_OOPS(k_usermode_from_copy(&k_val, val, sizeof(union charger_propval)));
return z_impl_charger_set_prop(dev, prop, &k_val);
}

View file

@ -89,7 +89,7 @@ static inline int z_vrfy_counter_set_channel_alarm(const struct device *dev,
struct counter_alarm_cfg cfg_copy;
Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, set_alarm));
Z_OOPS(z_user_from_copy(&cfg_copy, alarm_cfg, sizeof(cfg_copy)));
Z_OOPS(k_usermode_from_copy(&cfg_copy, alarm_cfg, sizeof(cfg_copy)));
Z_OOPS(K_SYSCALL_VERIFY_MSG(cfg_copy.callback == NULL,
"callbacks may not be set from user mode"));
return z_impl_counter_set_channel_alarm((const struct device *)dev,
@ -115,7 +115,7 @@ static inline int z_vrfy_counter_set_top_value(const struct device *dev,
struct counter_top_cfg cfg_copy;
Z_OOPS(Z_SYSCALL_DRIVER_COUNTER(dev, set_top_value));
Z_OOPS(z_user_from_copy(&cfg_copy, cfg, sizeof(cfg_copy)));
Z_OOPS(k_usermode_from_copy(&cfg_copy, cfg, sizeof(cfg_copy)));
Z_OOPS(K_SYSCALL_VERIFY_MSG(cfg_copy.callback == NULL,
"callbacks may not be set from user mode"));
return z_impl_counter_set_top_value((const struct device *)dev,

View file

@ -14,7 +14,7 @@ static inline int z_vrfy_dac_channel_setup(const struct device *dev,
struct dac_channel_cfg channel_cfg;
Z_OOPS(Z_SYSCALL_DRIVER_DAC(dev, channel_setup));
Z_OOPS(z_user_from_copy(&channel_cfg,
Z_OOPS(k_usermode_from_copy(&channel_cfg,
(struct dac_channel_cfg *)user_channel_cfg,
sizeof(struct dac_channel_cfg)));

View file

@ -14,7 +14,7 @@ static inline int z_vrfy_espi_config(const struct device *dev,
struct espi_cfg cfg_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, config));
Z_OOPS(z_user_from_copy(&cfg_copy, cfg,
Z_OOPS(k_usermode_from_copy(&cfg_copy, cfg,
sizeof(struct espi_cfg)));
return z_impl_espi_config(dev, &cfg_copy);
@ -53,7 +53,7 @@ static inline int z_vrfy_espi_write_lpc_request(const struct device *dev,
uint32_t data_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, write_lpc_request));
Z_OOPS(z_user_from_copy(&data_copy, data, sizeof(*data)));
Z_OOPS(k_usermode_from_copy(&data_copy, data, sizeof(*data)));
return z_impl_espi_write_lpc_request(dev, op, &data_copy);
}
@ -92,7 +92,7 @@ static inline int z_vrfy_espi_read_request(const struct device *dev,
struct espi_request_packet req_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, read_request));
Z_OOPS(z_user_from_copy(&req_copy, req,
Z_OOPS(k_usermode_from_copy(&req_copy, req,
sizeof(struct espi_request_packet)));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(req_copy.data, req_copy.len));
@ -113,7 +113,7 @@ static inline int z_vrfy_espi_write_request(const struct device *dev,
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, write_request));
Z_OOPS(Z_SYSCALL_MEMORY_READ(req->data, req->len));
Z_OOPS(z_user_from_copy(&req_copy, req,
Z_OOPS(k_usermode_from_copy(&req_copy, req,
sizeof(struct espi_request_packet)));
ret = z_impl_espi_write_request(dev, &req_copy);
@ -130,7 +130,7 @@ static inline int z_vrfy_espi_send_oob(const struct device *dev,
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, send_oob));
Z_OOPS(Z_SYSCALL_MEMORY_READ(pckt->buf, pckt->len));
Z_OOPS(z_user_from_copy(&pckt_copy, pckt,
Z_OOPS(k_usermode_from_copy(&pckt_copy, pckt,
sizeof(struct espi_oob_packet)));
ret = z_impl_espi_send_oob(dev, &pckt_copy);
@ -146,7 +146,7 @@ static inline int z_vrfy_espi_receive_oob(const struct device *dev,
struct espi_oob_packet pckt_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, receive_oob));
Z_OOPS(z_user_from_copy(&pckt_copy, pckt,
Z_OOPS(k_usermode_from_copy(&pckt_copy, pckt,
sizeof(struct espi_oob_packet)));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(pckt->buf, pckt->len));
@ -165,7 +165,7 @@ static inline int z_vrfy_espi_read_flash(const struct device *dev,
struct espi_flash_packet pckt_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, flash_read));
Z_OOPS(z_user_from_copy(&pckt_copy, pckt,
Z_OOPS(k_usermode_from_copy(&pckt_copy, pckt,
sizeof(struct espi_flash_packet)));
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(pckt->buf, pckt->len));
@ -184,7 +184,7 @@ static inline int z_vrfy_espi_write_flash(const struct device *dev,
struct espi_flash_packet pckt_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, flash_write));
Z_OOPS(z_user_from_copy(&pckt_copy, pckt,
Z_OOPS(k_usermode_from_copy(&pckt_copy, pckt,
sizeof(struct espi_flash_packet)));
Z_OOPS(Z_SYSCALL_MEMORY_READ(pckt->buf, pckt->len));
@ -201,7 +201,7 @@ static inline int z_vrfy_espi_flash_erase(const struct device *dev,
struct espi_flash_packet pckt_copy;
Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, flash_write));
Z_OOPS(z_user_from_copy(&pckt_copy, pckt,
Z_OOPS(k_usermode_from_copy(&pckt_copy, pckt,
sizeof(struct espi_flash_packet)));
Z_OOPS(Z_SYSCALL_MEMORY_READ(pckt->buf, pckt->len));

View file

@ -453,7 +453,7 @@ static int flash_npcx_nor_ex_op(const struct device *dev, uint16_t code,
struct npcx_ex_ops_uma_out out_copy;
if (syscall_trap) {
Z_OOPS(z_user_from_copy(&in_copy, op_in, sizeof(in_copy)));
Z_OOPS(k_usermode_from_copy(&in_copy, op_in, sizeof(in_copy)));
op_in = &in_copy;
op_out = &out_copy;
}
@ -474,7 +474,7 @@ static int flash_npcx_nor_ex_op(const struct device *dev, uint16_t code,
struct npcx_ex_ops_qspi_oper_in in_copy;
if (syscall_trap) {
Z_OOPS(z_user_from_copy(&in_copy, op_in, sizeof(in_copy)));
Z_OOPS(k_usermode_from_copy(&in_copy, op_in, sizeof(in_copy)));
op_in = &in_copy;
}
#endif

View file

@ -36,7 +36,7 @@ int flash_stm32_ex_op_sector_wp(const struct device *dev, const uintptr_t in,
struct flash_stm32_ex_op_sector_wp_in in_copy;
if (syscall_trap) {
Z_OOPS(z_user_from_copy(&in_copy, request,
Z_OOPS(k_usermode_from_copy(&in_copy, request,
sizeof(in_copy)));
request = &in_copy;
}
@ -102,7 +102,7 @@ int flash_stm32_ex_op_rdp(const struct device *dev, const uintptr_t in,
if (request != NULL) {
#ifdef CONFIG_USERSPACE
if (syscall_trap) {
Z_OOPS(z_user_from_copy(&copy, request, sizeof(copy)));
Z_OOPS(k_usermode_from_copy(&copy, request, sizeof(copy)));
request = &copy;
}
#endif

View file

@ -15,7 +15,7 @@ static inline int z_vrfy_fuel_gauge_get_prop(const struct device *dev, fuel_gaug
Z_OOPS(Z_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
Z_OOPS(z_user_from_copy(&k_val, val, sizeof(union fuel_gauge_prop_val)));
Z_OOPS(k_usermode_from_copy(&k_val, val, sizeof(union fuel_gauge_prop_val)));
int ret = z_impl_fuel_gauge_get_prop(dev, prop, &k_val);
@ -34,8 +34,8 @@ static inline int z_vrfy_fuel_gauge_get_props(const struct device *dev, fuel_gau
Z_OOPS(Z_SYSCALL_DRIVER_FUEL_GAUGE(dev, get_property));
Z_OOPS(z_user_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
Z_OOPS(z_user_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
Z_OOPS(k_usermode_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
Z_OOPS(k_usermode_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
int ret = z_impl_fuel_gauge_get_props(dev, k_props, k_vals, len);
@ -66,8 +66,8 @@ static inline int z_vrfy_fuel_gauge_set_props(const struct device *dev, fuel_gau
Z_OOPS(Z_SYSCALL_DRIVER_FUEL_GAUGE(dev, set_property));
Z_OOPS(z_user_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
Z_OOPS(z_user_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
Z_OOPS(k_usermode_from_copy(k_vals, vals, len * sizeof(union fuel_gauge_prop_val)));
Z_OOPS(k_usermode_from_copy(k_props, props, len * sizeof(fuel_gauge_prop_t)));
int ret = z_impl_fuel_gauge_set_props(dev, k_props, k_vals, len);

View file

@ -20,7 +20,7 @@ static inline int z_vrfy_i2s_configure(const struct device *dev,
goto out;
}
Z_OOPS(z_user_from_copy(&config, (const void *)cfg_ptr,
Z_OOPS(k_usermode_from_copy(&config, (const void *)cfg_ptr,
sizeof(struct i2s_config)));
/* Check that the k_mem_slab provided is a valid pointer and that
@ -98,7 +98,7 @@ static inline int z_vrfy_i2s_buf_write(const struct device *dev,
return -ENOMEM;
}
ret = z_user_from_copy(mem_block, (void *)buf, size);
ret = k_usermode_from_copy(mem_block, (void *)buf, size);
if (ret) {
k_mem_slab_free(tx_cfg->mem_slab, mem_block);
Z_OOPS(ret);

View file

@ -39,7 +39,7 @@ static inline int z_vrfy_peci_transfer(const struct device *dev,
struct peci_msg msg_copy;
Z_OOPS(Z_SYSCALL_DRIVER_PECI(dev, transfer));
Z_OOPS(z_user_from_copy(&msg_copy, msg, sizeof(*msg)));
Z_OOPS(k_usermode_from_copy(&msg_copy, msg, sizeof(*msg)));
return z_impl_peci_transfer(dev, &msg_copy);
}

View file

@ -236,7 +236,7 @@ void *k_usermode_alloc_from_copy(const void *src, size_t size);
* @retval 0 On success
* @retval EFAULT On memory access error
*/
int z_user_from_copy(void *dst, const void *src, size_t size);
int k_usermode_from_copy(void *dst, const void *src, size_t size);
/**
* @brief Copy data to user mode

View file

@ -842,7 +842,7 @@ out_err:
return ret;
}
int z_user_from_copy(void *dst, const void *src, size_t size)
int k_usermode_from_copy(void *dst, const void *src, size_t size)
{
return user_copy(dst, src, size, false);
}
@ -907,7 +907,7 @@ int z_user_string_copy(char *dst, const char *src, size_t maxlen)
goto out;
}
ret = z_user_from_copy(dst, src, actual_len);
ret = k_usermode_from_copy(dst, src, actual_len);
/* See comment above in z_user_string_alloc_copy() */
dst[actual_len - 1] = '\0';

View file

@ -38,7 +38,7 @@ static int z_vrfy_magic_syscall(unsigned int *cookie)
/* Confirm that this user-supplied pointer is valid memory that
* can be accessed. If it's OK, copy into cookie_copy.
*/
if (z_user_from_copy(&cookie_copy, cookie, sizeof(*cookie)) != 0) {
if (k_usermode_from_copy(&cookie_copy, cookie, sizeof(*cookie)) != 0) {
return -EPERM;
}

View file

@ -1589,7 +1589,7 @@ static inline int z_vrfy_net_if_ipv6_addr_lookup_by_index(
{
struct in6_addr addr_v6;
Z_OOPS(z_user_from_copy(&addr_v6, (void *)addr, sizeof(addr_v6)));
Z_OOPS(k_usermode_from_copy(&addr_v6, (void *)addr, sizeof(addr_v6)));
return z_impl_net_if_ipv6_addr_lookup_by_index(&addr_v6);
}
@ -1929,7 +1929,7 @@ bool z_vrfy_net_if_ipv6_addr_add_by_index(int index,
return false;
}
Z_OOPS(z_user_from_copy(&addr_v6, (void *)addr, sizeof(addr_v6)));
Z_OOPS(k_usermode_from_copy(&addr_v6, (void *)addr, sizeof(addr_v6)));
return z_impl_net_if_ipv6_addr_add_by_index(index,
&addr_v6,
@ -1965,7 +1965,7 @@ bool z_vrfy_net_if_ipv6_addr_rm_by_index(int index,
return false;
}
Z_OOPS(z_user_from_copy(&addr_v6, (void *)addr, sizeof(addr_v6)));
Z_OOPS(k_usermode_from_copy(&addr_v6, (void *)addr, sizeof(addr_v6)));
return z_impl_net_if_ipv6_addr_rm_by_index(index, &addr_v6);
}
@ -3526,7 +3526,7 @@ static inline int z_vrfy_net_if_ipv4_addr_lookup_by_index(
{
struct in_addr addr_v4;
Z_OOPS(z_user_from_copy(&addr_v4, (void *)addr, sizeof(addr_v4)));
Z_OOPS(k_usermode_from_copy(&addr_v4, (void *)addr, sizeof(addr_v4)));
return z_impl_net_if_ipv4_addr_lookup_by_index(&addr_v4);
}
@ -3578,7 +3578,7 @@ bool z_vrfy_net_if_ipv4_set_netmask_by_index(int index,
return false;
}
Z_OOPS(z_user_from_copy(&netmask_addr, (void *)netmask,
Z_OOPS(k_usermode_from_copy(&netmask_addr, (void *)netmask,
sizeof(netmask_addr)));
return z_impl_net_if_ipv4_set_netmask_by_index(index, &netmask_addr);
@ -3631,7 +3631,7 @@ bool z_vrfy_net_if_ipv4_set_gw_by_index(int index,
return false;
}
Z_OOPS(z_user_from_copy(&gw_addr, (void *)gw, sizeof(gw_addr)));
Z_OOPS(k_usermode_from_copy(&gw_addr, (void *)gw, sizeof(gw_addr)));
return z_impl_net_if_ipv4_set_gw_by_index(index, &gw_addr);
}
@ -3805,7 +3805,7 @@ bool z_vrfy_net_if_ipv4_addr_add_by_index(int index,
return false;
}
Z_OOPS(z_user_from_copy(&addr_v4, (void *)addr, sizeof(addr_v4)));
Z_OOPS(k_usermode_from_copy(&addr_v4, (void *)addr, sizeof(addr_v4)));
return z_impl_net_if_ipv4_addr_add_by_index(index,
&addr_v4,
@ -3841,7 +3841,7 @@ bool z_vrfy_net_if_ipv4_addr_rm_by_index(int index,
return false;
}
Z_OOPS(z_user_from_copy(&addr_v4, (void *)addr, sizeof(addr_v4)));
Z_OOPS(k_usermode_from_copy(&addr_v4, (void *)addr, sizeof(addr_v4)));
return (uint32_t)z_impl_net_if_ipv4_addr_rm_by_index(index, &addr_v4);
}

View file

@ -307,11 +307,11 @@ char *z_vrfy_net_addr_ntop(sa_family_t family, const void *src,
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(dst, size));
if (family == AF_INET) {
Z_OOPS(z_user_from_copy(&addr4, (const void *)src,
Z_OOPS(k_usermode_from_copy(&addr4, (const void *)src,
sizeof(addr4)));
addr = &addr4;
} else if (family == AF_INET6) {
Z_OOPS(z_user_from_copy(&addr6, (const void *)src,
Z_OOPS(k_usermode_from_copy(&addr6, (const void *)src,
sizeof(addr6)));
addr = &addr6;
} else {

View file

@ -281,7 +281,7 @@ static inline int z_vrfy_z_zsock_getaddrinfo_internal(const char *host,
uint32_t ret;
if (hints) {
Z_OOPS(z_user_from_copy(&hints_copy, (void *)hints,
Z_OOPS(k_usermode_from_copy(&hints_copy, (void *)hints,
sizeof(hints_copy)));
}
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(res, AI_ARR_MAX, sizeof(struct zsock_addrinfo)));

View file

@ -483,7 +483,7 @@ static inline int z_vrfy_zsock_bind(int sock, const struct sockaddr *addr,
struct sockaddr_storage dest_addr_copy;
Z_OOPS(Z_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy)));
Z_OOPS(z_user_from_copy(&dest_addr_copy, (void *)addr, addrlen));
Z_OOPS(k_usermode_from_copy(&dest_addr_copy, (void *)addr, addrlen));
return z_impl_zsock_bind(sock, (struct sockaddr *)&dest_addr_copy,
addrlen);
@ -562,7 +562,7 @@ int z_vrfy_zsock_connect(int sock, const struct sockaddr *addr,
struct sockaddr_storage dest_addr_copy;
Z_OOPS(Z_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy)));
Z_OOPS(z_user_from_copy(&dest_addr_copy, (void *)addr, addrlen));
Z_OOPS(k_usermode_from_copy(&dest_addr_copy, (void *)addr, addrlen));
return z_impl_zsock_connect(sock, (struct sockaddr *)&dest_addr_copy,
addrlen);
@ -693,7 +693,7 @@ static inline int z_vrfy_zsock_accept(int sock, struct sockaddr *addr,
socklen_t addrlen_copy;
int ret;
Z_OOPS(addrlen && z_user_from_copy(&addrlen_copy, addrlen,
Z_OOPS(addrlen && k_usermode_from_copy(&addrlen_copy, addrlen,
sizeof(socklen_t)));
Z_OOPS(addr && Z_SYSCALL_MEMORY_WRITE(addr, addrlen ? addrlen_copy : 0));
@ -865,7 +865,7 @@ ssize_t z_vrfy_zsock_sendto(int sock, const void *buf, size_t len, int flags,
Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, len));
if (dest_addr) {
Z_OOPS(Z_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy)));
Z_OOPS(z_user_from_copy(&dest_addr_copy, (void *)dest_addr,
Z_OOPS(k_usermode_from_copy(&dest_addr_copy, (void *)dest_addr,
addrlen));
}
@ -950,7 +950,7 @@ static inline ssize_t z_vrfy_zsock_sendmsg(int sock,
size_t i;
int ret;
Z_OOPS(z_user_from_copy(&msg_copy, (void *)msg, sizeof(msg_copy)));
Z_OOPS(k_usermode_from_copy(&msg_copy, (void *)msg, sizeof(msg_copy)));
msg_copy.msg_name = NULL;
msg_copy.msg_control = NULL;
@ -1520,7 +1520,7 @@ ssize_t z_vrfy_zsock_recvfrom(int sock, void *buf, size_t max_len, int flags,
}
if (addrlen) {
Z_OOPS(z_user_from_copy(&addrlen_copy, addrlen,
Z_OOPS(k_usermode_from_copy(&addrlen_copy, addrlen,
sizeof(socklen_t)));
}
Z_OOPS(src_addr && Z_SYSCALL_MEMORY_WRITE(src_addr, addrlen_copy));
@ -2591,7 +2591,7 @@ static inline int z_vrfy_zsock_getpeername(int sock, struct sockaddr *addr,
socklen_t addrlen_copy;
int ret;
Z_OOPS(z_user_from_copy(&addrlen_copy, (void *)addrlen,
Z_OOPS(k_usermode_from_copy(&addrlen_copy, (void *)addrlen,
sizeof(socklen_t)));
if (Z_SYSCALL_MEMORY_WRITE(addr, addrlen_copy)) {
@ -2670,7 +2670,7 @@ static inline int z_vrfy_zsock_getsockname(int sock, struct sockaddr *addr,
socklen_t addrlen_copy;
int ret;
Z_OOPS(z_user_from_copy(&addrlen_copy, (void *)addrlen,
Z_OOPS(k_usermode_from_copy(&addrlen_copy, (void *)addrlen,
sizeof(socklen_t)));
if (Z_SYSCALL_MEMORY_WRITE(addr, addrlen_copy)) {