From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2EAA36A35E for ; Fri, 17 Jul 2026 18:07:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.216.54 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784311677; cv=pass; b=GAEnty3K96KB3pCAX5lgGr7m2kMG2K7h2BUPLDZL0dbU6H0l+tAWLKmi+v7kbhfEdFTHs9mzSVbLsaImBMkBqazRDjgkBF8VYtX8TkC/Lhz7Tl4yECANuVgkSKbjaIxNHV3TXIbJXmvnKDz6XVGd79jjrtftylTiojmQhI3enhw= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784311677; c=relaxed/simple; bh=XNN0JpTZt4JS4XA+k0s5ZjKLsam3WypcC0ebaleTyjU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MxykxEgCrIwLqlB4aReEBIw4zQemh/B1cwXIQlIUzrP4rQhm4hGJGjKeIygEnaX1ZNtnEa3Xi1J71OUoX/QJOAKpj8Tlt4RcWUil3Tg8GMl3cwKLwimF4qHFj5o4d5O9xEey9iESVRbS+cBfB0sx1FXGNwL3XUxjhF7utL9B2/Q= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=G/S+npVt; arc=pass smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="G/S+npVt" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-383cb94f742so7649678a91.3 for ; Fri, 17 Jul 2026 11:07:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1784311675; cv=none; d=google.com; s=arc-20260327; b=iPJa9DkzM5v5CCUd7hWKz47H74F+0CnllWeDThavJKRCstNmczt0gW9I/0Nyg46J/L MjwV/3yJGL5/wkhJX69GKxGgPMtowXB7mmAGgROJregmH7JOFEkcUSPF48cP/3FTrfKt oXKTSB/5+LHKQjevX/zmZlrY3FV+e+rDHpvYWvThhhfUnmjoOjERZ4YoWbYY3P6sK/tn zOYaftDtIF519jVzPv4TO9Ke2GthEqSeuASa1lRstj1p3RgTzvYxrU6mxWR4rqwdaIPj miOi3JSJFca+Ht7czz7vPJEzrMJkQhG89xCF8SoI2gyTcV7CBMIbnp/8uL2MEaYceiwe D8AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oHggWXBEHwEkm7E6ec3wMUq0bi8f7fhVcVQVAKiXHao=; fh=9L/Qteog4K3/FqFtLjQCZmvwfFNBC+RK5RbOTCeTz2I=; b=fWMaaw4138fp7YZJPGi9y3Gm9EnHhE8pduWaUw9wMtJwV5flUpLtiQEdMaDHE6tcXs NJn47ipbrasSknf0dOuOIluCzkSGXcPuFgbS0YWE973198mG249PP+EntVebZNlj/2zZ WEQ+8yrlX2us5T857plSBEuFShWEEgNLHDGQviQjROCq78jJraLJSg6oPhU0WufoNaBY pmmDUzvzQAeiDIa/GphUJXYJmAP8k/9B3dZeYyE0j8wRyBHxfwPCoZhTbThjDaorp8iI kT0/9cd/URJ2q+AiTw3HA2GV2wFPMb9AT4apWtwvgYyg8EA9hoyxMORrbrt7s6hAOg22 4hhQ==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784311675; x=1784916475; darn=vger.kernel.org; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to:content-type; bh=oHggWXBEHwEkm7E6ec3wMUq0bi8f7fhVcVQVAKiXHao=; b=G/S+npVtkG1DqE3Qrv12SDfeqj2k048H+KVSZa3Mrej9tPxqjEe3bmQgP3uOYiJHJo qNy2hCDAi4Qye5q/rUZQgwgLi2ALqB/U2AB/CEiwPZq1Dymslx2c9D9b8UHE5ZqwRj3o JpNRXbMCsSfU/b54jcdGitA0NXWo1tNexaxpKV2NCZnT26oUDYywj338uoeIJjDcYwTd 63XHz+i4lLbJpUwDYtCGFvBaK3L5vsOWjpIxOfKXtx+dgl/fkBVniG54mU6vWnEDViIK U4DPWqduuvzi+b8bRT7Tpu1M/vkqFxlfBNc7nCl7mLSOWTdRvZYWn4klXwoUuMkMrKZl SXiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784311675; x=1784916475; h=content-transfer-encoding:content-type:cc:to:subject:message-id :date:from:in-reply-to:references:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oHggWXBEHwEkm7E6ec3wMUq0bi8f7fhVcVQVAKiXHao=; b=NuUdhcnMXnyZULpPcOTCT1NlfM5MNnu1aF6QySvEqCsY4ToXk/F/Yd0mJGV0eNREUN u20wkNZjK7ZGFLXOme/7a62EHDX4G0YwIRC6dWbxgkjjAywP6lGDXcGveC8Jt0spZRC7 Ve/LbH7Jr4pS9B/RBKbC+S2+JhOf9d7Tfn9Q6xP3Bqhn3YLNyF5QKUIw9Rv0X4nuBgnp zP9Byj52q/uZ8VZh4uzMEb/yEvm3999m9sKNth7Hy16YwGQIst93vuG/TkWCbCxGC3wF PtL2d8bLwNnFkm6+34vOUsJyGopyt/DQ49C67GT/LD8N+iz3g/T8+QHuVDVWcSviQttP E0Ew== X-Forwarded-Encrypted: i=1; AHgh+RqabisTMqwy/1UBifBLAckaIpCQZckulOZO1iKRNovMkaCAbrgEZPhf2mC8sYG33EH8kbSnTclP6am6A/k=@vger.kernel.org X-Gm-Message-State: AOJu0Yx604o/cvMz/+0FHF5NjiVaUuQyW1UpJIb515s1OtZwZOH3FVMb na8QlGtsgSJN1mfQRHUKGKRledx/M6LEiXJpSZS5JN4w2XW8Ahb8BV4sxuBYNE6PS1F+J9BWv9I xDcnyhUNLm+CLwX8ld9oczcXVPxwL+8O/3YgHZ8YL X-Gm-Gg: AfdE7ckvoq9SS58MK2l++opf02nmt57Ld69iPKuyr2QM5weWliWZbl/to613GvuP1A5 OLBTiN7JIRWGyTgCfffbX4P24brgKeh2+PKhiRUbPfJLo7gv0/pTnXZrDNutCBvLfArR4w+6tKm XsBdjmlyiz2QUKrXW2LGwn8323bx4ahL+HaG5aXxZHaA9WAP8vFkPaZGth6iGmsqLIYZxSCYWAA Myxa3xDYyBofMi14oUtTYteMP3TQBIcT/9IECVhLqnenSLZ/yoJslDFO0jNRQ== X-Received: by 2002:a17:90b:1e44:b0:38e:584f:2515 with SMTP id 98e67ed59e1d1-38e584f25c6mr761804a91.37.1784311674411; Fri, 17 Jul 2026 11:07:54 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260714190356.190328-1-dmatlack@google.com> <2vxzy0fcicpi.fsf@kernel.org> <20260715172336.GC3775915@nvidia.com> <2vxzh5lzhrgk.fsf@kernel.org> In-Reply-To: From: David Matlack Date: Fri, 17 Jul 2026 11:07:27 -0700 X-Gm-Features: AUfX_mzfx9OYJHTdyoObAAgLGZ66H2glYXt1USO9ylzsx0cIDR5QQ0HWu7nHJrA Message-ID: Subject: Re: [RFC PATCH] liveupdate: Allow multiple openers for /dev/liveupdate To: Pasha Tatashin Cc: Pratyush Yadav , Jason Gunthorpe , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Mike Rapoport , Samiullah Khawaja , Shuah Khan , uca.boccassi@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jul 17, 2026 at 10:07=E2=80=AFAM Pasha Tatashin wrote: > > On 07-16 17:41, Pratyush Yadav wrote: > > On Thu, Jul 16 2026, Pasha Tatashin wrote: > > > > > On 07-15 14:23, Jason Gunthorpe wrote: > > >> On Wed, Jul 15, 2026 at 03:50:33PM +0200, Pratyush Yadav wrote: > > >> > Hi David, > > >> > > > >> > On Tue, Jul 14 2026, David Matlack wrote: > > >> > > > >> > > Remove the single-opener restriction for /dev/liveupdate by remo= ving the > > >> > > atomic in_use tracking and the exclusive open check in luo_open(= ) that > > >> > > returned -EBUSY. Protect luo_session_deserialize() with a mutex = guard so > > >> > > that concurrent open attempts by multiple processes safely execu= tes > > >> > > deserialization only once. Update liveupdate selftest to verify = that > > >> > > multiple concurrent openers succeed. > > >> > > > > >> > > LUO does not inherently require a single opener. There is some > > >> > > documentation about it simplifying state management, but the onl= y thing > > >> > > it actually protects is the session deserialization during first= open, > > >> > > which can be easily handled with a mutex. > > >> > > > > >> > > Relaxing the single-opener requirement avoids the kernel forcing= a > > >> > > design pattern on userspace that it itself does not require, e.g= . > > >> > > allowing multiple userspace processes to create and manage sessi= ons. > > >> > > > >> > Agreed. When the kernel had a global state machine in the early ve= rsions > > >> > of LUO, this might have been more relevant. With sessions, even if= we > > >> > later add a state machine, it likely will be per-session instead o= f > > >> > being global. So I think letting userspace open /dev/liveupdate mu= ltiple > > >> > times makes a lot of sense. > > >> > > > >> > Also, today's systemd only supports preserving individual files, a= nd > > >> > does not hand out sessions. To get sessions, userspace must open > > > > > > It should in the future, because of permissions issue, see below. > > > > > >> > /dev/liveupdate and create a session. This opens up room for one b= ad > > >> > process to block every other process from creating sessions. It al= so > > >> > imposes a need for userspace to add a polling/retry logic for gett= ing > > >> > sessions and serializes their execution around this point. > > >> > > >> Shouldn't systemd open and own /dev/liveupdate? That was at least wh= at > > >> I originally expected here, you'd talk to it and get a session FD > > >> through dbus. > > >> > > >> Moving to multi-opening /dev/liveupdate and removing visibility of > > >> what sessions are open from systemd is a different model > > >> > > >> Not saying this patch is wrong or anything, but that I don't really > > >> understand what kind of model you are going for now. > > > > > > CC ca for systemd's take. > > > > > > /dev/liveupdate should only be accessed by a privileged process, and > > > sessions should be accessed by whoever originally created them. While > > > this patch does not change the permissions, it paves the road for us = to > > > move in the wrong direction: instead of having a privileged userspace > > > manager that distributes the sessions to their rightful owners, it > > > encourages userspace to work around the permissions so that VMMs acce= ss > > > /dev/liveupdate to retrieve or store their sessions directly. This wo= uld > > > also allow them to access sessions belonging to any other participant= of > > > the live update. > > > > But you can still do all this. In fact, systemd's release notes suggest > > doing so [0]: > > > > Units can also create their own LUO Sessions by talking to the > > kernel directly, and store them in their FD Stores, and those will > > also be preserved and passed down to the unit after kexec > > They should not. Ideally, systemd should be the sole entity > communicating directly with /dev/liveupdate. > > > > > Having a single opener does not in practice prevent userspace from > > creating sessions directly. All it does is to force them to turn the > > open into a polling loop. So I don't think single open achieves the goa= l > > That is a fragile design, and they should avoid it. To be clear, I do > not see any functional bugs in this patch, but I still do not understand > the underlying use case. > > LUO should rely on a single manager agent that interacts with clients to > create, preserve across reboots, and restore session IDs on their behalf. > > In fact, systemd is the only userspace process that AFAIK survives > across the reboot() boundary; all other processes are terminated before > reboot() is invoked. Relying on multiple independent LUO managers is > therefore architecturally, wrong as they will close sessionfds. > > While the kernel can technically allow multiple openers for > /dev/liveupdate, I do not see what problem this actually solves. > Instead, it seems to encourage bad architectural decisions in userspace. > > you think it should. Userspace already works around this restriction. > > > > So as long as we keep access to /dev/liveupdate restricted to privilege= d > > processes, I don't see why single open is any better. > > What is the concrete use case for this patch, once we live in the world > where systemd is fully capable of creating, storing, and retrieving > sessions? I guess I would flip the question around: What problem does the kernel requiring a single opener of /dev/liveupdate solve? If systemd wants to have a single opener model it can certainly enforce that itself without the kernel's help. I'm not sure why the kernel needs to impose a restriction on userspace that it doesn't require itself. > > > > > [0] https://github.com/systemd/systemd/releases#release-v261 > > > > > > > > Instead, sessions should be created and retrieved by a privileged > > > process that knows to send them back to their rightful owner after > > > retrieval. > > > > > > Also, as a minor concern, each userspace LUO manager needs its own > > > session to maintain state. This means that by allowing multiple > > > managers, they may run into naming conflicts for those state sessions= . > > > > -- > > Regards, > > Pratyush Yadav