From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 471C98017D for ; Thu, 12 Nov 2026 16:07:12 +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 6ACG5qek010332; Thu, 12 Nov 2026 19:05:53 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ACG5qek010332 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="GjMDe5Qz" Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6ACG5osO010328 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 12 Nov 2026 19:05:50 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6ACG5osO010328 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-49953abe51fso32346875e9.1 for ; Thu, 12 Nov 2026 08:05:50 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGE7+nQJjpl0GWUw+RScmFZhIE+M6wB814UywKfRALD1jKyS/+CubaY8P1VMWGLq6hAVIIBjw==@openvz.org X-Gm-Message-State: APuU4Z+m8Kx0pdLL/sEOi40XNNBbjM2u/+hPlN5zVfzrUVsy96u4kLIK WQEZclpVVhL6qsbsiRH0Utb/oAZ7rDDwfM1qDgG0ecWvz3B0XuUz9SqZDxr0CM13kEUdfbU3P/m /YxQ18geuzG0+hztgcPmOqwR21TnRGYEjGvW5kp73FjKDDqFzO10NxA== X-Gm-Gg: AYBFou3FDEHSGxQPhmk3VktNeq5P4SHvyQ0xaCQReFSKKjwcqJtifVNVL4MmcKlsAoR PZPqCAJk0Bmw1TCUaV6QbaVQ8QP4kB+eDqqV4qegD5s8rO/lFNO5SKH5gCck3YCicPmJAuX+8y4 XDk7susxH8tgrPUtFYYmlul6i3S3Prmj6wPMvqANHmL7hBrT5kCBDbnpbPdgD53gnpzHZKsB1yG kpG3cuPtNNOrbHKjiupMd1LYvIWwljDGNwtc9tz51SACUb+w6Nm+C6aQwMIDqxze3og3t/wW1hJ RfeH+dM4P0EDCXzpC7Lqtkt/XTA/h/57pf7c3410uzZKSsjhfGuEJjrgK8iBhgElKN7/55ygVXy kBaRFQ+6Z0LjW2RLi X-Received: by 2002:a05:600c:34d0:b0:4a5:87b3:ddc1 with SMTP id 5b1f17b1804b1-4ba0938a143mr112574275e9.13.1794499549987; Thu, 12 Nov 2026 08:05:49 -0800 (PST) X-Received: by 2002:a05:600c:34d0:b0:4a5:87b3:ddc1 with SMTP id 5b1f17b1804b1-4ba0938a143mr112573785e9.13.1794499549448; Thu, 12 Nov 2026 08:05:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794499549; cv=none; d=google.com; s=arc-20260327; b=m9QEI+l5qU2mfx0x0zl+Q2bqeWSZR+Zw0dR18EPpFYuE6T+mXw09WpOTnjN89Y2yHq 3On4RVmRYi23CbiJwGPc7YyG6K8P2a3G0nF4IA7xs2feuwAzrFnzyEOzbFsId7jp88VM ePZ4R09jlKavKOOchsE6OZjiSBVuUUdDkGghkpp3Mlz7ceOlsGrbka1qo1h8S7zBE4b0 M/EWR4YW1EbLuahRqnkiZTaD3KyH0vZkALypjYmhf3FIaUpBQ2NJrMDLa2YUfw4a99+s wH8Piab5X+2WUrllgIYfT3KDiKa/wze8H2WUrvF+2gxInpa5LJlVDmZrvD7VFGcKnRwj S2cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:mime-version:dkim-signature; bh=R6C5G6YAPy7u3K1bPpd192bEu34kRg3JyUSEcQg41So=; fh=e1cf8n77z2da+N1ymO/d91hfoJ+J/34ch9kWx7ws6zY=; b=BQJBQAsx65bWExz7PEhJZdzArMval+uFVaDsc4RKhW5BKsnl9VTFGHbsegvFPrRfX+ WpKhqHhUc0Mgto+MyIHNSkaFozOXiWojzoWAGm+CX4pBpBMXLKYFq6DC0sUkapGuMZPV e4NzDSADAAaKC9KfPAnf7SRFbtUrRj5D+IIVr4acopx33UmA4Ooqj456X9lksN01Efdi dXgxGP48wThenSjl6jfQ0DY0IAJNc9o9T/7dOMPc52QHq43Xl4hZ9oISHLhkIH4ACshL dFLHna4oirxRMqhtIoxGC88Ip0wNSYU/sN5tnDq1CnuW+zPvvDe9PfLB9yvdnFBLHSeY xBsA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=GjMDe5Qz; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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-498378024a5si18532935f8f.386.2026.11.12.08.05.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2026 08:05:49 -0800 (PST) Received-SPF: pass (google.com: domain of khorenko@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=GjMDe5Qz; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@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:Date:From:Subject:Content-Type: MIME-Version; bh=R6C5G6YAPy7u3K1bPpd192bEu34kRg3JyUSEcQg41So=; b=GjMDe5QzJFQ/ a844aJd53eCsPlsn5mjvyxI6gtHaxOHUrR1AojXrd+4aiUW393LVKwJ4KlW+ex5xL2iAOpBigKlY6 xxWQvN0b/nJIq2u3kzZnTC3XrJcHAYPAWQpXGYCQRc93Bo9Iw9bihVGQLTfJfZkSUzc4dXUXl+R6d 6p9mXEL799yrjfVBL9/PCbHLnF4IMSmwFEuNu+uJWa5q1/6oDbDAeNSnkZa/ubDcQJlMhPAvelKwm vvpzCH81mdq64C24VUjVvyZQ+sQRsceO2340menw2XUrQcfVhR5gLnYv0xPAqvW+RLZeOia5Uu6Th iOhO1xSDrAyivjXfs81ddw==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xRXEx-002tS9-2i; Thu, 12 Nov 2026 17:05:46 +0100 MIME-Version: 1.0 From: Konstantin Khorenko To: Mirian Shilakadze In-Reply-To: <20261012102058.46896-1-mirian.shilakadze@virtuozzo.com> References: <20261012102058.46896-1-mirian.shilakadze@virtuozzo.com> Date: Thu, 12 Nov 2026 17:05:46 +0100 Message-Id: <179449954661.4060562.4766019607878285221.b4-review@b4> X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4998; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=/5oUwC51SgikK7aiW1hM/WHz3sIsWJq8+nj+3F5U554=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBq9ePcqZRKxiQuAFPHf9h3on5NPbM3JBTEcauAv ZTRGQEq8naJAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCavXj3AAKCRBRlgpH+WFc KhWQD/4pVASndJ/Kj1jVfS7JH9xw3o6kRkKcYD6n+WpKYx/VN6uYLXO8gONHFHPmtHj+5jcQvCs 4vR0GNgCSRNJmCoa47QfAuQ+lqoUcjOi4q3P76k6eSZY+rqdvv5BIjzNAgEPd8W0PNLizdMsBtG 7VShcqiYIueNKPsk7TCwZOChJbbiSqPrhLuLjCj0sm2Z4kH0EAbN5f0Ahqbw+HoaWMFpPFhk7lZ eAb0APmvvxRUjxwSouswtxeKV5BapFTHr3JE/sgg8CY6Qo8XeTCGUuhhVsZAilNSf7PKLLHU+1O AaJeuB4hid0+GZ1E5EwyQ3nZmqr/fIFSfy8MPO0JuTqsVxLcqCOB1+YWVbzBJFLGQw2+94VaNz7 17YqYTfOCw19nAyfI8bxWWTkzEpX7JdRFQ+vus2IB+4cZlkLoPPd5FAUH4viwZ3Cwt1DhVh/5NP ouAgVIoBZDnP7vZgnf25XwShBUPpkltCRlr1vtuyMAgaBb21qL2dqfMyqnI5MbNr9va4FTPlq1s JN1vgXRWI8t6+0BsQbVWdzKy4uRpxtpOc0JPQFGkADeQ2gAcogiVuVrlL9r6VWs6o9+6d9AB7kg 0PrqIP5xEUkB8usLVY3GoAhKqD+zDN7aZ6a5XNWX+uDTMGwQrSal3I7QJqIqn0ceGIEa9j4h6l2 RLjTbXtSptGTrRg== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: Re: [Devel] [PATCH vz10] fs: let the protection flags of a mount be locked from userspace 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 I won't apply this version, please send v2 with the changes below. On Mon, 12 Oct 2026 14:20:34 +0400, Mirian Shilakadze wrote: > Add MOUNT_ATTR_VE_LOCK to mount_setattr(). In attr_set it locks those > of the four protections the call leaves set, in attr_clr it drops the > locks. Only a host task with CAP_SYS_ADMIN in the initial user > namespace may use it. MNT_LOCKED is not raised, so the container can > still unmount the bind. - Drop the tools/perf copy of the define. - Make the lock readable, e.g. in statmount() mnt_attr or in mountinfo, so checkpoint/restore can keep it. If not in this patch, say in the message that C/R loses it. - Say in the message that unlocking also drops the locks lock_mnt_tree() raised. - Say in the message that a remount racing a lock can change the superblock and still fail with EPERM. Keep the code. - ve_may_lock_mount(): one definition outside the #ifdef, keep the ve0 test, and name the setns() case in its comment. - Fewer comment lines: move the rationale into the message. The kernel logic itself looks right to me: the re-tests close the remount race, the lock_mnt_tree() refactor is exact, and nothing changes while nobody uses the flag. > diff --git a/tools/perf/trace/beauty/include/uapi/linux/mount.h b/tools/perf/trace/beauty/include/uapi/linux/mount.h [...] > +#define MOUNT_ATTR_VE_LOCK 0x8000000000000000ULL Sashiko is right here. fsmount.sh turns this define into entry 64 of fsmount_attr_flags[], and on a 32-bit perf the flag printer then shifts 1UL by more than 31. fsmount() can never pass this flag, so the entry is dead anyway. Without the hunk check-headers.sh only warns. > @@ -5230,8 +5278,33 @@ static int build_mount_kattr(const struct mount_attr *attr, size_t usize, > if ((attr->attr_set | attr->attr_clr) & ~MOUNT_SETATTR_VALID_FLAGS) > return -EINVAL; > > + kattr->ve_lock = !!(attr->attr_set & MOUNT_ATTR_VE_LOCK); Sashiko and Pavel asked how the lock is read back, and it matters. Nothing reports MNT_LOCK_*, so CRIU restores a locked bind as an ordinary one. libvzctl relocks the configured binds after restore, but not the binds the container made of them. Those were locked before the dump, because clone_mnt() copies the bits. After restore the container can remount them rw again. > + if (attr->attr_clr & MOUNT_ATTR_VE_LOCK) > + kattr->attr_clr |= MNT_LOCK_PROTECTION_MASK; These are the same bits lock_mnt_tree() raises when a tree crosses a user namespace. Until now nothing could clear them, now host root can, on any mount it reaches. That is fine, but the message and the UAPI comment have to say it. > + if (can_change_locked_flags(mnt, mnt_flags)) > + set_mount_attributes(mnt, mnt_flags); > + else > + err = -EPERM; This is Sashiko's first point, and it is real: mount_setattr() takes neither s_umount nor the namespace lock, so a lock can land between the first test and this one, after reconfigure_super() is done. Testing earlier does not close the window. Only the owner of the superblock gets here and the mount stays locked, so keep the code and say it in the message. > +static inline bool ve_may_lock_mount(void) > +{ > + return ve_is_super(get_exec_env()) && capable(CAP_SYS_ADMIN); > +} [...] > +static inline bool ve_may_lock_mount(void) { return capable(CAP_SYS_ADMIN); } ve_is_super() and get_exec_env() have CONFIG_VE=n stubs, so the first definition works for both configs. The ve0 test is not excess, as Pavel thought: host root can setns() into a container's ve namespace and keep its init_user_ns credentials, and capable() is then true. That is the case the comment should name. > +/* > + * Raise the MNT_LOCK_* twin of every protection @flags carries, so that whoever > + * is given the mount cannot clear them again. Shared by lock_mnt_tree(), where > + * the kernel locks a tree that crosses a user namespace, and by > + * MOUNT_ATTR_VE_LOCK, where the host asks for it. > + * > + * Neither MNT_LOCKED nor MNT_LOCK_ATIME is raised here. lock_mnt_tree() adds > + * both itself, while a mount locked through MOUNT_ATTR_VE_LOCK can still be > + * unmounted and keeps its atime settable. > + */ The patch adds far more comment lines than the code around it has. The rationale here, in ve_may_lock_mount() and in the two blocks in build_mount_kattr() belongs in the commit message. The second paragraph is also inexact: lock_mnt_tree() adds MNT_LOCKED only to mounts that are not on an expiry list. Separate patches, not needed for this series. I created a task for it: 1. Pavel's idea to let the host raise MNT_LOCKED on the binds vzctl makes, so the container can neither unmount nor move them. A moved bind loses its --ext-mount-map key and CRIU fails the dump. Pavel has the task: https://virtuozzo.atlassian.net/browse/VSTOR-154914 -- Konstantin Khorenko, Virtuozzo Linux Kernel Team _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel