From 56fddd805af0d3af75ce5cf5f1fb269024a35387 Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Wed, 27 Sep 2023 10:54:56 +0000 Subject: [PATCH] syscall: rename z_user_from_copy -> k_usermode_from_copy Rename internal API to not use z_/Z_. Signed-off-by: Anas Nashif --- doc/kernel/usermode/syscalls.rst | 16 ++++++++-------- drivers/adc/adc_handlers.c | 6 +++--- drivers/can/can_handlers.c | 12 ++++++------ drivers/charger/charger_handlers.c | 2 +- drivers/counter/counter_handlers.c | 4 ++-- drivers/dac/dac_handlers.c | 2 +- drivers/espi/espi_handlers.c | 18 +++++++++--------- drivers/flash/flash_npcx_fiu_nor.c | 4 ++-- drivers/flash/flash_stm32_ex_op.c | 4 ++-- .../fuel_gauge/fuel_gauge_syscall_handlers.c | 10 +++++----- drivers/i2s/i2s_handlers.c | 4 ++-- drivers/peci/peci_handlers.c | 2 +- include/zephyr/internal/syscall_handler.h | 2 +- kernel/userspace.c | 4 ++-- .../userspace/prod_consumer/src/app_syscall.c | 2 +- subsys/net/ip/net_if.c | 16 ++++++++-------- subsys/net/ip/utils.c | 4 ++-- subsys/net/lib/sockets/getaddrinfo.c | 2 +- subsys/net/lib/sockets/sockets.c | 16 ++++++++-------- 19 files changed, 65 insertions(+), 65 deletions(-) diff --git a/doc/kernel/usermode/syscalls.rst b/doc/kernel/usermode/syscalls.rst index 1b5572e905..c3e629f9ea 100644 --- a/doc/kernel/usermode/syscalls.rst +++ b/doc/kernel/usermode/syscalls.rst @@ -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. diff --git a/drivers/adc/adc_handlers.c b/drivers/adc/adc_handlers.c index 7ac7d5442d..d9fcfc90a0 100644 --- a/drivers/adc/adc_handlers.c +++ b/drivers/adc/adc_handlers.c @@ -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; diff --git a/drivers/can/can_handlers.c b/drivers/can/can_handlers.c index e8338e6716..bb5e185ddd 100644 --- a/drivers/can/can_handlers.c +++ b/drivers/can/can_handlers.c @@ -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); } diff --git a/drivers/charger/charger_handlers.c b/drivers/charger/charger_handlers.c index 0f2200ea72..6f4cd658b7 100644 --- a/drivers/charger/charger_handlers.c +++ b/drivers/charger/charger_handlers.c @@ -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); } diff --git a/drivers/counter/counter_handlers.c b/drivers/counter/counter_handlers.c index 58adcd0e1f..78a372f809 100644 --- a/drivers/counter/counter_handlers.c +++ b/drivers/counter/counter_handlers.c @@ -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, diff --git a/drivers/dac/dac_handlers.c b/drivers/dac/dac_handlers.c index 7db06aea11..76bfa2bbef 100644 --- a/drivers/dac/dac_handlers.c +++ b/drivers/dac/dac_handlers.c @@ -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))); diff --git a/drivers/espi/espi_handlers.c b/drivers/espi/espi_handlers.c index ef90547c29..e6d903d30b 100644 --- a/drivers/espi/espi_handlers.c +++ b/drivers/espi/espi_handlers.c @@ -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)); diff --git a/drivers/flash/flash_npcx_fiu_nor.c b/drivers/flash/flash_npcx_fiu_nor.c index a1b2d79b24..d60b1ee29b 100644 --- a/drivers/flash/flash_npcx_fiu_nor.c +++ b/drivers/flash/flash_npcx_fiu_nor.c @@ -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 diff --git a/drivers/flash/flash_stm32_ex_op.c b/drivers/flash/flash_stm32_ex_op.c index 37bf73840f..b5323ae887 100644 --- a/drivers/flash/flash_stm32_ex_op.c +++ b/drivers/flash/flash_stm32_ex_op.c @@ -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(©, request, sizeof(copy))); + Z_OOPS(k_usermode_from_copy(©, request, sizeof(copy))); request = © } #endif diff --git a/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c b/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c index 8fdb29de9f..c184df73ff 100644 --- a/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c +++ b/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c @@ -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); diff --git a/drivers/i2s/i2s_handlers.c b/drivers/i2s/i2s_handlers.c index 8e3315131b..fc768027bf 100644 --- a/drivers/i2s/i2s_handlers.c +++ b/drivers/i2s/i2s_handlers.c @@ -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); diff --git a/drivers/peci/peci_handlers.c b/drivers/peci/peci_handlers.c index 758806aaec..c878be82ed 100644 --- a/drivers/peci/peci_handlers.c +++ b/drivers/peci/peci_handlers.c @@ -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); } diff --git a/include/zephyr/internal/syscall_handler.h b/include/zephyr/internal/syscall_handler.h index 08f396cf26..77cedf12fd 100644 --- a/include/zephyr/internal/syscall_handler.h +++ b/include/zephyr/internal/syscall_handler.h @@ -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 diff --git a/kernel/userspace.c b/kernel/userspace.c index 1907fc7d84..c2c177a537 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -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'; diff --git a/samples/userspace/prod_consumer/src/app_syscall.c b/samples/userspace/prod_consumer/src/app_syscall.c index dc726096ed..85def07df5 100644 --- a/samples/userspace/prod_consumer/src/app_syscall.c +++ b/samples/userspace/prod_consumer/src/app_syscall.c @@ -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; } diff --git a/subsys/net/ip/net_if.c b/subsys/net/ip/net_if.c index b5887b1da8..72a5de8e3c 100644 --- a/subsys/net/ip/net_if.c +++ b/subsys/net/ip/net_if.c @@ -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); } diff --git a/subsys/net/ip/utils.c b/subsys/net/ip/utils.c index 592d391f6a..05dfd01304 100644 --- a/subsys/net/ip/utils.c +++ b/subsys/net/ip/utils.c @@ -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 { diff --git a/subsys/net/lib/sockets/getaddrinfo.c b/subsys/net/lib/sockets/getaddrinfo.c index 5bb3f6c012..ba782e4e5e 100644 --- a/subsys/net/lib/sockets/getaddrinfo.c +++ b/subsys/net/lib/sockets/getaddrinfo.c @@ -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))); diff --git a/subsys/net/lib/sockets/sockets.c b/subsys/net/lib/sockets/sockets.c index fd4f914fc8..38da3dc520 100644 --- a/subsys/net/lib/sockets/sockets.c +++ b/subsys/net/lib/sockets/sockets.c @@ -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)) {