syscall: Z_SYSCALL_MEMORY_ARRAY -> K_SYSCALL_MEMORY_ARRAY
Rename macros and do not use Z_ for internal APIs. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
412561b62a
commit
df9428991a
|
@ -299,14 +299,14 @@ Several macros exist to validate arguments:
|
|||
:c:macro:`Z_SYSCALL_MEMORY_READ()` but the calling thread must additionally
|
||||
have write permissions.
|
||||
|
||||
* :c:macro:`Z_SYSCALL_MEMORY_ARRAY_READ()` validates an array whose total size
|
||||
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_READ()` validates an array whose total size
|
||||
is expressed as separate arguments for the number of elements and the
|
||||
element size. This macro correctly accounts for multiplication overflow
|
||||
when computing the total size. The calling thread must have read permissions
|
||||
on the total size.
|
||||
|
||||
* :c:macro:`Z_SYSCALL_MEMORY_ARRAY_WRITE()` is the same as
|
||||
:c:macro:`Z_SYSCALL_MEMORY_ARRAY_READ()` but the calling thread must
|
||||
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_WRITE()` is the same as
|
||||
:c:macro:`K_SYSCALL_MEMORY_ARRAY_READ()` but the calling thread must
|
||||
additionally have write permissions.
|
||||
|
||||
* :c:macro:`K_SYSCALL_VERIFY_MSG()` does a runtime check of some boolean
|
||||
|
@ -638,8 +638,8 @@ Helper macros for creating system call verification functions are provided in
|
|||
* :c:macro:`Z_OOPS()`
|
||||
* :c:macro:`Z_SYSCALL_MEMORY_READ()`
|
||||
* :c:macro:`Z_SYSCALL_MEMORY_WRITE()`
|
||||
* :c:macro:`Z_SYSCALL_MEMORY_ARRAY_READ()`
|
||||
* :c:macro:`Z_SYSCALL_MEMORY_ARRAY_WRITE()`
|
||||
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_READ()`
|
||||
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_WRITE()`
|
||||
* :c:macro:`K_SYSCALL_VERIFY_MSG()`
|
||||
* :c:macro:`Z_SYSCALL_VERIFY`
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ static inline int z_vrfy_i2c_transfer(const struct device *dev,
|
|||
Z_OOPS(Z_SYSCALL_VERIFY(num_msgs >= 1 && num_msgs < 32));
|
||||
|
||||
/* We need to be able to read the overall array of messages */
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs,
|
||||
sizeof(struct i2c_msg)));
|
||||
|
||||
return copy_msgs_and_transfer((const struct device *)dev,
|
||||
|
|
|
@ -16,19 +16,19 @@ static inline int z_vrfy_i3c_do_ccc(const struct device *dev,
|
|||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(payload, sizeof(*payload)));
|
||||
|
||||
if (payload->ccc.data != NULL) {
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(payload->ccc.data,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(payload->ccc.data,
|
||||
payload->ccc.data_len,
|
||||
sizeof(*payload->ccc.data)));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_WRITE(payload->ccc.data,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(payload->ccc.data,
|
||||
payload->ccc.data_len,
|
||||
sizeof(*payload->ccc.data)));
|
||||
}
|
||||
|
||||
if (payload->targets.payloads != NULL) {
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(payload->targets.payloads,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(payload->targets.payloads,
|
||||
payload->targets.num_targets,
|
||||
sizeof(*payload->targets.payloads)));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_WRITE(payload->targets.payloads,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(payload->targets.payloads,
|
||||
payload->targets.num_targets,
|
||||
sizeof(*payload->targets.payloads)));
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ static inline int z_vrfy_i3c_transfer(struct i3c_device_desc *target,
|
|||
Z_OOPS(Z_SYSCALL_VERIFY(num_msgs >= 1 && num_msgs < 32));
|
||||
|
||||
/* We need to be able to read the overall array of messages */
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs,
|
||||
sizeof(struct i3c_msg)));
|
||||
|
||||
return copy_i3c_msgs_and_transfer((struct i3c_device_desc *)target,
|
||||
|
|
|
@ -102,7 +102,7 @@ static inline int z_vrfy_uart_tx_u16(const struct device *dev,
|
|||
size_t len, int32_t timeout)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, tx));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(buf, len, sizeof(uint16_t)));
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(buf, len, sizeof(uint16_t)));
|
||||
return z_impl_uart_tx_u16(dev, buf, len, timeout);
|
||||
}
|
||||
#include <syscalls/uart_tx_u16_mrsh.c>
|
||||
|
@ -127,7 +127,7 @@ static inline int z_vrfy_uart_rx_enable_u16(const struct device *dev,
|
|||
size_t len, int32_t timeout)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_UART(dev, rx_enable));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_WRITE(buf, len, sizeof(uint16_t)));
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(buf, len, sizeof(uint16_t)));
|
||||
return z_impl_uart_rx_enable_u16(dev, buf, len, timeout);
|
||||
}
|
||||
#include <syscalls/uart_rx_enable_u16_mrsh.c>
|
||||
|
|
|
@ -23,7 +23,7 @@ static struct spi_buf_set *copy_and_check(struct spi_buf_set *bufs,
|
|||
}
|
||||
|
||||
/* Validate the array of struct spi_buf instances */
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(bufs->buffers,
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(bufs->buffers,
|
||||
bufs->count,
|
||||
sizeof(struct spi_buf)));
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ int z_user_string_copy(char *dst, const char *src, size_t maxlen);
|
|||
#define Z_SYSCALL_MEMORY_WRITE(ptr, size) \
|
||||
Z_SYSCALL_MEMORY(ptr, size, 1)
|
||||
|
||||
#define Z_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, write) \
|
||||
#define K_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, write) \
|
||||
({ \
|
||||
size_t product; \
|
||||
K_SYSCALL_VERIFY_MSG(!size_mul_overflow((size_t)(nmemb), \
|
||||
|
@ -409,8 +409,8 @@ int z_user_string_copy(char *dst, const char *src, size_t maxlen);
|
|||
* @param size Size of each array element
|
||||
* @return 0 on success, nonzero on failure
|
||||
*/
|
||||
#define Z_SYSCALL_MEMORY_ARRAY_READ(ptr, nmemb, size) \
|
||||
Z_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 0)
|
||||
#define K_SYSCALL_MEMORY_ARRAY_READ(ptr, nmemb, size) \
|
||||
K_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 0)
|
||||
|
||||
/**
|
||||
* @brief Validate user thread has read/write permission for sized array
|
||||
|
@ -424,8 +424,8 @@ int z_user_string_copy(char *dst, const char *src, size_t maxlen);
|
|||
* @param size Size of each array element
|
||||
* @return 0 on success, nonzero on failure
|
||||
*/
|
||||
#define Z_SYSCALL_MEMORY_ARRAY_WRITE(ptr, nmemb, size) \
|
||||
Z_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 1)
|
||||
#define K_SYSCALL_MEMORY_ARRAY_WRITE(ptr, nmemb, size) \
|
||||
K_SYSCALL_MEMORY_ARRAY(ptr, nmemb, size, 1)
|
||||
|
||||
static inline int z_obj_validation_check(struct k_object *ko,
|
||||
const void *obj,
|
||||
|
|
|
@ -101,7 +101,7 @@ static inline size_t z_vrfy_zephyr_fwrite(const void *ZRESTRICT ptr,
|
|||
FILE *ZRESTRICT stream)
|
||||
{
|
||||
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(ptr, nitems, size));
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(ptr, nitems, size));
|
||||
return z_impl_zephyr_fwrite((const void *ZRESTRICT)ptr, size,
|
||||
nitems, (FILE *ZRESTRICT)stream);
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ static inline int z_vrfy_z_zsock_getaddrinfo_internal(const char *host,
|
|||
Z_OOPS(z_user_from_copy(&hints_copy, (void *)hints,
|
||||
sizeof(hints_copy)));
|
||||
}
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_WRITE(res, AI_ARR_MAX, sizeof(struct zsock_addrinfo)));
|
||||
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);
|
||||
|
|
|
@ -81,7 +81,7 @@ static inline int z_vrfy_rtio_sqe_copy_in_get_handles(struct rtio *r, const stru
|
|||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(r, K_OBJ_RTIO));
|
||||
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_READ(sqes, sqe_count, sizeof(struct rtio_sqe)));
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(sqes, sqe_count, sizeof(struct rtio_sqe)));
|
||||
struct rtio_sqe *sqe;
|
||||
uint32_t acquirable = rtio_sqe_acquirable(r);
|
||||
|
||||
|
@ -116,7 +116,7 @@ static inline int z_vrfy_rtio_cqe_copy_out(struct rtio *r,
|
|||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(r, K_OBJ_RTIO));
|
||||
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_ARRAY_WRITE(cqes, cqe_count, sizeof(struct rtio_cqe)));
|
||||
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_WRITE(cqes, cqe_count, sizeof(struct rtio_cqe)));
|
||||
|
||||
return z_impl_rtio_cqe_copy_out(r, cqes, cqe_count, timeout);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue