From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 0399D3F8EB5 for ; Thu, 28 May 2026 17:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779990111; cv=none; b=gbXUwdQLhqIxe5mLClTSoJpWXrDrs36GBvggwuZSHwLgNJ9WsSVswdefDdZUUdDtWDM/XNUFV6h3fLq6CfoLvhVPdOGmknnEY70gNAQcyqixaVTQp9PZvA8734OjtPFLBZiNC5tv//CABRiReTnRmx1805JXRLNRHb4XmELSJZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779990111; c=relaxed/simple; bh=KAMdx8s2C1zMEwaN5gNaaXfmuRTW1H6Sy6SYcyTzxI4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=rVmuDwqogPyc3FQTO7SJ62xYAebqix2V9eQ/xyiOP70JpEPPpNf7vYos6Li3aq1JGfZ3eBVW6KJWMYGLZ3YIWiR5c3Vp7mM2sVp6gyCkjjdA6qDDJaYJ6NlUIiCwY8c4JynYUaWUAEar/UcSsq8VBuLk+0D2L0I9tJw7kU923qY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZeOzaDSq; arc=none smtp.client-ip=209.85.215.202 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=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZeOzaDSq" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-bce224720d8so6626021a12.1 for ; Thu, 28 May 2026 10:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1779990109; x=1780594909; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=zI6/R1kae2LnDj1mKhlFVbr6Z6bSt4LSCoOlMnq3wXg=; b=ZeOzaDSqRX1y5YzTW4R7Y1T99rTFReXuQzNvAE3A5wZ2NYWBN8mPBzxLRaXKjNje4/ 3voULJaBBYUfePI+ae6HfP3buM0TDradoGAcS6YUqnLrwTct73RCjopmH0kOT/dsdYRB BQj/5zSxzSiL37KNNAvR8OmgZXDS+P1KVED1c2UeBapjvdcq1779aI66ir6XlaBcYr8h wmAZiqqww1fMJthck/8viPtlFMWElWfD7CyAIUgsUX73sG8hAKVGD+m0ACWxL+pgs+I6 Dl99biTYbZgAgsFhIPkPMSB34SmAFUTyREbd4HNNvf4RiP4+3gYnKhDawSRv4vL03GN6 VI9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779990109; x=1780594909; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=zI6/R1kae2LnDj1mKhlFVbr6Z6bSt4LSCoOlMnq3wXg=; b=nnkYkhcs2udDzeKH0D2N9/MhlZ8gV2bCFilYqNmtT4o8g6zUD0rj33gAiK16exdrH4 riHN0MQYQSiUcCGFVsu+Dg4deOGyCLUujaXKVJl0/ixAwaW9ppUUb/2H+v2u59cX6uyD 8eabs4VPCfO5rdcWZeGKNjnINF45AVM9mfF0QtztGG96TrlHth6uUwd5f5lGWwZOlCDv QObkxqjx3uDH/Kw3EFZPN6FHB7KqtplZRfmutE+MGtvw9WahGtb4E7tjGUDkn3CTei91 OSAMYVQPArMFMS0kFmWZz43EejEvkbGGBLi7t77mVydjfhqS41WJ5PIzR3xCosFs5l7g 3siQ== X-Forwarded-Encrypted: i=1; AFNElJ96af7+AtlQOh89EfKMyIqGN3fLd6KzXB2CyStK5LSkQGekJEtvz26xHsaA0NnckZ5v7mrGRq8KFsvSWqI=@vger.kernel.org X-Gm-Message-State: AOJu0Yw9mOsdWpbXYC0qNGZqUM2r8Y32SUezTJW1FxoL9OynB1aep2S1 N/jxfQfsiyq7yvLcrpb97LCIGKx6bYnGUuL1JYuqTcUYUP0k+/FAnvFTKt94jo++hJPSwkLMAM6 xGmmhVUmBawHvsw== X-Received: from pgli34.prod.google.com ([2002:a63:1322:0:b0:c82:3bf0:91df]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:394c:b0:3a3:33bd:319b with SMTP id adf61e73a8af0-3b328f3b012mr30313814637.39.1779990109127; Thu, 28 May 2026 10:41:49 -0700 (PDT) Date: Thu, 28 May 2026 17:41:40 +0000 In-Reply-To: <20260528174140.1921129-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260528174140.1921129-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.823.g6e5bcc1fc9-goog Message-ID: <20260528174140.1921129-3-dmatlack@google.com> Subject: [PATCH 2/2] liveupdate: Remember FLB retrieve() status From: David Matlack To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Mike Rapoport , Pasha Tatashin , Pratyush Yadav , David Matlack Content-Type: text/plain; charset="UTF-8" LUO keeps track of successful retrieve attempts on an FLB. It does so to avoid multiple retrievals of the same FLB. Multiple retrievals cause problems because once the FLB is retrieved, the serialized data structures are likely freed and the FLB is likely in a very different state from what the code expects. All this works well when retrieve succeeds. When it fails, luo_flb_retrieve_one() returns the error immediately, without ever storing anywhere that a retrieve was attempted or what its error code was. If the user attempts to retrieve another file registered with the same FLB, LUO will attempt to call the FLB's retrieve() callback again. The retry is problematic for much of the same reasons listed above. The FLB is likely in a very different state than what the retrieve logic normally expects (e.g. some KHO pages may have already been restored and freed). There is no sane way of attempting the retrieve again. Remember the error retrieve returned and directly return it on a retry. This is done by changing the retrieved bool to a retrieve_status integer. A value of 0 means retrieve was never attempted, a positive value means it succeeded, and a negative value means it failed and the error code is the value. This is similar to commit f85b1c6af5bc ("liveupdate: luo_file: remember retrieve() status") which did the same for LUO files. Fixes: cab056f2aae7 ("liveupdate: luo_flb: introduce File-Lifecycle-Bound global state") Assisted-by: Gemini:gemini-3-pro-preview Signed-off-by: David Matlack --- include/linux/liveupdate.h | 6 ++++-- kernel/liveupdate/luo_flb.c | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index c344bf987b63..63ea5417de84 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -173,7 +173,9 @@ struct liveupdate_flb_ops { * @lock: A mutex that protects all fields within this structure, providing * the synchronization service for the FLB's ops. * @finished: True once the FLB's finish() callback has run. - * @retrieved: True once the FLB's retrieve() callback has run. + * @retrieve_status: Status code indicating whether retrieve() has been + * attempted. 0 means not attempted, 1 means successful, + * and negative value means it failed with that error code. */ struct luo_flb_private_state { refcount_t count; @@ -181,7 +183,7 @@ struct luo_flb_private_state { void *obj; struct mutex lock; bool finished; - bool retrieved; + int retrieve_status; }; /* diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 7ddef552ff6b..f8852f7e62e5 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -170,7 +170,10 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb) if (private->incoming.finished) return -ENODATA; - if (private->incoming.retrieved) + if (private->incoming.retrieve_status < 0) + return private->incoming.retrieve_status; + + if (private->incoming.retrieve_status > 0) return 0; if (!fh->active) @@ -196,12 +199,13 @@ static int luo_flb_retrieve_one(struct liveupdate_flb *flb) err = flb->ops->retrieve(&args); if (err) { + private->incoming.retrieve_status = err; module_put(flb->ops->owner); return err; } private->incoming.obj = args.obj; - private->incoming.retrieved = true; + private->incoming.retrieve_status = 1; return 0; } @@ -215,7 +219,7 @@ void liveupdate_flb_put_incoming(struct liveupdate_flb *flb) if (!refcount_dec_and_test(&private->incoming.count)) return; - if (!private->incoming.retrieved) { + if (private->incoming.retrieve_status <= 0) { int err = luo_flb_retrieve_one(flb); if (WARN_ON(err)) -- 2.54.0.823.g6e5bcc1fc9-goog