From a48e68441ba47d179ab3a04f673d103c8d7ef305 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Tue, 14 Nov 2023 05:20:47 +0000 Subject: [PATCH] logging: Remove syscall for z_log_msg_runtime_vcreate This syscall is completely problematic in userspace, it does not check ANY parameter that is given and it uses variadic argument that are not copied / checked before being used in the implementation, instead it just pass a pointer to user stack with unknown data is blindly consumed by the kernel. Signed-off-by: Flavio Ceolin --- include/zephyr/logging/log_msg.h | 10 +++++----- subsys/logging/log_msg.c | 14 +------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/include/zephyr/logging/log_msg.h b/include/zephyr/logging/log_msg.h index c35a69d85cc..fabc7a16b0c 100644 --- a/include/zephyr/logging/log_msg.h +++ b/include/zephyr/logging/log_msg.h @@ -679,11 +679,11 @@ __syscall void z_log_msg_static_create(const void *source, * * @param ap Variable list of string arguments. */ -__syscall void z_log_msg_runtime_vcreate(uint8_t domain_id, const void *source, - uint8_t level, const void *data, - size_t dlen, uint32_t package_flags, - const char *fmt, - va_list ap); +void z_log_msg_runtime_vcreate(uint8_t domain_id, const void *source, + uint8_t level, const void *data, + size_t dlen, uint32_t package_flags, + const char *fmt, + va_list ap); /** @brief Create message at runtime. * diff --git a/subsys/logging/log_msg.c b/subsys/logging/log_msg.c index a28f1ddc10a..8023cefbf8c 100644 --- a/subsys/logging/log_msg.c +++ b/subsys/logging/log_msg.c @@ -281,7 +281,7 @@ static inline void z_vrfy_z_log_msg_static_create(const void *source, #include #endif -void z_impl_z_log_msg_runtime_vcreate(uint8_t domain_id, const void *source, +void z_log_msg_runtime_vcreate(uint8_t domain_id, const void *source, uint8_t level, const void *data, size_t dlen, uint32_t package_flags, const char *fmt, va_list ap) { @@ -330,15 +330,3 @@ void z_impl_z_log_msg_runtime_vcreate(uint8_t domain_id, const void *source, z_log_msg_finalize(msg, source, desc, data); } } - -#ifdef CONFIG_USERSPACE -static inline void z_vrfy_z_log_msg_runtime_vcreate(uint8_t domain_id, - const void *source, - uint8_t level, const void *data, size_t dlen, - uint32_t package_flags, const char *fmt, va_list ap) -{ - return z_impl_z_log_msg_runtime_vcreate(domain_id, source, level, data, - dlen, package_flags, fmt, ap); -} -#include -#endif