From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp3.mymangomail.com (unknown [209.141.44.239]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B42D93CF044 for ; Fri, 20 Mar 2026 16:44:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.141.44.239 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774025071; cv=none; b=ANgmXNZD4iJSYaQqSD8JjxwkLZ1J7e+SxVNfMsVddywnUhNi63wgeZzADtX52b61efImkNjAm//x7RJwyKv259QRnvp9pnujGjbS6v7qrKlMOA8JWpZ7JynErlW8X0lNaG+8Wg6A9UJQELVVkqFSV0mvmCc//06aS4oecK6Ciw0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774025071; c=relaxed/simple; bh=LCP21uO2OPKzphq8H7bcRGLaZ+F4b8Pc7Apy117wI5s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T73poOLLujPG6CuwJ96/YLMX/z7rvGclb/wig28f1r8kab1xVQVxXQJTYQr9+I1M/xSZwnAwNNDthsZg1jqsC7f/zSh+hjHRdEI8JUl/+NRpY1J4NKxuTz8RDbJWcZviBteOLBDhHzlNW0B8WK2htdq2XNM8DbPRPhcEFmdnKVA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gerlicz.space; spf=pass smtp.mailfrom=gerlicz.space; dkim=pass (1024-bit key) header.d=gerlicz.space header.i=@gerlicz.space header.b=OLWx2AuE; arc=none smtp.client-ip=209.141.44.239 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gerlicz.space Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gerlicz.space Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=gerlicz.space header.i=@gerlicz.space header.b="OLWx2AuE" Received: from [127.0.1.1] (localhost [127.0.0.1]) by hillsboro.smtp.mymangomail.com (Mango Mail) with ESMTP id 037615F43E; Fri, 20 Mar 2026 12:44:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gerlicz.space; s=mango-1; t=1774025057; bh=LCP21uO2OPKzphq8H7bcRGLaZ+F4b8Pc7Apy117wI5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OLWx2AuEk0kG9zBBROAAKPICPPUq6/y4iYKgplAdXo2kKU5ghP/1Vq8FbbPIj5Lhl ebBvCd0GELyrvFcdtjUGEPnro+SFSGOepH/O/gahw3Gs6ss7SlG8rO89oSNO0pxFSU v4crwG1qDceb9CbH9uwzVkPEg7D6ruXeFi9D4kqk= X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 X-Mango-Origin: 1 Received: from authenticated-user (smtp.mymangomail.com [205.185.121.143]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by hillsboro.smtp.mymangomail.com (Mango Mail) with ESMTPSA id D56385D9B1; Fri, 20 Mar 2026 12:43:16 -0400 (EDT) From: Oskar Gerlicz Kowalczuk To: Pasha Tatashin , Mike Rapoport , Baoquan He Cc: Pratyush Yadav , Andrew Morton , linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-mm@kvack.org, Oskar Gerlicz Kowalczuk Subject: [PATCH 5/5] liveupdate: guard FLB counters against underflow Date: Fri, 20 Mar 2026 17:37:20 +0100 Message-ID: <20260320163720.100456-5-oskar@gerlicz.space> In-Reply-To: <20260320163720.100456-1-oskar@gerlicz.space> References: <20260320163720.100456-1-oskar@gerlicz.space> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The FLB lifetime counters are decremented unconditionally on unpreserve and finish. If either path runs with a zero counter, the value wraps and the FLB state appears to stay live forever. Once the counter underflows, later handover operations can act on stale FLB state or skip the real final teardown, which makes restore and finish lifetime tracking unreliable. Guard both counters against zero and warn once instead of decrementing. This keeps the existing lifetime rules intact while preventing wraparound. Signed-off-by: Oskar Gerlicz Kowalczuk --- kernel/liveupdate/luo_flb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 3672cbf8e075..06501360fa3f 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -128,6 +128,9 @@ static void luo_flb_file_unpreserve_one(struct liveupdate_flb *flb) struct luo_flb_private *private = luo_flb_get_private(flb); scoped_guard(mutex, &private->outgoing.lock) { + if (WARN_ON_ONCE(!private->outgoing.count)) + return; + private->outgoing.count--; if (!private->outgoing.count) { struct liveupdate_flb_op_args args = {0}; @@ -201,8 +204,12 @@ static void luo_flb_file_finish_one(struct liveupdate_flb *flb) struct luo_flb_private *private = luo_flb_get_private(flb); u64 count; - scoped_guard(mutex, &private->incoming.lock) + scoped_guard(mutex, &private->incoming.lock) { + if (WARN_ON_ONCE(!private->incoming.count)) + return; + count = --private->incoming.count; + } if (!count) { struct liveupdate_flb_op_args args = {0}; -- 2.53.0