From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id B708C8015C for ; Sun, 20 Sep 2026 17:47:43 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68KHkG5V028034; Sun, 20 Sep 2026 20:46:17 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68KHkG5V028034 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="aqjqV4ho" Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 68KHkFHu028023 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Sun, 20 Sep 2026 20:46:15 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 68KHkFHu028023 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-49cf5bd2f12so31289965e9.1 for ; Sun, 20 Sep 2026 10:46:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AKwUvBwKV2jTbPdDb+sR5KFoJYG0vRKjRsBWkHPd2DGUT9ew9ujwejEL6qMbUDzm4Zmt5JUS6Rf+jg==@openvz.org X-Gm-Message-State: AFuF++mmLNLeOas1zFogy34PHPK205Lg5e5LWiJJhyq7TaHv6RSqoiLN dZ1BHmxrNpZtqU5AGBQaUNorTIZqjv0AsvzXARhrFNO8VHVzlKYDH4s+6BDTb4YsFGlKSTj7tKg Ga/fXyqCF0FogPlQx46gBaY2xN53PZKLlDxDe3qEntUQjMIb8yDmSyg== X-Gm-Gg: AYBFou2kOeSgbUQ0j1rcH0xRxTRezz2iMSMApY4QVHHznbKXfMTU+RFPDf+/QMXwh4F Lshpq7/sBgHfvYU3J6N23OczKvT3M3I0NFtwhWL7np0t2VT460v91HH9QXkxsE4eU6Xcve+PZbd ym0D8Ss9ZdjIxx3Jamdx3u6TotW2ZjCsFRfddiHdLw+J0YPx+BymEUcDsgRVPW0DZLMgPDOMW8d 9SNzrYtV3arKH5g19Fpe8/a+UAroMxV9RjYiIZK/gmONbQ/VIGkrDShpYRDJ6L8XWAjiVc26e/A FjstYN4QITTIdoHyc7r2D7op0E9Xt6kXcBitqcNJZt8cSXkMNmgA31r9Zb/KojTu4JpOOlJVhpk HPQ6CnnLpzmMjxnODGyijuMht24mI X-Received: by 2002:a05:600d:4453:20b0:49c:fa21:1c7d with SMTP id 5b1f17b1804b1-49fc5a10ca6mr78876715e9.18.1789926375582; Sun, 20 Sep 2026 10:46:15 -0700 (PDT) X-Received: by 2002:a05:600d:4453:20b0:49c:fa21:1c7d with SMTP id 5b1f17b1804b1-49fc5a10ca6mr78876545e9.18.1789926375044; Sun, 20 Sep 2026 10:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1789926375; cv=none; d=google.com; s=arc-20260327; b=jZ4wlNF/+r+zcj0dIWzTo28f1Au/VfWSnGAMwHl0RRDk5ucohcf/R7iP7DtV//T4ph vnJiNBjQ5tY8u/grZ/CgcDX5TtgrD7ebwDwl/s1n5lYQ31BPRPV03cocSzzR2IWFoZQa ow3Uy2PLrcZ93X8FeIXdmlhLR6+/8TLg/ZJ4agtkO8zk4vAK3JiId2soREsLBp6CA5wO 34dmfthoXE2ViD1tjn0JpH1mwUQQWX0HrbJqWyvmZYRoWoYfmOQwo7c9VsfXEvQck3av IS/neDzb9j6NeTYCOxk8M1omjC+JBVW3HlRE3DvIqfustkkl0yNHPg7aMyMkrgNb03SB ko8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=HWCRphRthsn8ja08cn5bVx5Ncw/LdXAhBu/0GAsOrvE=; fh=4dppuILCfGifWHfxjIIA1BWoKQtGs1EMopxlFiqV6no=; b=XxgW8YLJsz+ZI9fEnhiF/ZWigNd/HsFiz5OnZqyRVmLkDCnOuJxd4xrcYQlMzN0S6H sMntprEnzsxaa0SAVhz+QE9Y4HW9uLhZmOpT25mYY410d0uSyZkEJvMTH1SwNtcPelz9 031mDwswiTO14BHD3tNZI2PIU4x/ixkbgytjXdDE0r+U+a1yay+Zn0rUQjHx/FwvljOb y3wzQsyPUNWbUO3uv5akb6CeWIxLTDsS4J0Jp6zAVTT0j19ovjkCPSt5tE7FXoayhYzE wy+3iBjkwzN9kRTWHnvU/2Z5EAUy/i7PgquK7ounxJFl555T52y3Yz0/U9hDZEOzv7dq jonQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=aqjqV4ho; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-4872457bb73si9540110f8f.127.2026.09.20.10.46.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Sep 2026 10:46:14 -0700 (PDT) Received-SPF: pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=aqjqV4ho; spf=pass (google.com: domain of vladimir.riabchun@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=vladimir.riabchun@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=HWCRphRthsn8ja08cn5bVx5Ncw/LdXAhBu/0GAsOrvE=; b=aqjqV4hoAdiCX8OJHBK PD0UC9m8vMP4SMonCBiyf1naf7viXd1QZfEwhaIBM4fi6+8FDNXoIXgSvfsv4NzMumlk61a1BW+hp G20jey1b2MeuJqguvHcaVpTR66C792FuIzMDz44xvypn5XOgvG7gSLngrGzVlwF6aigro0N62ji8W xOOPGEEg7Dyi8sKpUc0q9npjo/hfMyCv39O1/aQRGmEFqUHByJEw25kUZuZ4LMrixtWH273oO+HlG 1oSs+LehTDxH/lWzCR4pH0v6g7eMX9G4bK2ek6/dxuSbAQVuVsMCuA9hZNtkWFiaK2lQJL/OvKfOP szo8GHOH5OvgnjA==; Received: from [130.117.225.5] (helo=dev012.aci.vzint.dev) by relay.virtuozzo.com with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x8LZN-00E3NU-2d; Sun, 20 Sep 2026 19:46:07 +0200 From: Vladimir Riabchun Date: Sun, 20 Sep 2026 17:45:43 +0000 MIME-Version: 1.0 Message-Id: <20260920-ovl-use-orig-ve-v1-2-b3e63f6ff80d@virtuozzo.com> References: <20260920-ovl-use-orig-ve-v1-0-b3e63f6ff80d@virtuozzo.com> In-Reply-To: <20260920-ovl-use-orig-ve-v1-0-b3e63f6ff80d@virtuozzo.com> To: Konstantin Khorenko X-Mailer: b4 0.16.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 2/2] ovl: Keep creator VE in overlayfs superblock X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org We observed a crash in overlayfs when checkpointing a container with docker running inside: [ 2300.870181] BUG: kernel NULL pointer dereference, address: 0000000000000005 [ 2300.871537] #PF: supervisor read access in kernel mode [ 2300.872577] #PF: error_code(0x0000) - not-present page [ 2300.873595] PGD 800000010a18f067 P4D 800000010a18f067 PUD 10730c067 PMD 0 [ 2300.874900] Oops: Oops: 0000 [#1] SMP PTI [ 2300.875742] CPU: 1 UID: 0 PID: 5419 Comm: criu ve: 0 Kdump: loaded Not tainted 6.12.0-211.39.1.16.6.vz10.x86_64 #1 16.6 PREEMPT(voluntary) [ 2300.878057] Hardware name: Acronis OpenStack Compute/Virtuozzo, BIOS 1.16.1-1.vz9.2 04/01/2014 [ 2300.879684] RIP: 0010:ovl_get_index_name_fh+0x18/0x70 [overlay] [ 2300.880859] Code: ... [ 2300.884128] RSP: 0018:ffffd32582e0f7c0 EFLAGS: 00010246 [ 2300.885153] RAX: 0000000000000010 RBX: 0000000000000000 RCX: ffff8ba4497480a8 [ 2300.886480] RDX: ffff8ba45535dc00 RSI: 0000000000000dc0 RDI: 0000000000000000 [ 2300.887824] RBP: ffff8ba68f9daa80 R08: ffff8ba4497480a8 R09: 000000000000030e [ 2300.889139] R10: 0000000000000000 R11: ffff8ba44862d6d0 R12: ffffd32582e0f800 [ 2300.890498] R13: 0000000000000000 R14: ffff8ba497cb0110 R15: ffff8ba517548cc0 [ 2300.891838] FS: 00007f5a2f492880(0000) GS:ffff8bab9fc80000(0000) knlGS:0000000000000000 [ 2300.893376] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2300.894476] CR2: 0000000000000005 CR3: 000000033403a005 CR4: 00000000003726f0 [ 2300.895807] Call Trace: [ 2300.896397] [ 2300.896938] ? show_trace_log_lvl+0x1b0/0x2f0 [ 2300.897854] ? show_trace_log_lvl+0x1b0/0x2f0 [ 2300.898748] ? ovl_create_index+0x82/0x260 [overlay] [ 2300.899766] ? __die_body.cold+0x8/0x12 [ 2300.900582] ? page_fault_oops+0x148/0x160 [ 2300.901562] ? exc_page_fault+0x7f/0x150 [ 2300.902406] ? asm_exc_page_fault+0x26/0x30 [ 2300.903298] ? ovl_get_index_name_fh+0x18/0x70 [overlay] [ 2300.904435] ovl_create_index+0x82/0x260 [overlay] [ 2300.905406] ovl_copy_up_workdir+0x30a/0x330 [overlay] [ 2300.906427] ovl_do_copy_up+0x10d/0x2e0 [overlay] [ 2300.907387] ovl_copy_up_one+0x456/0x720 [overlay] [ 2300.908376] ? xa_load+0x7b/0xb0 [ 2300.909090] ? _raw_spin_unlock+0xe/0x30 [ 2300.909913] ? list_lru_add+0x11b/0x160 [ 2300.910736] ovl_copy_up_flags+0x81/0x110 [overlay] [ 2300.911740] ovl_create_object+0x51/0x130 [overlay] [ 2300.912719] vfs_mkdir+0x194/0x250 [ 2300.913470] do_mkdirat+0x14c/0x180 [ 2300.914223] __x64_sys_mkdir+0x46/0x70 [ 2300.915019] do_syscall_64+0x7d/0x160 [ 2300.915798] ? do_sys_openat2+0x9c/0xe0 [ 2300.916672] ? syscall_exit_work+0xf3/0x120 [ 2300.917540] ? syscall_exit_to_user_mode+0x32/0x190 [ 2300.918518] ? do_syscall_64+0x89/0x160 [ 2300.919316] ? syscall_exit_work+0xf3/0x120 [ 2300.920181] ? syscall_exit_to_user_mode+0x32/0x190 [ 2300.921173] ? do_syscall_64+0x89/0x160 [ 2300.921991] ? exc_page_fault+0x7f/0x150 [ 2300.922814] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 2300.923823] RIP: 0033:0x7f5a2f8de3eb The root cause is VE namespace mismatch. Overlayfs was created inside CT, so ovl_fill_super stored in-container credentials to ofs->creator_cred. Those creds are later used in ovl_override_creds to temporarily swich creds and perform checks using them. One of these checks happened in ovl_get_origin_fh/ovl_can_decode_fh. On fs creation this check passed because we had container VE and container creds, so overlayfs thought that we support file handles (ovl_can_decode_fh call in ovl_make_workdir). When we tried to do something with the overlayfs from host VE, ve_capable check was performed with credentials from CT and with host VE. ovl_get_origin_fh returned unexpected NULL and all exploded. Store creator VE next to creator creds, so we can perform all ve_capable checks with the correct VE. https://virtuozzo.atlassian.net/browse/VSTOR-142405 Signed-off-by: Vladimir Riabchun --- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/namei.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/params.c | 3 +++ fs/overlayfs/super.c | 7 +++++-- fs/overlayfs/util.c | 4 ++-- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 4388004a319d..b7c06ae4beb4 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -478,7 +478,7 @@ struct ovl_fh *ovl_get_origin_fh(struct ovl_fs *ofs, struct dentry *origin) * so we can use the overlay.origin xattr to distignuish between a copy * up and a pure upper inode. */ - if (!ovl_can_decode_fh(origin->d_sb)) + if (!ovl_can_decode_fh(origin->d_sb, ofs)) return NULL; return ovl_encode_real_fh(ofs, d_inode(origin), false); diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index efa2a072aa69..e33debf8b1ed 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c @@ -166,7 +166,7 @@ struct dentry *ovl_decode_real_fh(struct ovl_fs *ofs, struct ovl_fh *fh, struct dentry *real; int bytes; - if (!ve_capable(CAP_DAC_READ_SEARCH)) + if (!__ve_capable(ofs->creator_ve, CAP_DAC_READ_SEARCH)) return NULL; /* diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index 8577c7884fb9..9c8dd2f9cac6 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h @@ -427,7 +427,7 @@ static inline const struct cred *ovl_creds(struct super_block *sb) return OVL_FS(sb)->creator_cred; } -int ovl_can_decode_fh(struct super_block *sb); +int ovl_can_decode_fh(struct super_block *sb, struct ovl_fs *ofs); struct dentry *ovl_indexdir(struct super_block *sb); bool ovl_index_all(struct super_block *sb); bool ovl_verify_lower(struct super_block *sb); diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index ab78001635e7..a6ad8b8de48c 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -77,6 +77,7 @@ struct ovl_fs { struct ovl_config config; /* creds of process who forced instantiation of super block */ const struct cred *creator_cred; + struct ve_struct *creator_ve; bool tmpfile; bool noxattr; bool nofh; diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c index 32c58fcfe52f..c047f1265b8e 100644 --- a/fs/overlayfs/params.c +++ b/fs/overlayfs/params.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "overlayfs.h" #include "params.h" @@ -761,6 +762,8 @@ void ovl_free_fs(struct ovl_fs *ofs) kfree(ofs->config.workdir); if (ofs->creator_cred) put_cred(ofs->creator_cred); + if (ofs->creator_ve) + put_ve(ofs->creator_ve); kfree(ofs); } diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index fb47711c8fb9..e87b6684ec70 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "overlayfs.h" #include "params.h" @@ -393,7 +394,7 @@ static int ovl_lower_dir(const char *name, struct path *path, * The inodes index feature and NFS export need to encode and decode * file handles, so they require that all layers support them. */ - fh_type = ovl_can_decode_fh(path->dentry->d_sb); + fh_type = ovl_can_decode_fh(path->dentry->d_sb, ofs); if ((ofs->config.nfs_export || (ofs->config.index && ofs->config.upperdir)) && !fh_type) { ofs->config.index = false; @@ -757,7 +758,7 @@ static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, } /* Check if upper/work fs supports file handles */ - fh_type = ovl_can_decode_fh(ofs->workdir->d_sb); + fh_type = ovl_can_decode_fh(ofs->workdir->d_sb, ofs); if (ofs->config.index && !fh_type) { ofs->config.index = false; pr_warn("upper fs does not support file handles, falling back to index=off.\n"); @@ -1328,6 +1329,8 @@ int ovl_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_d_op = &ovl_dentry_operations; + ofs->creator_ve = get_ve(get_exec_env()); + err = -ENOMEM; ofs->creator_cred = cred = prepare_creds(); if (!cred) diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c index f95090f0d29c..047b618ad296 100644 --- a/fs/overlayfs/util.c +++ b/fs/overlayfs/util.c @@ -78,9 +78,9 @@ const struct cred *ovl_override_creds(struct super_block *sb) * Return 1 (FILEID_INO32_GEN) if fs uses the default 32bit inode encoding. * Return -1 if fs uses a non default encoding with unknown inode size. */ -int ovl_can_decode_fh(struct super_block *sb) +int ovl_can_decode_fh(struct super_block *sb, struct ovl_fs *ofs) { - if (!ve_capable(CAP_DAC_READ_SEARCH)) + if (!__ve_capable(ofs->creator_ve, CAP_DAC_READ_SEARCH)) return 0; if (!exportfs_can_decode_fh(sb->s_export_op)) -- 2.47.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel