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 17680C83F09 for ; Thu, 10 Jul 2025 07:27:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91D0F6B00A0; Thu, 10 Jul 2025 03:27:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F4916B00A3; Thu, 10 Jul 2025 03:27:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 837006B00A6; Thu, 10 Jul 2025 03:27:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 749946B00A0 for ; Thu, 10 Jul 2025 03:27:11 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 326E01A04AC for ; Thu, 10 Jul 2025 07:27:10 +0000 (UTC) X-FDA: 83647523820.17.C93A732 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf25.hostedemail.com (Postfix) with ESMTP id 96BA7A0006 for ; Thu, 10 Jul 2025 07:27:08 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sv22hU7e; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1752132428; 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=yLPZ9ap6BjdmVvtFFLfN3BN/W06x+DXM5TY6sF4KpRM=; b=QJzZfjDKRykCOAGodhXCZj6RrFa0GEfIVwaKZiBaXixObm4kf+1kZg/OrKqResK9r8y9hJ /71MiMpTlALujQBCWUQCi5OCXyNYgGI6ylw4qRedJQvvhlpy7MFoTZBPGpeU6DUUpH2A3r X/5/DvFruL8QCJho83/GpWWsJcLlAeU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sv22hU7e; spf=pass (imf25.hostedemail.com: domain of rppt@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1752132428; a=rsa-sha256; cv=none; b=f+21WSGzsYVmJRsomB6gE2X0rfLABur2z3s4z9ipsbget3i82DSV6j+fEma+NKm/siml6R kWblgTu9eX5WY8myH/5+qdQOrXEDyy4F8MmbYAo5bwYvlxU7PO67VMmEntaP+f7O3DN4k2 X1PGSre49SO1egrmSVVWb1unFK2eG0w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id BA47E6145E; Thu, 10 Jul 2025 07:27:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2A35C4CEE3; Thu, 10 Jul 2025 07:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1752132427; bh=q8eQa8h3G+1BUbeKwUG/+c6FzsMMOTsEwlY/U/VRJq4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sv22hU7eDntyWDea+W8G3nJxqHVDscPWMcXGvQKTcjjDvycY9Iaf68KLjGlBWxIGQ U6ijuHlmSsfE6qNOLSBDpOojSUWJwJR81oMSU2OfqhKEQalv2rvOI7klGpoL48gs37 owl8tKt1gY5jqUaFfYfMiFpNcSeAeNgTixi18OeLlfRCHGU2hmoixdpCjtPKve6VAZ 9XikS4R7HWWG236SnW9XShLGB1tP1667qhMKBlwiKBubK4DkgHVAfZBc3iDeOwmeJ+ AMUUNt4tENX6pAtuXdWSD2E91l74cj/o7pg97QLRsHZLBICdBqNj3XIPOP+r6KT/pJ ND44JKhgqtDsQ== Date: Thu, 10 Jul 2025 10:26:45 +0300 From: Mike Rapoport To: Pratyush Yadav Cc: Christian Brauner , Pasha Tatashin , 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 Message-ID: References: <20250515182322.117840-1-pasha.tatashin@soleen.com> <20250515182322.117840-11-pasha.tatashin@soleen.com> <20250624-akzeptabel-angreifbar-9095f4717ca4@brauner> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Stat-Signature: d79be5mm1ea1rhhpz69bm9atkyrzxngf X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 96BA7A0006 X-HE-Tag: 1752132428-249350 X-HE-Meta: U2FsdGVkX18geqd6cpsDRzxwglQIU1v0ov0HfXh2326jCZZOYOM7WJHCJt2hksmwTiMIwb+2dwp4iqmibjB3IjYNqjkVOTW3KU9aTUM6km/mBiSqCq7bZHOC0hiT78RIGKqCOjfIV7yiQTslIWviUVY+wyW0ypRciwm8mLbXUcKh5JA6f1Tmgns/3bnvy8kCWJdsYqD6r3M3WWsTqH3NAW2R50S5Yh44mqOUN64R79RXfSQpuuyMxb46u+mNKbe4BfiCdIK8uGC5HX2U6m6CFoZiqZJA+501X2Wk2lRR43xuiIcXG1zVShkbqXkzoSbL1oK/BU4aTio+BIEeMFjD5iDpcpHyEnCHYUDsIQi0puiFeQsbdNWz5GRF7TmW8K2koB5FUxfzBRBY5P/YfXikglEjr86iFG2FslZHVCfMxVClDBfMPjMhvUlEJ4mb6x4PGqUKwrBhwBWDHFygg7ud9qjwBaelQkfXqGuBkDRttmhhLhhbU84RL63HuG3yE8eMdgdAcacyFKO72j3JSYFbGDieEYrjXxPiQDMPQmzyjpS/odeGnj42OE36XkjPRQY/xl6KYey1fJHamjBIDMybUcp9hrvTiEHLrbevlRfaJLowo4vUecHSDR8A7m2HnGL0tOfeDMv6EVJTtqTpqjLA+RIy74oOLeJSYar7Juy9mSgHWKTREgbgnBX54ziaJnW2s/9Qi1rSUDhOcaWGJD79a4vTPl4WU42kmMDs6QK6yujZcRGgzpCMaD9Ta5S2hEUz5WByOJzvaOqjloqEmzc+sZSWpPKbBauy/ycIBi+k72hRzEiZwm8JVMco+7GvOmuHMrsTzriE83CxFndLaeITiafvdsbF1/ev5juSKzEnAGE7sTnR0Fqrv+2md3sauAZnoF6J3c5nKvlBCy5jKRNuIZnRKG2AfrN1hGEioS5p1RmyP+pUgZxR8aSxEGvUOkHuzjhZK4zvhz2uuiI1pBv EQotJCIo yrTVGuUavKdPCAegItCOOv3eGn9Zu5LgjdeFcWztocKleNZNe7lpM/9wsb1brLLPMpvEk4S/8XNV5pHR2566cRe1Q/xAvIw9GS56/847x2fBwls4foujxnZlo3C7cPXTI4TaiScf4zCkA5KlNxkIKDou+5n+r+yf1W3xZNqzIqcFqTrWc6HxhnJRbJTkN6FRZEqTqM88A/2GiIU0MBmUkMP8/XL0yoIpYPY+XCXKUiqqa6PNJYruF/avT1Efl5HXDJh9jwKPSsfvWQbm/2u9CROv2OvyPndk7WrLp/s7utWdgokNWeWU+1nBMt5Jzp1cjRHDCsLigRVp6WxFNfSwy+OJKqGqnJhRa0pROX6vjL1w4QivnlLvI6OFbZ0WUQ5Mi5prJjQM/vq9wYIcPDtwGS6986eFcUAoTxos4pj3m+fjwLDo= 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 Wed, Jul 09, 2025 at 11:27:08PM +0200, Pratyush Yadav wrote: > 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... IIUC Christian's point was mostly not about using VFS APIs (i.e. read/write) but about using a special pseudo fs rather than devtmpfs to drive ioctls. So instead of fd = open("/dev/liveupdate", ...); ioctl(fd, ...); we'd use fd = open("/sys/fs/kexec/control", ...); ioctl(fd, ...); > -- > Regards, > Pratyush Yadav -- Sincerely yours, Mike.