Browse Source

syscall: rename Z_SYSCALL_VERIFY -> K_SYSCALL_VERIFY

Rename internal API to not use z_/Z_.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
pull/64779/head
Anas Nashif 2 years ago committed by Carles Cufí
parent
commit
ee9f278323
  1. 4
      doc/kernel/usermode/syscalls.rst
  2. 2
      drivers/i2c/i2c_handlers.c
  3. 2
      drivers/i3c/i3c_handlers.c
  4. 4
      drivers/spi/spi_handlers.c
  5. 2
      include/zephyr/internal/syscall_handler.h
  6. 4
      kernel/poll.c
  7. 2
      kernel/stack.c
  8. 8
      kernel/thread.c
  9. 6
      subsys/net/lib/sockets/sockets.c

4
doc/kernel/usermode/syscalls.rst

@ -311,7 +311,7 @@ Several macros exist to validate arguments:
* :c:macro:`K_SYSCALL_VERIFY_MSG()` does a runtime check of some boolean * :c:macro:`K_SYSCALL_VERIFY_MSG()` does a runtime check of some boolean
expression which must evaluate to true otherwise the check will fail. expression which must evaluate to true otherwise the check will fail.
A variant :c:macro:`Z_SYSCALL_VERIFY` exists which does not take A variant :c:macro:`K_SYSCALL_VERIFY` exists which does not take
a message parameter, instead printing the expression tested if it a message parameter, instead printing the expression tested if it
fails. The latter should only be used for the most obvious of tests. fails. The latter should only be used for the most obvious of tests.
@ -641,7 +641,7 @@ Helper macros for creating system call verification functions are provided in
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_READ()` * :c:macro:`K_SYSCALL_MEMORY_ARRAY_READ()`
* :c:macro:`K_SYSCALL_MEMORY_ARRAY_WRITE()` * :c:macro:`K_SYSCALL_MEMORY_ARRAY_WRITE()`
* :c:macro:`K_SYSCALL_VERIFY_MSG()` * :c:macro:`K_SYSCALL_VERIFY_MSG()`
* :c:macro:`Z_SYSCALL_VERIFY` * :c:macro:`K_SYSCALL_VERIFY`
Functions for invoking system calls are defined in Functions for invoking system calls are defined in
:zephyr_file:`include/zephyr/syscall.h`: :zephyr_file:`include/zephyr/syscall.h`:

2
drivers/i2c/i2c_handlers.c

@ -59,7 +59,7 @@ static inline int z_vrfy_i2c_transfer(const struct device *dev,
* in i2c.h use only a handful of messages, so up to 32 messages * in i2c.h use only a handful of messages, so up to 32 messages
* should be more than sufficient. * should be more than sufficient.
*/ */
Z_OOPS(Z_SYSCALL_VERIFY(num_msgs >= 1 && num_msgs < 32)); Z_OOPS(K_SYSCALL_VERIFY(num_msgs >= 1 && num_msgs < 32));
/* We need to be able to read the overall array of messages */ /* We need to be able to read the overall array of messages */
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs, Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs,

2
drivers/i3c/i3c_handlers.c

@ -69,7 +69,7 @@ static inline int z_vrfy_i3c_transfer(struct i3c_device_desc *target,
* in i2c.h use only a handful of messages, so up to 32 messages * in i2c.h use only a handful of messages, so up to 32 messages
* should be more than sufficient. * should be more than sufficient.
*/ */
Z_OOPS(Z_SYSCALL_VERIFY(num_msgs >= 1 && num_msgs < 32)); Z_OOPS(K_SYSCALL_VERIFY(num_msgs >= 1 && num_msgs < 32));
/* We need to be able to read the overall array of messages */ /* We need to be able to read the overall array of messages */
Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs, Z_OOPS(K_SYSCALL_MEMORY_ARRAY_READ(msgs, num_msgs,

4
drivers/spi/spi_handlers.c

@ -86,7 +86,7 @@ static inline int z_vrfy_spi_transceive(const struct device *dev,
Z_OOPS(K_SYSCALL_MEMORY_READ(tx_bufs, Z_OOPS(K_SYSCALL_MEMORY_READ(tx_bufs,
sizeof(struct spi_buf_set))); sizeof(struct spi_buf_set)));
memcpy(&tx_bufs_copy, tx, sizeof(tx_bufs_copy)); memcpy(&tx_bufs_copy, tx, sizeof(tx_bufs_copy));
Z_OOPS(Z_SYSCALL_VERIFY(tx_bufs_copy.count < 32)); Z_OOPS(K_SYSCALL_VERIFY(tx_bufs_copy.count < 32));
} else { } else {
memset(&tx_bufs_copy, 0, sizeof(tx_bufs_copy)); memset(&tx_bufs_copy, 0, sizeof(tx_bufs_copy));
} }
@ -98,7 +98,7 @@ static inline int z_vrfy_spi_transceive(const struct device *dev,
Z_OOPS(K_SYSCALL_MEMORY_READ(rx_bufs, Z_OOPS(K_SYSCALL_MEMORY_READ(rx_bufs,
sizeof(struct spi_buf_set))); sizeof(struct spi_buf_set)));
memcpy(&rx_bufs_copy, rx, sizeof(rx_bufs_copy)); memcpy(&rx_bufs_copy, rx, sizeof(rx_bufs_copy));
Z_OOPS(Z_SYSCALL_VERIFY(rx_bufs_copy.count < 32)); Z_OOPS(K_SYSCALL_VERIFY(rx_bufs_copy.count < 32));
} else { } else {
memset(&rx_bufs_copy, 0, sizeof(rx_bufs_copy)); memset(&rx_bufs_copy, 0, sizeof(rx_bufs_copy));
} }

2
include/zephyr/internal/syscall_handler.h

@ -328,7 +328,7 @@ int k_usermode_string_copy(char *dst, const char *src, size_t maxlen);
* oops. A stringified version of this expression will be printed. * oops. A stringified version of this expression will be printed.
* @return 0 on success, nonzero on failure * @return 0 on success, nonzero on failure
*/ */
#define Z_SYSCALL_VERIFY(expr) K_SYSCALL_VERIFY_MSG(expr, #expr) #define K_SYSCALL_VERIFY(expr) K_SYSCALL_VERIFY_MSG(expr, #expr)
/** /**
* @brief Runtime check that a user thread has read and/or write permission to * @brief Runtime check that a user thread has read and/or write permission to

4
kernel/poll.c

@ -364,7 +364,7 @@ static inline int z_vrfy_k_poll(struct k_poll_event *events,
/* Validate the events buffer and make a copy of it in an /* Validate the events buffer and make a copy of it in an
* allocated kernel-side buffer. * allocated kernel-side buffer.
*/ */
if (Z_SYSCALL_VERIFY(num_events >= 0)) { if (K_SYSCALL_VERIFY(num_events >= 0)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
@ -393,7 +393,7 @@ static inline int z_vrfy_k_poll(struct k_poll_event *events,
for (int i = 0; i < num_events; i++) { for (int i = 0; i < num_events; i++) {
struct k_poll_event *e = &events_copy[i]; struct k_poll_event *e = &events_copy[i];
if (Z_SYSCALL_VERIFY(e->mode == K_POLL_MODE_NOTIFY_ONLY)) { if (K_SYSCALL_VERIFY(e->mode == K_POLL_MODE_NOTIFY_ONLY)) {
ret = -EINVAL; ret = -EINVAL;
goto out_free; goto out_free;
} }

2
kernel/stack.c

@ -65,7 +65,7 @@ static inline int32_t z_vrfy_k_stack_alloc_init(struct k_stack *stack,
uint32_t num_entries) uint32_t num_entries)
{ {
Z_OOPS(K_SYSCALL_OBJ_NEVER_INIT(stack, K_OBJ_STACK)); Z_OOPS(K_SYSCALL_OBJ_NEVER_INIT(stack, K_OBJ_STACK));
Z_OOPS(Z_SYSCALL_VERIFY(num_entries > 0)); Z_OOPS(K_SYSCALL_VERIFY(num_entries > 0));
return z_impl_k_stack_alloc_init(stack, num_entries); return z_impl_k_stack_alloc_init(stack, num_entries);
} }
#include <syscalls/k_stack_alloc_init_mrsh.c> #include <syscalls/k_stack_alloc_init_mrsh.c>

8
kernel/thread.c

@ -763,14 +763,14 @@ k_tid_t z_vrfy_k_thread_create(struct k_thread *new_thread,
/* User threads may only create other user threads and they can't /* User threads may only create other user threads and they can't
* be marked as essential * be marked as essential
*/ */
Z_OOPS(Z_SYSCALL_VERIFY(options & K_USER)); Z_OOPS(K_SYSCALL_VERIFY(options & K_USER));
Z_OOPS(Z_SYSCALL_VERIFY(!(options & K_ESSENTIAL))); Z_OOPS(K_SYSCALL_VERIFY(!(options & K_ESSENTIAL)));
/* Check validity of prio argument; must be the same or worse priority /* Check validity of prio argument; must be the same or worse priority
* than the caller * than the caller
*/ */
Z_OOPS(Z_SYSCALL_VERIFY(_is_valid_prio(prio, NULL))); Z_OOPS(K_SYSCALL_VERIFY(_is_valid_prio(prio, NULL)));
Z_OOPS(Z_SYSCALL_VERIFY(z_is_prio_lower_or_equal(prio, Z_OOPS(K_SYSCALL_VERIFY(z_is_prio_lower_or_equal(prio,
_current->base.prio))); _current->base.prio)));
z_setup_new_thread(new_thread, stack, stack_size, z_setup_new_thread(new_thread, stack, stack_size,

6
subsys/net/lib/sockets/sockets.c

@ -482,7 +482,7 @@ static inline int z_vrfy_zsock_bind(int sock, const struct sockaddr *addr,
{ {
struct sockaddr_storage dest_addr_copy; struct sockaddr_storage dest_addr_copy;
Z_OOPS(Z_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy))); Z_OOPS(K_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy)));
Z_OOPS(k_usermode_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, return z_impl_zsock_bind(sock, (struct sockaddr *)&dest_addr_copy,
@ -561,7 +561,7 @@ int z_vrfy_zsock_connect(int sock, const struct sockaddr *addr,
{ {
struct sockaddr_storage dest_addr_copy; struct sockaddr_storage dest_addr_copy;
Z_OOPS(Z_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy))); Z_OOPS(K_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy)));
Z_OOPS(k_usermode_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, return z_impl_zsock_connect(sock, (struct sockaddr *)&dest_addr_copy,
@ -864,7 +864,7 @@ ssize_t z_vrfy_zsock_sendto(int sock, const void *buf, size_t len, int flags,
Z_OOPS(K_SYSCALL_MEMORY_READ(buf, len)); Z_OOPS(K_SYSCALL_MEMORY_READ(buf, len));
if (dest_addr) { if (dest_addr) {
Z_OOPS(Z_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy))); Z_OOPS(K_SYSCALL_VERIFY(addrlen <= sizeof(dest_addr_copy)));
Z_OOPS(k_usermode_from_copy(&dest_addr_copy, (void *)dest_addr, Z_OOPS(k_usermode_from_copy(&dest_addr_copy, (void *)dest_addr,
addrlen)); addrlen));
} }

Loading…
Cancel
Save