diff --git a/doc/kernel/usermode/syscalls.rst b/doc/kernel/usermode/syscalls.rst index c3e629f9ea5..c68dcb6f752 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:`k_usermode_from_copy()` APIs exist for +:c:func:`k_usermode_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 @@ -397,12 +397,12 @@ for some integral value: int ret; ret = z_impl_some_syscall(&local_out_param); - Z_OOPS(z_user_to_copy(out_param, &local_out_param, sizeof(*out_param))); + Z_OOPS(k_usermode_to_copy(out_param, &local_out_param, sizeof(*out_param))); return ret; } Here we have allocated ``local_out_param`` on the stack, passed its address to -the implementation function, and then used :c:func:`z_user_to_copy()` to fill +the implementation function, and then used :c:func:`k_usermode_to_copy()` to fill in the memory passed in by the caller. It might be tempting to do something more concise: @@ -435,7 +435,7 @@ bytes processed. This too should use a stack copy: 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))); + Z_OOPS(k_usermode_to_copy(size_ptr, &size, sizeof(size))); return ret; } @@ -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:`k_usermode_from_copy()`, :c:func:`z_user_to_copy()` + :c:func:`k_usermode_from_copy()`, :c:func:`k_usermode_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/can/can_handlers.c b/drivers/can/can_handlers.c index bb5e185dddf..ae2541acb47 100644 --- a/drivers/can/can_handlers.c +++ b/drivers/can/can_handlers.c @@ -17,7 +17,7 @@ static int z_vrfy_can_calc_timing(const struct device *dev, struct can_timing *r 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))); + Z_OOPS(k_usermode_to_copy(res, &res_copy, sizeof(*res))); return err; } @@ -84,7 +84,7 @@ static int z_vrfy_can_calc_timing_data(const struct device *dev, struct can_timi 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))); + Z_OOPS(k_usermode_to_copy(res, &res_copy, sizeof(*res))); return err; } diff --git a/drivers/charger/charger_handlers.c b/drivers/charger/charger_handlers.c index 6f4cd658b73..237f9ff9628 100644 --- a/drivers/charger/charger_handlers.c +++ b/drivers/charger/charger_handlers.c @@ -16,7 +16,7 @@ static inline int z_vrfy_charger_get_prop(const struct device *dev, const charge int ret = z_impl_charger_get_prop(dev, prop, &k_val); - Z_OOPS(z_user_to_copy(val, &k_val, sizeof(union charger_propval))); + Z_OOPS(k_usermode_to_copy(val, &k_val, sizeof(union charger_propval))); return ret; } diff --git a/drivers/counter/maxim_ds3231.c b/drivers/counter/maxim_ds3231.c index 518f989cede..5f5d87490df 100644 --- a/drivers/counter/maxim_ds3231.c +++ b/drivers/counter/maxim_ds3231.c @@ -1314,7 +1314,7 @@ int z_vrfy_maxim_ds3231_get_syncpoint(const struct device *dev, rv = z_impl_maxim_ds3231_get_syncpoint(dev, &value); if (rv >= 0) { - Z_OOPS(z_user_to_copy(syncpoint, &value, sizeof(*syncpoint))); + Z_OOPS(k_usermode_to_copy(syncpoint, &value, sizeof(*syncpoint))); } return rv; diff --git a/drivers/espi/espi_handlers.c b/drivers/espi/espi_handlers.c index e6d903d30b9..5eaadfdc905 100644 --- a/drivers/espi/espi_handlers.c +++ b/drivers/espi/espi_handlers.c @@ -40,7 +40,7 @@ static inline int z_vrfy_espi_read_lpc_request(const struct device *dev, Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, read_lpc_request)); ret = z_impl_espi_read_lpc_request(dev, op, &data_copy); - Z_OOPS(z_user_to_copy(data, &data_copy, sizeof(uint8_t))); + Z_OOPS(k_usermode_to_copy(data, &data_copy, sizeof(uint8_t))); return ret; } @@ -79,7 +79,7 @@ static inline int z_vrfy_espi_receive_vwire(const struct device *dev, Z_OOPS(Z_SYSCALL_DRIVER_ESPI(dev, receive_vwire)); ret = z_impl_espi_receive_vwire(dev, signal, &level_copy); - Z_OOPS(z_user_to_copy(level, &level_copy, sizeof(uint8_t))); + Z_OOPS(k_usermode_to_copy(level, &level_copy, sizeof(uint8_t))); return ret; } @@ -98,7 +98,7 @@ static inline int z_vrfy_espi_read_request(const struct device *dev, ret = z_impl_espi_read_request(dev, &req_copy); - Z_OOPS(z_user_to_copy(req, &req_copy, + Z_OOPS(k_usermode_to_copy(req, &req_copy, sizeof(struct espi_request_packet))); return ret; @@ -151,7 +151,7 @@ static inline int z_vrfy_espi_receive_oob(const struct device *dev, Z_OOPS(Z_SYSCALL_MEMORY_WRITE(pckt->buf, pckt->len)); ret = z_impl_espi_receive_oob(dev, &pckt_copy); - Z_OOPS(z_user_to_copy(pckt, &pckt_copy, + Z_OOPS(k_usermode_to_copy(pckt, &pckt_copy, sizeof(struct espi_oob_packet))); return ret; @@ -170,7 +170,7 @@ static inline int z_vrfy_espi_read_flash(const struct device *dev, Z_OOPS(Z_SYSCALL_MEMORY_WRITE(pckt->buf, pckt->len)); ret = z_impl_espi_read_flash(dev, pckt); - Z_OOPS(z_user_to_copy(pckt, &pckt_copy, + Z_OOPS(k_usermode_to_copy(pckt, &pckt_copy, sizeof(struct espi_flash_packet))); return ret; diff --git a/drivers/flash/flash_npcx_fiu_nor.c b/drivers/flash/flash_npcx_fiu_nor.c index d60b1ee29bd..4fcac59c027 100644 --- a/drivers/flash/flash_npcx_fiu_nor.c +++ b/drivers/flash/flash_npcx_fiu_nor.c @@ -462,7 +462,7 @@ static int flash_npcx_nor_ex_op(const struct device *dev, uint16_t code, ret = flash_npcx_nor_ex_exec_uma(dev, op_in, op_out); #ifdef CONFIG_USERSPACE if (ret == 0 && syscall_trap) { - Z_OOPS(z_user_to_copy(out, op_out, sizeof(out_copy))); + Z_OOPS(k_usermode_to_copy(out, op_out, sizeof(out_copy))); } #endif break; @@ -495,7 +495,7 @@ static int flash_npcx_nor_ex_op(const struct device *dev, uint16_t code, ret = flash_npcx_nor_ex_get_spi_spec(dev, op_out); #ifdef CONFIG_USERSPACE if (ret == 0 && syscall_trap) { - Z_OOPS(z_user_to_copy(out, op_out, sizeof(out_copy))); + Z_OOPS(k_usermode_to_copy(out, op_out, sizeof(out_copy))); } #endif break; diff --git a/drivers/flash/flash_stm32_ex_op.c b/drivers/flash/flash_stm32_ex_op.c index b5323ae8872..02e5d11279d 100644 --- a/drivers/flash/flash_stm32_ex_op.c +++ b/drivers/flash/flash_stm32_ex_op.c @@ -75,7 +75,7 @@ int flash_stm32_ex_op_sector_wp(const struct device *dev, const uintptr_t in, #ifdef CONFIG_USERSPACE if (syscall_trap) { - Z_OOPS(z_user_to_copy(out, result, sizeof(out_copy))); + Z_OOPS(k_usermode_to_copy(out, result, sizeof(out_copy))); } #endif } @@ -132,7 +132,7 @@ int flash_stm32_ex_op_rdp(const struct device *dev, const uintptr_t in, #ifdef CONFIG_USERSPACE if (syscall_trap) { - Z_OOPS(z_user_to_copy(out, result, sizeof(copy))); + Z_OOPS(k_usermode_to_copy(out, result, sizeof(copy))); } #endif } diff --git a/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c b/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c index c184df73ff2..e05f9c292b4 100644 --- a/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c +++ b/drivers/fuel_gauge/fuel_gauge_syscall_handlers.c @@ -19,7 +19,7 @@ static inline int z_vrfy_fuel_gauge_get_prop(const struct device *dev, fuel_gaug int ret = z_impl_fuel_gauge_get_prop(dev, prop, &k_val); - Z_OOPS(z_user_to_copy(val, &k_val, sizeof(union fuel_gauge_prop_val))); + Z_OOPS(k_usermode_to_copy(val, &k_val, sizeof(union fuel_gauge_prop_val))); return ret; } @@ -39,7 +39,7 @@ static inline int z_vrfy_fuel_gauge_get_props(const struct device *dev, fuel_gau int ret = z_impl_fuel_gauge_get_props(dev, k_props, k_vals, len); - Z_OOPS(z_user_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val))); + Z_OOPS(k_usermode_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val))); return ret; } @@ -72,7 +72,7 @@ static inline int z_vrfy_fuel_gauge_set_props(const struct device *dev, fuel_gau int ret = z_impl_fuel_gauge_set_props(dev, k_props, k_vals, len); /* We only copy back vals because props will never be modified */ - Z_OOPS(z_user_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val))); + Z_OOPS(k_usermode_to_copy(vals, k_vals, len * sizeof(union fuel_gauge_prop_val))); return ret; } diff --git a/drivers/hwinfo/hwinfo_handlers.c b/drivers/hwinfo/hwinfo_handlers.c index 933e8499f4a..e9848f9d686 100644 --- a/drivers/hwinfo/hwinfo_handlers.c +++ b/drivers/hwinfo/hwinfo_handlers.c @@ -21,7 +21,7 @@ int z_vrfy_hwinfo_get_reset_cause(uint32_t *cause) uint32_t cause_copy; ret = z_impl_hwinfo_get_reset_cause(&cause_copy); - Z_OOPS(z_user_to_copy(cause, &cause_copy, sizeof(uint32_t))); + Z_OOPS(k_usermode_to_copy(cause, &cause_copy, sizeof(uint32_t))); return ret; } @@ -40,7 +40,7 @@ int z_vrfy_hwinfo_get_supported_reset_cause(uint32_t *supported) uint32_t supported_copy; ret = z_impl_hwinfo_get_supported_reset_cause(&supported_copy); - Z_OOPS(z_user_to_copy(supported, &supported_copy, sizeof(uint32_t))); + Z_OOPS(k_usermode_to_copy(supported, &supported_copy, sizeof(uint32_t))); return ret; } diff --git a/drivers/i2s/i2s_handlers.c b/drivers/i2s/i2s_handlers.c index fc768027bf7..6b268ea12d7 100644 --- a/drivers/i2s/i2s_handlers.c +++ b/drivers/i2s/i2s_handlers.c @@ -63,12 +63,12 @@ static inline int z_vrfy_i2s_buf_read(const struct device *dev, */ rx_cfg = i2s_config_get((const struct device *)dev, I2S_DIR_RX); - copy_success = z_user_to_copy((void *)buf, mem_block, + copy_success = k_usermode_to_copy((void *)buf, mem_block, data_size); k_mem_slab_free(rx_cfg->mem_slab, mem_block); Z_OOPS(copy_success); - Z_OOPS(z_user_to_copy((void *)size, &data_size, + Z_OOPS(k_usermode_to_copy((void *)size, &data_size, sizeof(data_size))); } diff --git a/drivers/ptp_clock/ptp_clock.c b/drivers/ptp_clock/ptp_clock.c index 8f4c3a171c8..92f04cf9666 100644 --- a/drivers/ptp_clock/ptp_clock.c +++ b/drivers/ptp_clock/ptp_clock.c @@ -22,7 +22,7 @@ int z_vrfy_ptp_clock_get(const struct device *dev, return 0; } - if (z_user_to_copy((void *)tm, &ptp_time, sizeof(ptp_time)) != 0) { + if (k_usermode_to_copy((void *)tm, &ptp_time, sizeof(ptp_time)) != 0) { return 0; } diff --git a/drivers/pwm/pwm_handlers.c b/drivers/pwm/pwm_handlers.c index f6153458625..ef10c459ee9 100644 --- a/drivers/pwm/pwm_handlers.c +++ b/drivers/pwm/pwm_handlers.c @@ -64,12 +64,12 @@ static inline int z_vrfy_pwm_capture_cycles(const struct device *dev, err = z_impl_pwm_capture_cycles((const struct device *)dev, channel, flags, &period, &pulse, timeout); if (period_cycles != NULL) { - Z_OOPS(z_user_to_copy(period_cycles, &period, + Z_OOPS(k_usermode_to_copy(period_cycles, &period, sizeof(*period_cycles))); } if (pulse_cycles != NULL) { - Z_OOPS(z_user_to_copy(pulse_cycles, &pulse, + Z_OOPS(k_usermode_to_copy(pulse_cycles, &pulse, sizeof(*pulse_cycles))); } diff --git a/include/zephyr/internal/syscall_handler.h b/include/zephyr/internal/syscall_handler.h index 77cedf12fda..59a68d41ba4 100644 --- a/include/zephyr/internal/syscall_handler.h +++ b/include/zephyr/internal/syscall_handler.h @@ -251,7 +251,7 @@ int k_usermode_from_copy(void *dst, const void *src, size_t size); * @retval 0 On success * @retval EFAULT On memory access error */ -int z_user_to_copy(void *dst, const void *src, size_t size); +int k_usermode_to_copy(void *dst, const void *src, size_t size); /** * @brief Copy a C string from userspace into a resource pool allocation @@ -267,7 +267,7 @@ int z_user_to_copy(void *dst, const void *src, size_t size); * @param maxlen Maximum size of the string including trailing NULL * @return The duplicated string, or NULL if an error occurred. */ -char *z_user_string_alloc_copy(const char *src, size_t maxlen); +char *k_usermode_string_alloc_copy(const char *src, size_t maxlen); /** * @brief Copy a C string from userspace into a provided buffer @@ -285,7 +285,7 @@ char *z_user_string_alloc_copy(const char *src, size_t maxlen); * to maxlen * @retval EFAULT On memory access error */ -int z_user_string_copy(char *dst, const char *src, size_t maxlen); +int k_usermode_string_copy(char *dst, const char *src, size_t maxlen); #define Z_OOPS(expr) \ do { \ diff --git a/kernel/device.c b/kernel/device.c index 399bd7f3022..5e158a365eb 100644 --- a/kernel/device.c +++ b/kernel/device.c @@ -59,7 +59,7 @@ static inline const struct device *z_vrfy_device_get_binding(const char *name) { char name_copy[Z_DEVICE_MAX_NAME_LEN]; - if (z_user_string_copy(name_copy, (char *)name, sizeof(name_copy)) + if (k_usermode_string_copy(name_copy, (char *)name, sizeof(name_copy)) != 0) { return NULL; } diff --git a/kernel/thread.c b/kernel/thread.c index 66d81a8247e..033bd234ef2 100644 --- a/kernel/thread.c +++ b/kernel/thread.c @@ -266,7 +266,7 @@ static inline int z_vrfy_k_thread_name_set(struct k_thread *thread, const char * * the current z_vrfy / z_impl split does not provide a * means of doing so. */ - if (z_user_string_copy(name, (char *)str, sizeof(name)) != 0) { + if (k_usermode_string_copy(name, (char *)str, sizeof(name)) != 0) { return -EFAULT; } @@ -377,7 +377,7 @@ static inline int z_vrfy_k_thread_name_copy(k_tid_t thread, return -ENOSPC; } - return z_user_to_copy((void *)buf, thread->name, len + 1); + return k_usermode_to_copy((void *)buf, thread->name, len + 1); #else ARG_UNUSED(thread); ARG_UNUSED(buf); @@ -1070,7 +1070,7 @@ int z_vrfy_k_thread_stack_space_get(const struct k_thread *thread, return ret; } - ret = z_user_to_copy(unused_ptr, &unused, sizeof(size_t)); + ret = k_usermode_to_copy(unused_ptr, &unused, sizeof(size_t)); CHECKIF(ret != 0) { return ret; } diff --git a/kernel/userspace.c b/kernel/userspace.c index c2c177a537f..790c614e301 100644 --- a/kernel/userspace.c +++ b/kernel/userspace.c @@ -847,12 +847,12 @@ int k_usermode_from_copy(void *dst, const void *src, size_t size) return user_copy(dst, src, size, false); } -int z_user_to_copy(void *dst, const void *src, size_t size) +int k_usermode_to_copy(void *dst, const void *src, size_t size) { return user_copy(dst, src, size, true); } -char *z_user_string_alloc_copy(const char *src, size_t maxlen) +char *k_usermode_string_alloc_copy(const char *src, size_t maxlen) { size_t actual_len; int err; @@ -885,7 +885,7 @@ out: return ret; } -int z_user_string_copy(char *dst, const char *src, size_t maxlen) +int k_usermode_string_copy(char *dst, const char *src, size_t maxlen) { size_t actual_len; int ret, err; @@ -909,7 +909,7 @@ int z_user_string_copy(char *dst, const char *src, size_t maxlen) ret = k_usermode_from_copy(dst, src, actual_len); - /* See comment above in z_user_string_alloc_copy() */ + /* See comment above in k_usermode_string_alloc_copy() */ dst[actual_len - 1] = '\0'; out: return ret; diff --git a/samples/userspace/prod_consumer/src/app_syscall.c b/samples/userspace/prod_consumer/src/app_syscall.c index 85def07df54..c1b630ba9f2 100644 --- a/samples/userspace/prod_consumer/src/app_syscall.c +++ b/samples/userspace/prod_consumer/src/app_syscall.c @@ -47,7 +47,7 @@ static int z_vrfy_magic_syscall(unsigned int *cookie) ret = z_impl_magic_syscall(&cookie_copy); if (ret == 0 && - z_user_to_copy(cookie, &cookie_copy, sizeof(*cookie)) != 0) { + k_usermode_to_copy(cookie, &cookie_copy, sizeof(*cookie)) != 0) { return -EPERM; } diff --git a/subsys/net/ip/utils.c b/subsys/net/ip/utils.c index 05dfd01304a..42d0f3b418f 100644 --- a/subsys/net/ip/utils.c +++ b/subsys/net/ip/utils.c @@ -323,7 +323,7 @@ char *z_vrfy_net_addr_ntop(sa_family_t family, const void *src, return 0; } - Z_OOPS(z_user_to_copy((void *)dst, str, MIN(size, sizeof(str)))); + Z_OOPS(k_usermode_to_copy((void *)dst, str, MIN(size, sizeof(str)))); return dst; } @@ -484,7 +484,7 @@ int z_vrfy_net_addr_pton(sa_family_t family, const char *src, return -EINVAL; } - if (z_user_string_copy(str, (char *)src, sizeof(str)) != 0) { + if (k_usermode_string_copy(str, (char *)src, sizeof(str)) != 0) { return -EINVAL; } @@ -495,7 +495,7 @@ int z_vrfy_net_addr_pton(sa_family_t family, const char *src, return err; } - Z_OOPS(z_user_to_copy((void *)dst, addr, size)); + Z_OOPS(k_usermode_to_copy((void *)dst, addr, size)); return 0; } diff --git a/subsys/net/lib/sockets/getaddrinfo.c b/subsys/net/lib/sockets/getaddrinfo.c index ba782e4e5e7..b5285feb156 100644 --- a/subsys/net/lib/sockets/getaddrinfo.c +++ b/subsys/net/lib/sockets/getaddrinfo.c @@ -287,7 +287,7 @@ static inline int z_vrfy_z_zsock_getaddrinfo_internal(const char *host, Z_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(res, AI_ARR_MAX, sizeof(struct zsock_addrinfo))); if (service) { - service_copy = z_user_string_alloc_copy((char *)service, 64); + service_copy = k_usermode_string_alloc_copy((char *)service, 64); if (!service_copy) { ret = DNS_EAI_MEMORY; goto out; @@ -295,7 +295,7 @@ static inline int z_vrfy_z_zsock_getaddrinfo_internal(const char *host, } if (host) { - host_copy = z_user_string_alloc_copy((char *)host, 64); + host_copy = k_usermode_string_alloc_copy((char *)host, 64); if (!host_copy) { ret = DNS_EAI_MEMORY; goto out; diff --git a/subsys/net/lib/sockets/socketpair.c b/subsys/net/lib/sockets/socketpair.c index ca9d78b43af..3813c8f7af4 100644 --- a/subsys/net/lib/sockets/socketpair.c +++ b/subsys/net/lib/sockets/socketpair.c @@ -350,7 +350,7 @@ int z_vrfy_zsock_socketpair(int family, int type, int proto, int *sv) ret = z_impl_zsock_socketpair(family, type, proto, tmp); if (ret == 0) { - Z_OOPS(z_user_to_copy(sv, tmp, sizeof(tmp))); + Z_OOPS(k_usermode_to_copy(sv, tmp, sizeof(tmp))); } out: diff --git a/subsys/net/lib/sockets/sockets.c b/subsys/net/lib/sockets/sockets.c index 38da3dc520c..fec5da20582 100644 --- a/subsys/net/lib/sockets/sockets.c +++ b/subsys/net/lib/sockets/sockets.c @@ -700,7 +700,7 @@ static inline int z_vrfy_zsock_accept(int sock, struct sockaddr *addr, ret = z_impl_zsock_accept(sock, (struct sockaddr *)addr, addrlen ? &addrlen_copy : NULL); - Z_OOPS(ret >= 0 && addrlen && z_user_to_copy(addrlen, &addrlen_copy, + Z_OOPS(ret >= 0 && addrlen && k_usermode_to_copy(addrlen, &addrlen_copy, sizeof(socklen_t))); return ret; @@ -1530,7 +1530,7 @@ ssize_t z_vrfy_zsock_recvfrom(int sock, void *buf, size_t max_len, int flags, addrlen ? &addrlen_copy : NULL); if (addrlen) { - Z_OOPS(z_user_to_copy(addrlen, &addrlen_copy, + Z_OOPS(k_usermode_to_copy(addrlen, &addrlen_copy, sizeof(socklen_t))); } @@ -1915,7 +1915,7 @@ static inline int z_vrfy_zsock_poll(struct zsock_pollfd *fds, ret = z_impl_zsock_poll(fds_copy, nfds, timeout); if (ret >= 0) { - z_user_to_copy((void *)fds, fds_copy, fds_size); + k_usermode_to_copy((void *)fds, fds_copy, fds_size); } k_free(fds_copy); @@ -1954,9 +1954,9 @@ static inline int z_vrfy_zsock_inet_pton(sa_family_t family, return -1; } - Z_OOPS(z_user_string_copy(src_copy, (char *)src, sizeof(src_copy))); + Z_OOPS(k_usermode_string_copy(src_copy, (char *)src, sizeof(src_copy))); ret = z_impl_zsock_inet_pton(family, src_copy, dst_copy); - Z_OOPS(z_user_to_copy(dst, dst_copy, dst_size)); + Z_OOPS(k_usermode_to_copy(dst, dst_copy, dst_size)); return ret; } @@ -2180,8 +2180,8 @@ int z_vrfy_zsock_getsockopt(int sock, int level, int optname, ret = z_impl_zsock_getsockopt(sock, level, optname, kernel_optval, &kernel_optlen); - Z_OOPS(z_user_to_copy((void *)optval, kernel_optval, kernel_optlen)); - Z_OOPS(z_user_to_copy((void *)optlen, &kernel_optlen, + Z_OOPS(k_usermode_to_copy((void *)optval, kernel_optval, kernel_optlen)); + Z_OOPS(k_usermode_to_copy((void *)optlen, &kernel_optlen, sizeof(socklen_t))); k_free(kernel_optval); @@ -2603,7 +2603,7 @@ static inline int z_vrfy_zsock_getpeername(int sock, struct sockaddr *addr, &addrlen_copy); if (ret == 0 && - z_user_to_copy((void *)addrlen, &addrlen_copy, + k_usermode_to_copy((void *)addrlen, &addrlen_copy, sizeof(socklen_t))) { errno = EINVAL; return -1; @@ -2682,7 +2682,7 @@ static inline int z_vrfy_zsock_getsockname(int sock, struct sockaddr *addr, &addrlen_copy); if (ret == 0 && - z_user_to_copy((void *)addrlen, &addrlen_copy, + k_usermode_to_copy((void *)addrlen, &addrlen_copy, sizeof(socklen_t))) { errno = EINVAL; return -1; diff --git a/subsys/net/lib/sockets/sockets_select.c b/subsys/net/lib/sockets/sockets_select.c index 3b533f63dde..af88e51e758 100644 --- a/subsys/net/lib/sockets/sockets_select.c +++ b/subsys/net/lib/sockets/sockets_select.c @@ -261,17 +261,17 @@ static int z_vrfy_zsock_select(int nfds, zsock_fd_set *readfds, if (ret >= 0) { if (readfds_copy) { - z_user_to_copy((void *)readfds, readfds_copy, + k_usermode_to_copy((void *)readfds, readfds_copy, sizeof(zsock_fd_set)); } if (writefds_copy) { - z_user_to_copy((void *)writefds, writefds_copy, + k_usermode_to_copy((void *)writefds, writefds_copy, sizeof(zsock_fd_set)); } if (exceptfds_copy) { - z_user_to_copy((void *)exceptfds, exceptfds_copy, + k_usermode_to_copy((void *)exceptfds, exceptfds_copy, sizeof(zsock_fd_set)); } } diff --git a/tests/kernel/mem_protect/syscalls/src/main.c b/tests/kernel/mem_protect/syscalls/src/main.c index 4ecf2aed9ef..f511bd6aedb 100644 --- a/tests/kernel/mem_protect/syscalls/src/main.c +++ b/tests/kernel/mem_protect/syscalls/src/main.c @@ -59,7 +59,7 @@ static inline size_t z_vrfy_string_nlen(char *src, size_t maxlen, int *err) err_copy = -1; } - Z_OOPS(z_user_to_copy((int *)err, &err_copy, sizeof(err_copy))); + Z_OOPS(k_usermode_to_copy((int *)err, &err_copy, sizeof(err_copy))); return ret; } @@ -79,7 +79,7 @@ static inline int z_vrfy_string_alloc_copy(char *src) char *src_copy; int ret; - src_copy = z_user_string_alloc_copy((char *)src, BUF_SIZE); + src_copy = k_usermode_string_alloc_copy((char *)src, BUF_SIZE); if (!src_copy) { return -1; } @@ -102,7 +102,7 @@ int z_impl_string_copy(char *src) static inline int z_vrfy_string_copy(char *src) { - int ret = z_user_string_copy(kernel_buf, (char *)src, BUF_SIZE); + int ret = k_usermode_string_copy(kernel_buf, (char *)src, BUF_SIZE); if (ret) { return ret; @@ -123,7 +123,7 @@ int z_impl_to_copy(char *dest) static inline int z_vrfy_to_copy(char *dest) { - return z_user_to_copy((char *)dest, user_string, BUF_SIZE); + return k_usermode_to_copy((char *)dest, user_string, BUF_SIZE); } #include @@ -248,7 +248,7 @@ ZTEST_USER(syscalls, test_string_nlen) * * @ingroup kernel_memprotect_tests * - * @see z_user_string_alloc_copy(), strcmp() + * @see k_usermode_string_alloc_copy(), strcmp() */ ZTEST_USER(syscalls, test_user_string_alloc_copy) { @@ -273,7 +273,7 @@ ZTEST_USER(syscalls, test_user_string_alloc_copy) * * @ingroup kernel_memprotect_tests * - * @see z_user_string_copy(), strcmp() + * @see k_usermode_string_copy(), strcmp() */ ZTEST_USER(syscalls, test_user_string_copy) { @@ -297,7 +297,7 @@ ZTEST_USER(syscalls, test_user_string_copy) * * @ingroup kernel_memprotect_tests * - * @see memcpy(), z_user_to_copy() + * @see memcpy(), k_usermode_to_copy() */ ZTEST_USER(syscalls, test_to_copy) {