From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 321B2C83F09 for ; Wed, 9 Jul 2025 21:27:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA5E86B0167; Wed, 9 Jul 2025 17:27:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C56556B0168; Wed, 9 Jul 2025 17:27:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B45446B0169; Wed, 9 Jul 2025 17:27:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9AF7B6B0167 for ; Wed, 9 Jul 2025 17:27:21 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 3DB6B803D6 for ; Wed, 9 Jul 2025 21:27:21 +0000 (UTC) X-FDA: 83646012282.23.56D45CF Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id 807E910000A for ; Wed, 9 Jul 2025 21:27:19 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ldzQw00U; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of pratyush@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=pratyush@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752096439; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WMtBVTCemOneqciN9zrT+ZSHybx/fIiJLnMZhoiYqEE=; b=y//CRV+Dg5U4/vyfLN+T9Va9i2Ev0v/VA5TH40nGivk/2SuHlbUBJz4nTajlZZ9O2gAB1g hvFVTZZ1fvdM8gGynnNnStN1kTFadtw3BYBaFB4UesHML9hVz3dRYYjillwffDUEsHd0sY 8WJWtn3/Asv81SLL4VtLnb5FjFs7aE0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752096439; a=rsa-sha256; cv=none; b=hr1tSQJXbAOu9XjsX+DqsJ9MzX4mE6pf98Fds5h2A3TC2VY8Zc1pW3G7wKKVcqxFuSX1ng 7ypHsm8WpdqwAG4GJYBPb44jeC92q94GhCdy/ylZZaVFfBxDxlyBpXmLZOUbuFF2fct+r0 8pwH7fXPi2a8pBM0TP+JDx1yVFh5k8E= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ldzQw00U; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of pratyush@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=pratyush@kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 273065C01E6; Wed, 9 Jul 2025 21:27:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F162EC4CEF4; Wed, 9 Jul 2025 21:27:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752096437; bh=di0qI7GEmczq14zBNaBk8AWjgNHZtoR0rPpsB6FrrvM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=ldzQw00U+OetIKA481nc0vtmKNZA1RskLqjb7X1NOEN1OeisHWun1QCwnCjI5ottS vx4NKF7Pf8e0EPpxQC9AFg2qPBCYZ3d6DbJ21t2lwKjYlgSAvwQRR1yt4EJkrndA1f trzz9UmGeEgappXz0em9JwDLdjx01xkdVQbI3rVE3SIia4ICLQG8cbVWFxlnpTAUKc WQFupUDU4w3ADhfQa1mGwDVdFb//Oc88+StcqBA4tOTf5V4klAd2DKIQiX+U54taBE cwWDg3qNLgwXVZYFjvCKSq8cfutNsrmXNizt1CYW6H3QEfQT+dYgCuQqr6GqUb4mQt RtrsejD0cEWWg== From: Pratyush Yadav To: Mike Rapoport Cc: Christian Brauner , Pasha Tatashin , pratyush@kernel.org, jasonmiu@google.com, graf@amazon.com, changyuanl@google.com, dmatlack@google.com, rientjes@google.com, corbet@lwn.net, rdunlap@infradead.org, ilpo.jarvinen@linux.intel.com, kanie@linux.alibaba.com, ojeda@kernel.org, aliceryhl@google.com, masahiroy@kernel.org, akpm@linux-foundation.org, tj@kernel.org, yoann.congal@smile.fr, mmaurer@google.com, roman.gushchin@linux.dev, chenridong@huawei.com, axboe@kernel.dk, mark.rutland@arm.com, jannh@google.com, vincent.guittot@linaro.org, hannes@cmpxchg.org, dan.j.williams@intel.com, david@redhat.com, joel.granados@kernel.org, rostedt@goodmis.org, anna.schumaker@oracle.com, song@kernel.org, zhangguopeng@kylinos.cn, linux@weissschuh.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, gregkh@linuxfoundation.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, rafael@kernel.org, dakr@kernel.org, bartosz.golaszewski@linaro.org, cw00.choi@samsung.com, myungjoo.ham@samsung.com, yesanishhere@gmail.com, Jonathan.Cameron@huawei.com, quic_zijuhu@quicinc.com, aleksander.lobakin@intel.com, ira.weiny@intel.com, andriy.shevchenko@linux.intel.com, leon@kernel.org, lukas@wunner.de, bhelgaas@google.com, wagi@kernel.org, djeffery@redhat.com, stuart.w.hayes@gmail.com Subject: Re: [RFC v2 10/16] luo: luo_ioctl: add ioctl interface In-Reply-To: References: <20250515182322.117840-1-pasha.tatashin@soleen.com> <20250515182322.117840-11-pasha.tatashin@soleen.com> <20250624-akzeptabel-angreifbar-9095f4717ca4@brauner> Date: Wed, 09 Jul 2025 23:27:08 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Rspam-User: X-Rspamd-Queue-Id: 807E910000A X-Rspamd-Server: rspam03 X-Stat-Signature: bcr6fgcso19sitsudr6hgrkzfeahzeqx X-HE-Tag: 1752096439-783240 X-HE-Meta: U2FsdGVkX1943MuuFFSAUnFZx4bM+FNRkQn6e6LWkXZQpWlg+qOPLm6zJBEwf70sHWOytiP+LS4cO3nv5ko9MWbYbjy803DRCm2CR7R9iO8uTYAXqsLhGGkD5ojD2X4xsqno0aSY1CyhNhLiu/hCkP30EBqUCW/QyZBuIAP2kp3vzd3gLp+cridcEEPS7KmiKu/I5WGkGwL0pDETAURUmZ7EXkUba0s3Akw9CSoNjAw9eblA0wfE/vqKIjxTcy0PFguszmSm/cx6NEKFdSV82fc8fNtEQjsgJd1SsxXaMm1NSSvF0pxk1qGu7Cd24pZ6sLymbgxxR5eNgy39dfTo3G2SQ83qV6qf/mY/c9AW2yd7oeB6SF93AxhKrr3fUIfujdi/Seu0Q5W8E3ooMbX1hFYa6uRgKeH9WiTHRa55azJeE/fM5Wu/9x26PSUxy7dsueECu0ZwfhgcPKsVg7PzDzuy5smpYHRrd3lEoLhTy4IhOcDAq9egNtdGfLSUKYyxPCO9TwJMrLlCy5Zoc8pdykNb9vEPgkdnZMy8FcaI6oNkouSVHT4Rc7rTZ4Rd5ns0JuNhYXVzyDx6MXqJgnT9ccZ3mDrVQZmr35A/jP2Z5yC+A0fbdRqC6J5jY290LruXMIu93SU7BsrkOhRGWxDhKX4P2KSPryUpCb7YCch7Z+pfLf6ovAoeADft3FKt6uJfJL0MRv44hmYuSh7lXYLzjGtgJcaQy42alAHF9tyFmC1n5mY+wx+GWQ2McLaiElmW1+zO+xOSVorAncpygGKkepkSfhsnlxVpnyrOlSbgMkZg21Z+vSTQnsUTaJkn1i0MUWRDqba7yW0W8+YYechxAa+Mrx5WYzQPlK82t8Of6Z2fIdi1WHgbfGAAk4eBbfRkMtAqnprcLkEIseGUl3Md3Bo/y65ECuPrRhIlXqHyZZCKJV9Gk5i2a4n62Guyx67vRV7QF2mX4SJYsRo7T94 VlyWR6zz iPvp3zF6K6Fc6rAabdtJ/A+hSMmNOk1X0GaAO7sKSwhJ/q4/02Rf/Q4pYHm7OzG5Wle5YWPg+JRSGmhe4IQMF+hszkW5RpVtmGs4tSq71pbWO2Z8C/CiIWt/AEN0DP1jKycITrxefvz3A1hOOUI2B0hf/H5gRvLQ/RL47HLknovG2zO0ZEyu83oS/Qth5olz8zNNZKYKpUhq2VT4p5kyWVGXFvRDNrKXAz/kN5b7IKnjsqZ75Rx4ONTPC2A8JIYEzOvgRqY4lWgq3Kf90yWvrZKmjW3EbV2KUR+C8dp1R8aZAfKt5E7E1n9XnT2fxswpTCYQC6gsAnaBeqnO/c/zg6HY7+hISerOj1c/BjnJzBNVZC8CW6aEjq1VzcdN/ga2cJdtV X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Sun, Jul 06 2025, Mike Rapoport wrote: > On Tue, Jun 24, 2025 at 11:50:49AM +0200, Christian Brauner wrote: >> On Thu, May 15, 2025 at 06:23:14PM +0000, Pasha Tatashin wrote: >> > Introduce the user-space interface for the Live Update Orchestrator >> > via ioctl commands, enabling external control over the live update >> > process and management of preserved resources. >> > >> > Create a misc character device at /dev/liveupdate. Access >> > to this device requires the CAP_SYS_ADMIN capability. >> > >> > A new UAPI header, , defines the necessary >> > structures. The magic number is registered in >> > Documentation/userspace-api/ioctl/ioctl-number.rst. >> > >> > Signed-off-by: Pasha Tatashin >> > --- >> > .../userspace-api/ioctl/ioctl-number.rst | 1 + >> > drivers/misc/liveupdate/Makefile | 1 + >> > drivers/misc/liveupdate/luo_ioctl.c | 199 ++++++++++++ >> > include/linux/liveupdate.h | 34 +- >> > include/uapi/linux/liveupdate.h | 300 ++++++++++++++++++ >> > 5 files changed, 502 insertions(+), 33 deletions(-) >> > create mode 100644 drivers/misc/liveupdate/luo_ioctl.c >> > create mode 100644 include/uapi/linux/liveupdate.h > > ... > >> > +static const struct file_operations fops = { >> > + .owner = THIS_MODULE, >> > + .open = luo_open, >> > + .unlocked_ioctl = luo_ioctl, >> > +}; >> > + >> > +static struct miscdevice liveupdate_miscdev = { >> > + .minor = MISC_DYNAMIC_MINOR, >> > + .name = "liveupdate", >> > + .fops = &fops, >> > +}; >> >> I'm not sure why people are so in love with character device based apis. >> It's terrible. It glues everything to devtmpfs which isn't namespacable >> in any way. It's terrible to delegate and extremely restrictive in terms >> of extensiblity if you need additional device entries (aka the loop >> driver folly). >> >> One stupid question: I probably have asked this before and just swapped >> out that I a) asked this already and b) received an explanation. But why >> isn't this a singleton simple in-memory filesystem with a flat >> hierarchy? >> >> mount -t kexecfs kexecfs /kexecfs >> >> So userspace mounts kexecfs (or the kernel does it automagically) and >> then to add fds into that thing you do the following: >> >> linkat(fd_my_anon_inode_memfd, "", -EBADF, "kexecfs/my_serialized_memfd", AT_EMPTY_PATH) > > Having an ability to link a file descriptor to kexecfs would have been > nice. We could even create a dependency hierarchy there, e.g. > > mkdir -p kexecfs/vm1/kvm/{iommu,memfd} > > linkat(kvmfd, "", -EBADF, "kexecfs/vm1/kvm/kvmfd", AT_EMPTY_PATH) > linkat(iommufd, "", -EBADF, "kexecfs/vm1/kvm/iommu/iommufd", AT_EMPTY_PATH) > linkat(memfd, "", -EBADF, "kexecfs/vm1/kvm/memfd/memfd", AT_EMPTY_PATH) > > But unfortunately this won't work because VFS checks that new and old paths > are on the same mount. And even if cross-mount links were allowed, VFS does > not pass the file objects to link* APIs, so preserving a file backed by > anon_inode is another issue. Yep, I was poking around the VFS code last week and saw the same problem. > >> which will serialize the fd_my_anon_inode_memfd. You can also do this >> with ioctls on the kexecfs filesystem of course. > > ioctls seem to be the only option, but I agree they don't have to be bound > to a miscdev. I suppose you can have a special file, say "preserve_fd", where you can write() the FD number. This is in some ways similar to how you would write it to the ioctl() via the arg buffer/struct. And I suppose you can have other special files to do the things that other ioctls would do. That is one way to do it, although I dunno if it classifies as a "proper" use of the VFS APIs... -- Regards, Pratyush Yadav