* [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn
@ 2026-11-25 16:48 Konstantin Khorenko
2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace Konstantin Khorenko
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Konstantin Khorenko @ 2026-11-25 16:48 UTC (permalink / raw)
To: Pavel Tikhomirov; +Cc: OpenVZ devel list, Denis V. Lunev
ve_check_trusted_exec()/ve_check_trusted_mmap() protect the host, but
the WARN(1, ...) is too much here:
* it taints the kernel while this is not a kernel bug which we beed to
debug and fix
* the backtrace only shows the exec/mmap path, which is already known
* on a host booted with panic_on_warn a denied exec takes the host down
The SIGSEGV and the core dump of the offending process are enough to
report and investigate such an attempt. Downgrade the WARN() to
pr_warn(), keeping the message, the rate limiting and the signal.
https://virtuozzo.atlassian.net/browse/VSTOR-147642
Fixes: fc7157b84c32 ("trusted/ve/mmap: Protect from unsecure library load from CT image")
Fixes: cc218b70c6b4 ("trusted/ve/fs/exec: Send SIGSEGV to a process trying to execute untrusted files")
Feature: security/fs: tructed exec feature
Link: http://lore.virtuozzo.com/20260819162513.493543-1-khorenko@virtuozzo.com
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
ReadyKernel-specific changes:
The patch was taken as-is without changes.
RK_BUG: VSTOR-157027 VSTOR-157031
RK_CHANGELOG: Do not crash a host with panic_on_warn on a denied exec/mmap.
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
kernel/ve/ve.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index b2788b80e7655..1a87229966042 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -1760,8 +1760,8 @@ bool ve_check_trusted_mmap(struct file *file)
if (file->f_path.dentry)
filename = file->f_path.dentry->d_name.name;
- WARN(1, "VE0 %s tried to map code from file '%s' from VEX\n",
- current->comm, filename);
+ pr_warn("VE0 %s tried to map code from file '%s' from VEX\n",
+ current->comm, filename);
force_sigsegv(SIGSEGV);
return false;
}
@@ -1780,7 +1780,7 @@ bool ve_check_trusted_exec(struct file *file, struct filename *name)
if (!__ratelimit(&sigsegv_rs))
return false;
- WARN(1, "VE0's %s tried to execute untrusted file %s from VEX\n",
+ pr_warn("VE0's %s tried to execute untrusted file %s from VEX\n",
current->comm, name->name);
force_sigsegv(SIGSEGV);
return false;
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 6+ messages in thread* [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace 2026-11-25 16:48 [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn Konstantin Khorenko @ 2026-11-25 16:48 ` Konstantin Khorenko 2026-12-01 0:20 ` no-reply 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko 2026-12-01 0:16 ` [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn no-reply 2 siblings, 1 reply; 6+ messages in thread From: Konstantin Khorenko @ 2026-11-25 16:48 UTC (permalink / raw) To: Pavel Tikhomirov; +Cc: OpenVZ devel list, Denis V. Lunev From: Eva Kurchatova <eva.kurchatova@virtuozzo.com> The kthreadd of a container is forked from a worker that takes over the namespaces, root, credentials and cgroups of the task starting the container, but not its ve namespace, which is not part of nsproxy. As task_ve follows the ve namespace, kthreadd and every kthread it forks, khelper included, run as host tasks, and so do the usermode helpers they start. A core dump to a pipe in a container then fails, since the host won't execute a file from an untrusted container disk. Switch the worker into the ve namespace of the starting task as well, last, as setns() does. Fixes: 4d033dd01fd3 ("ve: Make task_ve pointer ve namespace based") https://virtuozzo.atlassian.net/browse/VSTOR-152982 Feature: ve: ve generic structures Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com> Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Link: http://lore.virtuozzo.com/20261103173909.2589573-1-eva.kurchatova@virtuozzo.com ReadyKernel-specific changes: Patch adjusted to keep line numbers intact: the include takes the place of a blank line, a blank line in kthread_attach_fn() is dropped and so is the comment above the switch_ve_namespace() call. RK_BUG: VSTOR-157027 VSTOR-157031 RK_CHANGELOG: Fix core dumps to a pipe failing in containers. Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> --- kernel/ve/ve.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c index 1a87229966042..5e0b643d6dc68 100644 --- a/kernel/ve/ve.c +++ b/kernel/ve/ve.c @@ -33,7 +33,7 @@ #include <linux/tty.h> #include <linux/device.h> #include <linux/sched/loadavg.h> - +#include <linux/ve_namespace.h> #include <uapi/linux/vzcalluser.h> #include <net/rtnetlink.h> @@ -404,10 +404,10 @@ static void kthread_attach_fn(struct kthread_work *w) err = commit_creds(cred); if (err) goto out; - err = cgroup_attach_task_all(target, current); if (err) goto out; + switch_ve_namespace(current, get_ve_ns(target->ve_ns)); out: work->result = err; complete(&work->done); -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace Konstantin Khorenko @ 2026-12-01 0:20 ` no-reply 0 siblings, 0 replies; 6+ messages in thread From: no-reply @ 2026-12-01 0:20 UTC (permalink / raw) To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: Denis V. Lunev, OpenVZ devel list > From: Eva Kurchatova <eva.kurchatova@virtuozzo.com> > > The kthreadd of a container is forked from a worker that takes over the > namespaces, root, credentials and cgroups of the task starting the > container, but not its ve namespace, which is not part of nsproxy. > > As task_ve follows the ve namespace, kthreadd and every kthread it > forks, khelper included, run as host tasks, and so do the usermode > helpers they start. A core dump to a pipe in a container then fails, > since the host won't execute a file from an untrusted container disk. > > Switch the worker into the ve namespace of the starting task as well, > last, as setns() does. > > Fixes: 4d033dd01fd3 ("ve: Make task_ve pointer ve namespace based") > [ ... ] > > RK_BUG: VSTOR-157027 VSTOR-157031 > RK_CHANGELOG: Fix core dumps to a pipe failing in containers. > > Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> Sashiko has reviewed this patch and found no issues. Carry the trailer below into the next revision and Sashiko will not review this patch again. Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com> -- Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125164802.402895-1-khorenko@virtuozzo.com?part=2 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT 2026-11-25 16:48 [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn Konstantin Khorenko 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace Konstantin Khorenko @ 2026-11-25 16:48 ` Konstantin Khorenko 2026-12-01 0:25 ` no-reply 2026-12-01 0:16 ` [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn no-reply 2 siblings, 1 reply; 6+ messages in thread From: Konstantin Khorenko @ 2026-11-25 16:48 UTC (permalink / raw) To: Pavel Tikhomirov; +Cc: OpenVZ devel list, Denis V. Lunev From: Sean Christopherson <seanjc@google.com> [ Upstream commit c7c288d178cb0b78d3464a616b16b1aa0b316049 ] Force an MMU reset when emulating an INIT even if paging was already disabled, as the MMU page role includes guest_mode (L2), i.e. an INIT while L2 is running with CR0.PG=0 will result in KVM running L1 with a stale MMU context. Alternatively, the reset could be scoped strictly to paging being enabled or L2 being active, but SMM is also encoded in the page role. Even though it _should_ be impossible for the vCPU to be INIT'd while SMM is active, there's zero value in not handling SMM. At that point, the only scenario where KVM _doesn't_ need to reset the MMU context is on an INIT with the vCPU running in Real Mode or Unpaged Protect Mode, and while INIT in those modes is somewhat common, it's far from a hot path and re-initializing the MMU is not expensive, especially when the role isn't changing (KVM elides most of the re-configuration in that case). Note, like the Fixes commit, this bug only affects nested SVM as INIT is an unconditional intercept on VMX, i.e. it's impossible to emulate INIT while L2 is active. Temporarily keep the guest TLB flush when CR0.PG is being cleared even though it is fully redundant with the flush that is emitted on all INIT events (KVM itself only does RESET when a vCPU is being created, i.e. when CR0.PG must be '0'). Fixes: ed129ec9057f ("KVM: x86: forcibly leave nested mode on vCPU reset") Reported-by: Stefan Teodorescu <fane@google.com> Reported-by: Oren Yomtov <thenameisoren@gmail.com> Reported-by: Chris Mason <mason@kernel.org> Cc: stable@vger.kernel.org Cc: Yosry Ahmed <yosry@kernel.org> Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20261022015407.279870-2-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> (based on commit f55a3e4e08dc004b4bab7c1e9323d7e7e96e266a) https://virtuozzo.atlassian.net/browse/VSTOR-156442 Feature: fix ms/kvm ReadyKernel-specific changes: The fix is moved out of kvm_vcpu_reset() into svm_leave_nested(): - kvm_vcpu_reset() can't be livepatched: klp-build rejects its kvm_x86_call() static calls, their keys live in kvm.ko. - kvm-amd.ko can't call kvm_mmu_reset_context() from a livepatch: it does not reference that symbol today ("unexpected klp reloc for new symbol"). - svm_leave_nested() is where INIT drops guest_mode, through kvm_vcpu_reset() -> kvm_leave_nested(). Re-initialize the MMU there as a nested #VMEXIT does in nested_svm_load_cr3(): kvm_init_mmu() computes the role without guest_mode, kvm_mmu_new_pgd() moves L1 off the root built for L2. The root vmcb01 points to is then rewritten (KVM_REQ_LOAD_MMU_PGD or a reload) before the next VM-Enter, instead of the root L1 had before VMRUN, which may be freed by then. - Request MMU sync and TLB flush as nested_svm_transition_tlb_flush() does: kvm_mmu_new_pgd() may reuse a cached root and leaves both to its caller. - INIT with CR0.PG=1 is reset by kvm_vcpu_reset() anyway. With CR0.PG=0 (the bug) the role depends on guest_mode and smm only, so the one set here is final. INIT in SMM, also covered upstream, stays as is: it should be impossible. - The other callers of svm_leave_nested() (set nested state, RSM failure, KVM_SET_VCPU_EVENTS SMM change, shutdown intercept in L2, vCPU free) re-initialize the MMU too when the vCPU leaves L2. An unintercepted EFER.SVME clear by L2 gets the fix this way as well; upstream c7c288d does not cover that path. - Not covered: the shutdown intercept outside L2 with CR0.PG=0 clears vmcb01 and kvm_vcpu_reset() skips the MMU reset; upstream fixes that as a side effect. It does not involve nested state. - Blank lines of svm_leave_nested() are dropped to keep the line numbers of nested.c intact. The svm_leave_nested() variant is Fima Shevrin's. RK_BUG: VSTOR-156442 RK_CVE: CVE-2026-99312 RK_CHANGELOG: Fix a guest-to-host use-after-free in nested KVM on AMD. Co-developed-by: Fima Shevrin <efim.shevrin@virtuozzo.com> Signed-off-by: Fima Shevrin <efim.shevrin@virtuozzo.com> Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> --- arch/x86/kvm/svm/nested.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c index b7fd2e8699987..7095ed7ce2e01 100644 --- a/arch/x86/kvm/svm/nested.c +++ b/arch/x86/kvm/svm/nested.c @@ -1339,14 +1339,14 @@ void svm_leave_nested(struct kvm_vcpu *vcpu) if (is_guest_mode(vcpu)) { svm->nested.nested_run_pending = 0; svm->nested.vmcb12_gpa = INVALID_GPA; - leave_guest_mode(vcpu); - svm_switch_vmcb(svm, &svm->vmcb01); - nested_svm_uninit_mmu_context(vcpu); vmcb_mark_all_dirty(svm->vmcb); - + kvm_init_mmu(vcpu); + kvm_mmu_new_pgd(vcpu, vcpu->arch.cr3); + kvm_make_request(KVM_REQ_MMU_SYNC, vcpu); + kvm_make_request(KVM_REQ_TLB_FLUSH_CURRENT, vcpu); if (kvm_apicv_activated(vcpu->kvm)) kvm_make_request(KVM_REQ_APICV_UPDATE, vcpu); } -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko @ 2026-12-01 0:25 ` no-reply 0 siblings, 0 replies; 6+ messages in thread From: no-reply @ 2026-12-01 0:25 UTC (permalink / raw) To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: Denis V. Lunev, OpenVZ devel list > From: Sean Christopherson <seanjc@google.com> > > [ Upstream commit c7c288d178cb0b78d3464a616b16b1aa0b316049 ] > > Force an MMU reset when emulating an INIT even if paging was already > disabled, as the MMU page role includes guest_mode (L2), i.e. an INIT while > L2 is running with CR0.PG=0 will result in KVM running L1 with a stale MMU > context. > > Alternatively, the reset could be scoped strictly to paging being enabled > or L2 being active, but SMM is also encoded in the page role. Even though > it _should_ be impossible for the vCPU to be INIT'd while SMM is active, > there's zero value in not handling SMM. At that point, the only scenario > where KVM _doesn't_ need to reset the MMU context is on an INIT with the > vCPU running in Real Mode or Unpaged Protect Mode, and while INIT in those > [ ... ] > > Co-developed-by: Fima Shevrin <efim.shevrin@virtuozzo.com> > Signed-off-by: Fima Shevrin <efim.shevrin@virtuozzo.com> > Reviewed-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com> > Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> Sashiko has reviewed this patch and found no issues. Carry the trailer below into the next revision and Sashiko will not review this patch again. Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com> -- Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125164802.402895-1-khorenko@virtuozzo.com?part=3 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn 2026-11-25 16:48 [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn Konstantin Khorenko 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace Konstantin Khorenko 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko @ 2026-12-01 0:16 ` no-reply 2 siblings, 0 replies; 6+ messages in thread From: no-reply @ 2026-12-01 0:16 UTC (permalink / raw) To: Konstantin Khorenko, Pavel Tikhomirov; +Cc: Denis V. Lunev, OpenVZ devel list > ve_check_trusted_exec()/ve_check_trusted_mmap() protect the host, but > the WARN(1, ...) is too much here: > > * it taints the kernel while this is not a kernel bug which we beed to > debug and fix > * the backtrace only shows the exec/mmap path, which is already known > * on a host booted with panic_on_warn a denied exec takes the host down > > The SIGSEGV and the core dump of the offending process are enough to > report and investigate such an attempt. Downgrade the WARN() to > pr_warn(), keeping the message, the rate limiting and the signal. > > https://virtuozzo.atlassian.net/browse/VSTOR-147642 > > Fixes: fc7157b84c32 ("trusted/ve/mmap: Protect from unsecure library load from CT image") > Fixes: cc218b70c6b4 ("trusted/ve/fs/exec: Send SIGSEGV to a process trying to execute untrusted files") > Feature: security/fs: tructed exec feature > Link: http://lore.virtuozzo.com/20260819162513.493543-1-khorenko@virtuozzo.com > Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> > > ReadyKernel-specific changes: > The patch was taken as-is without changes. > > RK_BUG: VSTOR-157027 VSTOR-157031 > RK_CHANGELOG: Do not crash a host with panic_on_warn on a denied exec/mmap. > > Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com> Sashiko has reviewed this patch and found no issues. Carry the trailer below into the next revision and Sashiko will not review this patch again. Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com> -- Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261125164802.402895-1-khorenko@virtuozzo.com?part=1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-12-01 0:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-11-25 16:48 [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn Konstantin Khorenko 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 2/3] ve: start the kthreads of a container in its ve namespace Konstantin Khorenko 2026-12-01 0:20 ` no-reply 2026-11-25 16:48 ` [Devel] [PATCH RK hci-8.0 3/3] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko 2026-12-01 0:25 ` no-reply 2026-12-01 0:16 ` [Devel] [PATCH RK hci-8.0 1/3] ve: downgrade the trusted exec/mmap denial from WARN to pr_warn no-reply
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox