Patch: OpenVZ 7 Crash and Container2host - NFS4 Bug: CVE-2026-99362
Sí, aquí vamos de nuevo, ya paso en ghostlock y en el otro CVE 2026-99999 de ese no subi parche, pero oficialmente el desarrollador lanzó una actualización para ese CVE un mes después.
No culpo a nadie, estamos en un sistema obsoleto, pero las migraciones son así, lentas y tediosas y a veces hay que mantener el código. Para ese CVE yo había hecho backport tomando el parche desde tuxcare, pero esta vez el bug es bastante más feo.
https://opensec.in/blog/nfs2root-cve-2026-99362
Ahí pueden ver más información: Pre-auth heap overflow in the Linux NFS server (nfsd)
¿ Que sucede realmente aquí y por que nos afecta ?
EL problema es que un container en OVZ7 con nfs4 y el servidor nfs levantado y accesible local o remotamente por el puerto 2049 simplemente puede hacer que nuestro nodo crashee.
Tengo el POC desarrollado, pero no lo voy a subir al menos de momento, pero lo he confirmado 15 veces, un acceso remoto o local genera un kernel panic en el nodo y este se reinicia. El POC lo he desarrollado tal cual para reproducir el bug y ver si nos afecta, pero es un problema mayor, ya que el bug original habla de escalada a root, pues si este POC puede explotar parte del problema y crashear el nodo, quiere decir que también hay escalada de privilegios en el kernel 3.10.x el bug se introdujo en 3.14 pero este bug soluciona un problema de seguridad así que hubo backport a la 3.10.
Voy a dejar el kernel OVZ7 compilado para varios problemas de seguridad, no quiero que nadie lo instale, pero si tienes problemas de que te crashean el nodo adelante, está probado.
En todo caso si quieres compilar tu mismo el kernel que sería lo ideal para no fiarse de nadie aquí dejo el parche que a mi me funciona para evitar el crash:
From: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
Subject: [PATCH] nfsd: preflight SEQUENCE replies before accepting a slot
Backport of upstream commit 5d5a72e965c8b6ec870f114b9fe4961b8697732e
("nfsd: preflight SEQUENCE replies before accepting a slot"), by
Jérémy Jean (ANSSI), for CVE-2026-99362 ("NFS2ROOT"). Adapted to the
OpenVZ 7 vzkernel (3.10.0-1160.129.1.vz7.226.5).
The original bug was introduced by upstream commit 47ee52986472
("nfsd4: adjust buflen to session channel limit"). The 3.10 OpenVZ tree
carries the RHEL 7 backport of NFSv4.1 sessions, including the same
nfsd4_sequence() logic, so it is vulnerable.
nfsd4_sequence() narrows the reply buffer to the session's cached
reply limit before it accepts the slot seqid. A client may negotiate
ca_maxresponsesize_cached down to NFSD_MIN_HDR_SEQ_SZ, and
nfsd4_alloc_slot() gives every slot a zero-length sl_data[]. A
COMPOUND tag can fill that narrowed buffer until it holds the
SEQUENCE opcode but not the status word that follows.
nfsd4_encode_operation() returns without running
nfsd4_encode_sequence(), so cstate.data_offset stays zero. It leaves
op->status at nfs_ok as well, so the COMPOUND is treated as having
succeeded.
nfsd4_store_cache_entry() declines to cache a lone SEQUENCE that
returned an error. That test reads the status the operation reported,
so it passes here. The copy starts at offset zero and takes the whole
reply, RPC and COMPOUND headers included, into the zero-length
sl_data[]. The COMPOUND tag is copied along with it, so the client
picks most of the bytes written past the end of the slot.
Check that the fixed-size SEQUENCE result, plus room for a following
operation's error status, fits the negotiated limit before narrowing
the buffer and consuming the slot seqid.
Adaptation notes for the OpenVZ 7 tree:
- The upstream hunk keeps svc_reserve_auth() as context. The 3.10
tree already calls svc_reserve() here and buflen already includes
rq_auth_slack (xdr_restrict_buflen subtracts it), so the existing
call is kept; the auth reservation is not part of this fix.
- nfsd4_sequence() already receives rq_argp as the decoded
nfsd4_compoundargs; args->ops[0] is the SEQUENCE operation.
- nfsd4_max_reply(), nfsd4_last_compound_op() and
COMPOUND_ERR_SLACK_SPACE are already present in this tree.
Upstream-Link: https://lore.kernel.org/all/20260817-jean-v1-1-9e356596ab85@kernel.org/
CVE: CVE-2026-99362
Signed-off-by: backport for OpenVZ 7 vzkernel <noreply@example.com>
---
fs/nfsd/nfs4state.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index a619663f..402b3e07 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3046,6 +3046,7 @@ nfsd4_sequence(struct svc_rqst *rqstp,
struct nfsd4_compound_state *cstate,
struct nfsd4_sequence *seq)
{
+ struct nfsd4_compoundargs *args = rqstp->rq_argp;
struct nfsd4_compoundres *resp = rqstp->rq_resp;
struct xdr_stream *xdr = &resp->xdr;
struct nfsd4_session *session;
@@ -3054,6 +3055,7 @@ nfsd4_sequence(struct svc_rqst *rqstp,
struct nfsd4_conn *conn;
__be32 status;
int buflen;
+ u32 maxlen, respsize;
struct net *net = SVC_NET(rqstp);
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
@@ -3122,7 +3124,22 @@ nfsd4_sequence(struct svc_rqst *rqstp,
session->se_fchannel.maxresp_sz;
status = (seq->cachethis) ? nfserr_rep_too_big_to_cache :
nfserr_rep_too_big;
- if (xdr_restrict_buflen(xdr, buflen - rqstp->rq_auth_slack))
+ if (buflen < rqstp->rq_auth_slack)
+ goto out_put_session;
+ maxlen = buflen - rqstp->rq_auth_slack;
+
+ /*
+ * A SEQUENCE result too large for maxlen never reaches
+ * nfsd4_encode_sequence(), so cstate.data_offset stays zero and
+ * the reply cache overruns the slot.
+ */
+ respsize = nfsd4_max_reply(rqstp, &args->ops[0]);
+ if (!nfsd4_last_compound_op(rqstp))
+ respsize += COMPOUND_ERR_SLACK_SPACE;
+ if (xdr->buf->len + respsize > maxlen)
+ goto out_put_session;
+
+ if (xdr_restrict_buflen(xdr, maxlen))
goto out_put_session;
svc_reserve(rqstp, buflen);
From: Chuck Lever <cel@kernel.org>
Subject: [PATCH] nfsd: set op->status when an operation's header cannot be
encoded
Backport of upstream commit 241848cc774eb1172fa867bb6a28c32cf1869c0d
("nfsd: set op->status when an operation's header cannot be encoded"),
the follow-up guard for CVE-2026-99362. Adapted to the OpenVZ 7
vzkernel (3.10.0-1160.129.1.vz7.226.5).
nfsd4_encode_operation() leaves op->status alone when the reply
buffer has no room for the operation's opcode and status word.
nfsd4_proc_compound() reads the unchanged nfs_ok as success and
goes on to the next operation, so the reply counts an operation
whose result was never encoded.
Report the failure through nfsd4_check_resp_size(), which the rest
of the function already uses. It returns NFS4ERR_REP_TOO_BIG, or
NFS4ERR_REP_TOO_BIG_TO_CACHE on a session, and the COMPOUND ends
at that operation.
This is a guard, not the fix for CVE-2026-99362: the preflight in
nfsd4_sequence() (previous patch) rejects a SEQUENCE result that
does not fit.
Adaptation notes for the OpenVZ 7 tree:
- 3.10 reserves opnum and status in a single 8-byte
xdr_reserve_space() call instead of two XDR_UNIT calls, so the
single failure path reports the 8-byte header size.
- The old WARN_ON_ONCE(1) is dropped, matching upstream: the
condition is now an error reported to the client.
Upstream-Link: https://lore.kernel.org/all/20260817-jean-v1-2-9e356596ab85@kernel.org/
CVE: CVE-2026-99362
Signed-off-by: backport for OpenVZ 7 vzkernel <noreply@example.com>
---
fs/nfsd/nfs4xdr.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 712cc5da..fd7e50cf 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -4423,7 +4423,12 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op)
p = xdr_reserve_space(xdr, 8);
if (!p) {
- WARN_ON_ONCE(1);
+ /*
+ * nfsd4_proc_compound() stops the COMPOUND early only
+ * when op->status is set, so a header that cannot be
+ * encoded has to report the failure here.
+ */
+ op->status = nfsd4_check_resp_size(resp, 8);
return;
}
*p++ = cpu_to_be32(op->opnum);
Los 2 parches están probados contra el POC que tengo, evitan el crash el backport es desde el parche oficial https://lore.kernel.org/all/20260817-jean-v1-1-9e356596ab85@kernel.org/
La IA a metido mano para ayudar con el backport, no tengo tiempo ni ganas de pelearme, mucho ya tenemos con mantener sistemas antiguos e invertir mucho tiempo para quitarlos.
En cuanto al crash, dejo aquí algo de info al ejecutar el POC en el container, el nodo recibe un kernel panic y genera un coredump
[ 320.366041] WARNING: CPU: 7 PID: 2853 at fs/nfsd/nfs4xdr.c:4426 nfsd4_encode_operation+0x19e/0x1b0 [nfsd]
[ 320.366042] Modules linked in: nft_reject_inet nft_reject nft_meta nft_ct nft_hash nft_rbtree nf_tables_inet nft_chain_nat_ipv6 nft_chain_route_ipv6 nft_chain_nat_ipv4 nft_chain_route_ipv4 ip_set nf_tables_bridge nf_tables_ipv6 nf_tables_ipv4 nf_tables nfsd auth_rpcgss nfs_acl lockd grace 8021q garp mrp devlink xt_CHECKSUM ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 ip6table_mangle ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 iptable_mangle iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat ip6table_filter ip6_tables iptable_filter tun ebtable_filter ebt_among ebtables sunrpc ipmi_ssif intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel iTCO_wdt iTCO_vendor_support kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper
[ 320.366086] cryptd i2c_i801 pcspkr sg lpc_ich joydev mei_me mei ipmi_si ipmi_devintf ie31200_edac ipmi_msghandler acpi_pad video ip_vs nf_conntrack libcrc32c br_netfilter veth overlay ip6_vzprivnet ip6_vznetstat ip_vznetstat ip_vzprivnet vziolimit vzevent vzlist vzstat vznetstat vznetdev vzmon vzdev fuse bridge binfmt_misc stp llc ip_tables ext4 mbcache jbd2 sd_mod crc_t10dif crct10dif_generic ast drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ahci drm libahci igb libata crct10dif_pclmul crct10dif_common crc32c_intel ptp pps_core dca drm_panel_orientation_quirks i2c_algo_bit dm_mirror dm_region_hash dm_log dm_mod pio_kaio pio_nfs pio_direct pfmt_raw pfmt_ploop1 ploop
[ 320.366124] CPU: 7 PID: 2853 Comm: nfsd ve: 129e8c59-25a7-4109-9e27-a4f88e92a92a Kdump: loaded Not tainted 3.10.0-1160.129.1.vz7.226.6. #1 226.6
[ 320.366126] Hardware name: Supermicro SYS-5038ML-H8TRF/X10SLD, BIOS 2.00 04/24/2014
[ 320.366127] Call Trace:
[ 320.366133] [<ffffffffba1f33c1>] dump_stack+0x19/0x1f
[ 320.366136] [<ffffffffb9aa1d78>] __warn+0xd8/0x100
[ 320.366138] [<ffffffffb9aa1ebd>] warn_slowpath_null+0x1d/0x30
[ 320.366142] [<ffffffffc0b3799e>] nfsd4_encode_operation+0x19e/0x1b0 [nfsd]
[ 320.366146] [<ffffffffc0b2cd40>] nfsd4_proc_compound+0x240/0x780 [nfsd]
[ 320.366151] [<ffffffffc0b17820>] nfsd_dispatch+0xe0/0x290 [nfsd]
[ 320.366161] [<ffffffffc0a77820>] svc_process_common+0x410/0x7e0 [sunrpc]
[ 320.366167] [<ffffffffc0a77ceb>] svc_process+0xfb/0x110 [sunrpc]
[ 320.366170] [<ffffffffc0b1718f>] nfsd+0xdf/0x150 [nfsd]
[ 320.366174] [<ffffffffc0b170b0>] ? nfsd_destroy+0x80/0x80 [nfsd]
[ 320.366176] [<ffffffffb9acf8c1>] kthread+0xd1/0xe0
[ 320.366179] [<ffffffffb9acf7f0>] ? create_kthread+0x60/0x60
[ 320.366181] [<ffffffffba207337>] ret_from_fork_nospec_begin+0x21/0x21
[ 320.366183] [<ffffffffb9acf7f0>] ? create_kthread+0x60/0x60
[ 320.366184] ---[ end trace b807be3749288e9b ]---
[ 320.594775] general protection fault: 0000 [#1] SMP
[ 320.594796] Modules linked in: nft_reject_inet nft_reject nft_meta nft_ct nft_hash nft_rbtree nf_tables_inet nft_chain_nat_ipv6 nft_chain_route_ipv6 nft_chain_nat_ipv4 nft_chain_route_ipv4 ip_set nf_tables_bridge nf_tables_ipv6 nf_tables_ipv4 nf_tables nfsd auth_rpcgss nfs_acl lockd grace 8021q garp mrp devlink xt_CHECKSUM ip6t_REJECT nf_reject_ipv6 ipt_REJECT nf_reject_ipv4 ip6table_mangle ip6table_nat nf_conntrack_ipv6 nf_defrag_ipv6 nf_nat_ipv6 iptable_mangle iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat ip6table_filter ip6_tables iptable_filter tun ebtable_filter ebt_among ebtables sunrpc ipmi_ssif intel_powerclamp coretemp intel_rapl iosf_mbi kvm_intel iTCO_wdt iTCO_vendor_support kvm irqbypass crc32_pclmul ghash_clmulni_intel aesni_intel lrw gf128mul glue_helper ablk_helper
[ 320.595037] cryptd i2c_i801 pcspkr sg lpc_ich joydev mei_me mei ipmi_si ipmi_devintf ie31200_edac ipmi_msghandler acpi_pad video ip_vs nf_conntrack libcrc32c br_netfilter veth overlay ip6_vzprivnet ip6_vznetstat ip_vznetstat ip_vzprivnet vziolimit vzevent vzlist vzstat vznetstat vznetdev vzmon vzdev fuse bridge binfmt_misc stp llc ip_tables ext4 mbcache jbd2 sd_mod crc_t10dif crct10dif_generic ast drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm ahci drm libahci igb libata crct10dif_pclmul crct10dif_common crc32c_intel ptp pps_core dca drm_panel_orientation_quirks i2c_algo_bit dm_mirror dm_region_hash dm_log dm_mod pio_kaio pio_nfs pio_direct pfmt_raw pfmt_ploop1 ploop
[ 320.595304] CPU: 0 PID: 2853 Comm: nfsd ve: 129e8c59-25a7-4109-9e27-a4f88e92a92a Kdump: loaded Tainted: G W ------------ 3.10.0-1160.129.1.vz7.226.6. #1 226.6
[ 320.595342] Hardware name: Supermicro SYS-5038ML-H8TRF/X10SLD, BIOS 2.00 04/24/2014
[ 320.595361] task: ffff9a1e94c2e000 ti: ffff9a1e94c30000 task.ti: ffff9a1e94c30000
[ 320.595379] RIP: 0010:[<ffffffffb9c57eea>] [<ffffffffb9c57eea>] __kmalloc_track_caller+0xba/0x260
[ 320.595405] RSP: 0018:ffff9a1e94c33c38 EFLAGS: 00010286
[ 320.595418] RAX: 0000000000000008 RBX: 0000000000000080 RCX: 00000000000040e5
[ 320.595435] RDX: 00000000000040e4 RSI: 0000000000000000 RDI: 0000000000000001
[ 320.595453] RBP: ffff9a1e94c33c70 R08: 000000000002a060 R09: ffff9a183fc01b40
[ 320.595470] R10: 0000000000000007 R11: ffff9a1e952fe080 R12: 00000000000000d0
[ 320.595487] R13: 4141414141414141 R14: 000000000000000e R15: ffff9a183fc01b40
[ 320.595505] FS: 0000000000000000(0000) GS:ffff9a1edfc00000(0000) knlGS:0000000000000000
[ 320.595524] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 320.595539] CR2: 00007f177f779000 CR3: 000000043b410000 CR4: 00000000001607f0
[ 320.595556] Call Trace:
[ 320.595573] [<ffffffffc0b3b199>] ? create_client.isra.89+0x69/0x340 [nfsd]
[ 320.595592] [<ffffffffb9c046c0>] kmemdup+0x20/0x50
[ 320.595609] [<ffffffffc0b3b199>] create_client.isra.89+0x69/0x340 [nfsd]
[ 320.595629] [<ffffffffc0b3bea4>] nfsd4_exchange_id+0xe4/0x520 [nfsd]
[ 320.595646] [<ffffffffb9b15d00>] ? getboottime+0x30/0x40
[ 320.595663] [<ffffffffc0b2cedd>] nfsd4_proc_compound+0x3dd/0x780 [nfsd]
[ 320.595682] [<ffffffffc0b17820>] nfsd_dispatch+0xe0/0x290 [nfsd]
[ 320.595708] [<ffffffffc0a77820>] svc_process_common+0x410/0x7e0 [sunrpc]
[ 320.595732] [<ffffffffc0a77ceb>] svc_process+0xfb/0x110 [sunrpc]
[ 320.595749] [<ffffffffc0b1718f>] nfsd+0xdf/0x150 [nfsd]
[ 320.596426] [<ffffffffc0b170b0>] ? nfsd_destroy+0x80/0x80 [nfsd]
[ 320.597096] [<ffffffffb9acf8c1>] kthread+0xd1/0xe0
[ 320.597762] [<ffffffffb9acf7f0>] ? create_kthread+0x60/0x60
[ 320.598427] [<ffffffffba207337>] ret_from_fork_nospec_begin+0x21/0x21
[ 320.599089] [<ffffffffb9acf7f0>] ? create_kthread+0x60/0x60
[ 320.599748] Code: 93 3b 46 49 8b 50 08 4d 8b 28 49 8b 40 10 4d 85 ed 0f 84 45 01 00 00 48 85 c0 0f 84 3c 01 00 00 49 63 47 20 48 8d 4a 01 4d 8b 07 <49> 8b 5c 05 00 4c 89 e8 65 49 0f c7 08 0f 94 c0 84 c0 74 b9 49
[ 320.601228] RIP [<ffffffffb9c57eea>] __kmalloc_track_caller+0xba/0x260
[ 320.601964] RSP <ffff9a1e94c33c38>
El kernel compilado con el parche se puede descargar desde aquí:
Aparte de este parche, el kernel se ha compilado contra la última versión: * Thu Nov 19 2026 Konstantin Khorenko <khorenko@virtuozzo.com> [3.10.0-1160.129.1.vz7.226.6]
Lás ultimas lineas del changelog quedarían así para que vean los bugs corregidos
- Rebase on the official OpenVZ vzkernel 226.6 (released 2026-11-19)
- Drop 0001: 226.6 already includes the ipv4 checksum_start validation
for CVE-2026-99999 through patch-ovz.xz
- Carry over 15 security backports from tuxcare(CVE-2026-74630, CVE-2026-43339,
CVE-2026-98222, CVE-2026-52923, CVE-2026-72323, CVE-2026-53275,
CVE-2026-74480, CVE-2021-47352, CVE-2026-74656, CVE-2026-81000,
CVE-2026-89786, CVE-2026-68093, CVE-2026-74580)
- nfsd: preflight SEQUENCE replies before accepting a slot {CVE-2026-99362}
- nfsd: set op->status when an operation's header cannot be encoded {CVE-2026-99362}
* Thu Nov 19 2026 Konstantin Khorenko <khorenko@virtuozzo.com> [3.10.0-1160.129.1.vz7.226.6]
- ms/net: lock the socket in sock_gettstamp() (Eric Dumazet) [VSTOR-155948]
- ms/crypto: af_alg - Disallow concurrent writes in af_alg_sendmsg (Herbert Xu) [VSTOR-154198]
- ms/netfilter: bridge: make ebt_snat ARP rewrite writable (Yiming Qian) [VSTOR-154194]
- ms/netfilter: nf_tables: stricter validation of element data (Pablo Neira Ayuso) [VSTOR-154185]
- ms/ipv4: validate checksum_start before completing checksum (Michael S. Tsirkin) [VSTOR-154184]
- b4: ship project defaults in .b4-config (Konstantin Khorenko) [VSTOR-142960]
* Thu Sep 17 2026 Konstantin Khorenko <khorenko@virtuozzo.com> [latest]
* Thu Sep 17 2026 Konstantin Khorenko <khorenko@virtuozzo.com> [3.10.0-1160.129.1.vz7.226.4]
- ms/bridge: stp: Fix a potential use-after-free when deleting a bridge (Ido Schimmel) [VSTOR-145092]
Esta versión es completamente innecesaria, posiblemente el desarrollador saque un parche, pero el sistema esta obsoleto y los parches van lentos por parte del desarrollador, es completamente comprensible, así que si tienes problemas con crasheos o tienes muchos NFS funcionando en containers, aplica el parche sí no puedes esperar; y si no pues, espera
Parte de la solución es simplemente desactivar NFS en los containers, aunque esto no siempre es posible, toda esa historia ya la sabemos.
El último kernel que compilamos para parchear ghostlock fue: kernel-tools-3.10.0-1160.129.1.vz7.226.2.compiled.by.skamasle.com.x86_64.rpm
Esta vez tenemos a https://skamasle.com/rpm/x86_64/vzkernel-3.10.0-1160.129.1.vz7.226.7.compiled.by.skamasle.com.x86_64.rpm
Repositorio: https://skamasle.com/rpm/x86_64/https://skamasle.com/rpm/x86_64/vzkernel/