[Devel] [PATCH VZ10 v9 7/8] ve/printk: Don't use ve log outside task context
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Sep 25 19:02:33 MSK 2026
On 9/22/26 13:21, Vladimir Riabchun wrote:
> Please, don't take it with this series.
>
> The problem exists without the patches and we'd better add
> a proper fix in a separate series under the task VSTOR-146839.
ok, i won't apply this patch as well as i will drop neighbor related failcounter from the previous patch as it increases the amount of printks inside irq.
>
> On 9/15/26 19:22, Vladimir Riabchun wrote:
>> 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);
>>
>
More information about the Devel
mailing list