Skip to content

Commit 9bf333a

Browse files
nordic-krchnashif
authored andcommitted
logging: Fix user space crash when runtime filtering is on
Logging module data (including filters) are not accessible by the user space. Macro for creating logs where creating local variable with filters before checking is we are in the user context. It was not used in that case but creating variable was violating access writes that resulted in failure. Removing variable creation and using filters directly in the if clause but after checking condition that it is not the user context. With this approach data is accessed only in the kernel mode. Signed-off-by: Krzysztof Chruscinski <[email protected]>
1 parent f8c8ee6 commit 9bf333a

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

include/zephyr/logging/log_core.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,8 @@ static inline char z_log_minimal_level_to_char(int level)
229229
} \
230230
\
231231
bool is_user_context = k_is_user_context(); \
232-
uint32_t filters = IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) ? \
233-
(_dsource)->filters : 0;\
234232
if (!IS_ENABLED(CONFIG_LOG_FRONTEND) && IS_ENABLED(CONFIG_LOG_RUNTIME_FILTERING) && \
235-
!is_user_context && _level > Z_LOG_RUNTIME_FILTER(filters)) { \
233+
!is_user_context && _level > Z_LOG_RUNTIME_FILTER((_dsource)->filters)) { \
236234
break; \
237235
} \
238236
int _mode; \

0 commit comments

Comments
 (0)