From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (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 DC1723F1AA0 for ; Wed, 3 Jun 2026 03:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780457806; cv=none; b=re/YfXoIkGg8hy9WsCkmFHpydTUwkkXAsXj28el6P2PjinEcXLn5t3sxqvFUEQwRPBQT9DoirCMikISS3GOGELHPPl7ZM2rrn5cMd9KWGsa2co0JJue/5zmryatKtIME0S8YaiY9F4dnn6is39vmKde/DoYB4IfkXr1a5haMRa0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780457806; c=relaxed/simple; bh=hlmeRQF19tuuYqjlSs1OAtvups0MEJOffZTY2MaCaT0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Czgvt7uPFfQdzHyxBVVPXk/T6joXe5jnAf8wGE4W80PzsbwVzNkZo+pKARYvvzvtPdzSLE30TmSSOa9bupoglpSJOzMhbY6K7VCMD7DYHsqP2SUCEPzAVJWqLFTtfXZlqR56EZFVbOlqVWs78A5mbctRDNsrvPGkVeGjZM2mFx0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=HWgoS6u4; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="HWgoS6u4" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-5176ca6bab1so2895221cf.0 for ; Tue, 02 Jun 2026 20:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1780457804; x=1781062604; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=19g1dGk4BTOikWiMQOoz6k+1dj4ui8RGk7l8PldXTJ8=; b=HWgoS6u45MRVL3gPlAHoM78GlJVkInxgmdQDNcpyO7Ii8OygFHGqgS+MyhlX2dz8Zc WYFBrB2BpjJ16/5t2AKveHFS06ArptotD4Rqx2/l9L8uCKGR6MrDTWhK/R2sKD0tNrEo ptKlRSFNzT62HLx3CsM2nC9dpgV1k9xN7wX3aGSxl+L6TYfxkELFzlsGt5ArBEzEmFtU R3wQd2OubieNiZFDAHaXstgcl5MGcFIz/0Hp320y5au4W8UwyyUFxXQQZ3NHSaNRYKJv Ush4qgH+nykvJQ73B2Oh+zEgO6buED7HGdcFtJqtj3zEhnQWrUkyBvjcGDRnpjjUuOqw AIGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780457804; x=1781062604; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=19g1dGk4BTOikWiMQOoz6k+1dj4ui8RGk7l8PldXTJ8=; b=R20tHhskO4b7buffxA9ONZcREAJ4KE09+dGANThA9F3f4N0xFjpdDc+twJets0gyWO sKSdr+q6mTiTFvdi9WA7s915lnSkb3FnYoZpfHvFBrEFjXp2QMj0lDIGwRCrZDzWbr+w m6pkmeQHeUYDkUyno3iMutRLQhsD/FVG7tfj+uhstNkfZg1/e3LrsEdekta74dc1wIU7 OYQQPWeF4yD1yusv4dDGqmyCevWInRFsO+r0IArKabQIMO39Lk+b9QdQS5qxGVsEPPJ5 lfiKmHJl3cnpwddHKHRdWR86eJdkSEJKgW85Jz7U/ALXG7paxinnLnMMJpMeZM8CTWN4 rdEQ== X-Forwarded-Encrypted: i=1; AFNElJ8/Nu0gpUj4Y+54mgWXjau12hlRJsA3Y0M+J5UdZBXNM0F9t4DBnnV7AScqpWEVzUL5olxprYlvn8kbfCY=@vger.kernel.org X-Gm-Message-State: AOJu0Yxk6j7qQoT8cBG6EmG0i39XIB4G23/YTGXiC2/36Y4aop8h/GRF p30nVdpM5QMDGA1N0KyrFrbRupH7smex+/ow9SljzEr7hZrSnzMlf/yxQH89BkhWmtc= X-Gm-Gg: Acq92OHjFCD89BvifjMybm2KbarUHE5KSUceKqJ8gkOwgNszWXWHlUPLqjqDWa4yzbp HKWxMZgv433q2RDqENDI36r8p9hCWXRJQZQy55UVPIm6YL5SxfNX2tDGp33ptClLbLD+tr+7SyA /KQu6XN36fqDpkW8jyMe2IJaCYcn0H6N7kWYAPmkJGajEFU4KQ85sVOoP0S71tUPvUhiIC9Xy06 KwQh16/7tG819cDXTlyHHFYEMHG0YEo2Q3e7MfljAtU6uY7ajjzDXJmSWv9zL1Ix1V/ZoJ7D5j2 /vVfaqebj1qXrtHIYvQrDsiCqQ7zmFZejfjSUoZQMyUAxrdGMusbfH/xsQxpquOW9L071bN3xuk TcP/iM9Fcpy84oZ6j0Lj/vXycGlOiIB02xvg8B65ZL0hc+DIqbGl5k6cXz2sxDTCXWHJP7Gag9H eoAwioZRSVZHVEjOVPfSR2jXRVZyl1vonw0b0o44zXL0ktGJkkpW4U6x3pLCJzAw== X-Received: by 2002:a05:622a:1911:b0:50f:bd19:657b with SMTP id d75a77b69052e-517796cbe0bmr19101691cf.10.1780457803843; Tue, 02 Jun 2026 20:36:43 -0700 (PDT) Received: from plex ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51775c07c29sm14969661cf.1.2026.06.02.20.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 20:36:38 -0700 (PDT) Date: Wed, 3 Jun 2026 03:36:37 +0000 From: Pasha Tatashin To: David Matlack Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Morton , Mike Rapoport , Pasha Tatashin , Pratyush Yadav Subject: Re: [PATCH 1/2] liveupdate: Reference count outgoing FLB data Message-ID: References: <20260528174140.1921129-1-dmatlack@google.com> <20260528174140.1921129-2-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260528174140.1921129-2-dmatlack@google.com> On 05-28 17:41, David Matlack wrote: > Increment the outgoing FLB refcount in liveupdate_flb_get_outgoing() so > that the FLB structure cannot be freed while the caller is actively > using it. Add an additional liveupdate_flb_put_outgoing() function so > the caller can explicitly indicate when it is done using the outgoing > FLB. > > During a Live Update, the kernel may need to fetch the outgoing FLB > outside of the scope of a file handler's preserve() and unpreserve() > callbacks. In that situation there is no way for the caller to protect > itself against the outgoing FLB from being freed while it is using it. > Incrementing the reference count in liveupdate_flb_get_outgoing() > ensures it cannot be freed. > > This change also aligns the outgoing FLB lifecycle management with the > incoming FLB, since the latter uses the same get/put semantics. > > Fixes: cab056f2aae7 ("liveupdate: luo_flb: introduce File-Lifecycle-Bound global state") > Assisted-by: Gemini:gemini-3-pro-preview > Signed-off-by: David Matlack Reviewed-by: Pasha Tatashin > --- > include/linux/liveupdate.h | 5 +++++ > kernel/liveupdate/luo_flb.c | 10 +++++++--- > 2 files changed, 12 insertions(+), 3 deletions(-) > > diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h > index 88722e5caf02..c344bf987b63 100644 > --- a/include/linux/liveupdate.h > +++ b/include/linux/liveupdate.h > @@ -243,6 +243,7 @@ int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp); > void liveupdate_flb_put_incoming(struct liveupdate_flb *flb); > > int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb, void **objp); > +void liveupdate_flb_put_outgoing(struct liveupdate_flb *flb); > > #else /* CONFIG_LIVEUPDATE */ > > @@ -292,5 +293,9 @@ static inline int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb, > return -EOPNOTSUPP; > } > > +static inline void liveupdate_flb_put_outgoing(struct liveupdate_flb *flb) > +{ > +} > + > #endif /* CONFIG_LIVEUPDATE */ > #endif /* _LINUX_LIVEUPDATE_H */ > diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c > index 8f5c5dd01cd0..7ddef552ff6b 100644 > --- a/kernel/liveupdate/luo_flb.c > +++ b/kernel/liveupdate/luo_flb.c > @@ -135,7 +135,7 @@ static int luo_flb_file_preserve_one(struct liveupdate_flb *flb) > return 0; > } > > -static void luo_flb_file_unpreserve_one(struct liveupdate_flb *flb) > +void liveupdate_flb_put_outgoing(struct liveupdate_flb *flb) > { > struct luo_flb_private *private = luo_flb_get_private(flb); > > @@ -266,7 +266,7 @@ int luo_flb_file_preserve(struct liveupdate_file_handler *fh) > > exit_err: > list_for_each_entry_continue_reverse(iter, flb_list, list) > - luo_flb_file_unpreserve_one(iter->flb); > + liveupdate_flb_put_outgoing(iter->flb); > up_read(&luo_register_rwlock); > > return err; > @@ -291,7 +291,7 @@ void luo_flb_file_unpreserve(struct liveupdate_file_handler *fh) > > guard(rwsem_read)(&luo_register_rwlock); > list_for_each_entry_reverse(iter, flb_list, list) > - luo_flb_file_unpreserve_one(iter->flb); > + liveupdate_flb_put_outgoing(iter->flb); > } > > /** > @@ -546,6 +546,10 @@ int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb, void **objp) > return -EOPNOTSUPP; > > guard(mutex)(&private->outgoing.lock); > + if (!private->outgoing.obj) > + return -ENOENT; > + > + refcount_inc(&private->outgoing.count); > *objp = private->outgoing.obj; > > return 0; > -- > 2.54.0.823.g6e5bcc1fc9-goog >