[Devel] [PATCH VZ10 v9 7/8] ve/printk: Don't use ve log outside task context
Vladimir Riabchun
vladimir.riabchun at virtuozzo.com
Tue Sep 15 20:22:35 MSK 2026
get_exec_env() in interrupt context will return VE of the process
that was interrupted.
We don't want to leak logs to unrelated containers if we use
ve_printk in a function that may be called in an interrupt.
https://virtuozzo.atlassian.net/browse/VSTOR-135520
Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
---
kernel/printk/printk.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 8940b36e790b..90ecd7960800 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -560,7 +560,8 @@ struct log_state *ve_log_state(void)
{
struct log_state *log = &init_log_state;
#ifdef CONFIG_VE
- if (get_exec_env()->log_state)
+ /* get_exec_env() is not reliable outside task context */
+ if (get_exec_env()->log_state && in_task())
log = get_exec_env()->log_state;
#endif
return log;
@@ -2538,7 +2539,7 @@ static asmlinkage int ve_vprintk(int dst, const char *fmt, va_list args)
va_copy(args2, args);
if (ve_is_super(get_exec_env()) || (dst & VE0_LOG))
r = vprintk(fmt, args);
- if (!ve_is_super(get_exec_env()) && (dst & VE_LOG))
+ if (!ve_is_super(get_exec_env()) && (dst & VE_LOG) && in_task())
r = ve_vprintk_emit(0, LOGLEVEL_DEFAULT, NULL, fmt, args2);
va_end(args2);
@@ -2570,7 +2571,7 @@ static asmlinkage int ve_vprintk_deferred(int dst, const char *fmt, va_list args
va_copy(args2, args);
if (ve_is_super(get_exec_env()) || (dst & VE0_LOG))
r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, fmt, args);
- if (!ve_is_super(get_exec_env()) && (dst & VE_LOG))
+ if (!ve_is_super(get_exec_env()) && (dst & VE_LOG) && in_task())
r = ve_vprintk_emit(0, LOGLEVEL_SCHED, NULL, fmt, args2);
va_end(args2);
--
2.47.1
More information about the Devel
mailing list