From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 E13511DEFE0 for ; Fri, 27 Mar 2026 03:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582420; cv=none; b=c7PLTz35pHlZw6+jjG0QN5Z5uwA4hp8oA4Vm0cnyKNyZzR0ZLW0jD59tQKb7ur1pC0oVKi2zDCGzQE8fKXGmOHeka8180E1pgx0sXL3j04fPLPsAImUe6FqQe0uBIumEIFMa7GuTocbtDBKZWAo7B2ImyAUsttRR8hTTTbD+IHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582420; c=relaxed/simple; bh=pd2uvYHBSMAgA0yLve+m/ccHxTIR5c0aDL+TySoU03A=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r0F7cs+GzM6zmz3FRIk+3SKXSjVu90pzB3CjU/zgBwNXcx3RbgisWPKcGMlzMjluW89NuzIVb12mFYsJ6SWoEZ/7ANnrid2SnGDvcyVU5kj+SyCOJIyyOX39XAqiCcCLbQRwYeuAlRL23sezuRTTTSUdvUSalYbb6FVeuSJdGwc= 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=Oq59iogM; arc=none smtp.client-ip=209.85.219.43 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="Oq59iogM" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-89a1d7cc7f0so14216276d6.1 for ; Thu, 26 Mar 2026 20:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582418; x=1775187218; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uLvspK1gu6gX+80jQiUMF5aw95bvgPpDygvOrl90xlM=; b=Oq59iogMcNQSF/fCkEQh8VsZ1Z3hKc7vuW9oGVkeEsugo0R04lvd6m8RhlNvRpTnMf VfOe49RksB7zVw6l7bWvnqHVDm8NJBiQl13S2Qk9eUp5rhB2sEb62QUL9+z8rNbvMmom Y2AQUSPug2DRIayrwACGb4rcUPbnguCaXwTJ1T9iiNKppnvrKtjkOe3XeGuMr+TKcXc7 GQhgMsYWpmUA9GwSBFgpNN9C4P7Phv0K8FzpqIDcIwr4lUA8EzXF7GX/sLQA61NKdI2a Ao0U1AhmDuU21BXTNUdidsO4Yv9WDMnHOuMUuOJ67yC7Kmw675IcuRJZUUBa06fSeUY6 d0Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582418; x=1775187218; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=uLvspK1gu6gX+80jQiUMF5aw95bvgPpDygvOrl90xlM=; b=WR3jx7Wj0eQ6ULUshoKR4tM2cHCrQIfk9KvXnyYb3d/Gx/rYeTHhYTMpLlCrrqERDs IawL3FjCNPzgh45du70KXdy4bWGVWm6aRESddzuaH4FwSpTM4l8pUDqB2ktVHbN+xVvZ ZFoGOhhhlNnSZQyw3lmaeR97CYmf6E42CeH3WCLgDhbHTAZaIu7fJiLwx+9EywlXlHtF fYMOhIIwlbskr1pFdUmSSHHJIy0ssvnaT97uvTaPWZW0i5G6a3DL3dQ+Y7PqonGap+n6 hucg2921diDBoGyoghCrCQwNStiHkIpyBrqTr2dHeaIlqlJ5v4XOkvksDezuJ1K5ifHQ DSiQ== X-Forwarded-Encrypted: i=1; AJvYcCViOVNogW2r1jFZnV+F8N7Yq0UU/SBbXeTAC7XTwIcIEkfa0JsKXWfE/xljvWfvcSXluz8Mih2vCacM0B0=@vger.kernel.org X-Gm-Message-State: AOJu0YwXUdA/b/D90VWMtniaYv8zuPtKaX9xxUAxQ3EeOwNAq8K25yRH k22wXIaqhP4mm6B2pXPhF8fdytT0QVvClHCckSHlBlHA45G13HRUYQddBt22IAqcgRY= X-Gm-Gg: ATEYQzxJuDvkA0Wj5tjyFfTWGFOzKquVX10Qyade7/tjV2HKgBGGjY9sC4wxFZc6yCA gD76XKs5k9Tte8PGcBLoN09XqmSn7WMJn3uTwKB0G8EyoTmTnBICGkC6oMHg8jaVRuc4DNQAvJA pKpmAQKLahUkz2zMbRAMTdwVmKEDoRFS5wR+1r12OW4HI8R3Nwpe7MROWAnuyx/poqT5UGj5cif gR2dLlaheuZ6B/m7Xz7iKYhLoExXGIaL3N7LIkJEfaJfhaJjc+11axSF+34OwmWED1Yjiam9leg K0JYHPrW7qFofEsYnpVlcI9Wzn5f40rTTNz3KnimFNl6VGo+xhs2RY1dF+2oFROCu8VbEOhcZ6/ odEHMhjeg75NMy4r+aE1CZbj+oSFkIHBbm2gfVhkI/e293pcVha/g4ZDTTOYDtudPn9nvF6If0q Yzenaeht+dNW0FpzAgP+VyQfTnuyPs8n7zH9ZKrVk4hf0BI47mY6ENoJMjGoZONEXETw== X-Received: by 2002:a05:6214:3d9c:b0:89c:5d56:bcac with SMTP id 6a1803df08f44-89ce8b87d89mr11941016d6.0.1774582417846; Thu, 26 Mar 2026 20:33:37 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:37 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 01/10] liveupdate: Safely print untrusted strings Date: Fri, 27 Mar 2026 03:33:25 +0000 Message-ID: <20260327033335.696621-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Deserialized strings from KHO data (such as file handler compatible strings and session names) are provided by the previous kernel and might not be null-terminated if the data is corrupted or maliciously crafted. When printing these strings in error messages, use the %.*s format specifier with the maximum buffer size to prevent out-of-bounds reads into adjacent kernel memory. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) --- kernel/liveupdate/luo_file.c | 3 ++- kernel/liveupdate/luo_session.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 5acee4174bf0..a6d98fc75d25 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -785,7 +785,8 @@ int luo_file_deserialize(struct luo_file_set *file_set, } =20 if (!handler_found) { - pr_warn("No registered handler for compatible '%s'\n", + pr_warn("No registered handler for compatible '%.*s'\n", + (int)sizeof(file_ser[i].compatible), file_ser[i].compatible); return -ENOENT; } diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index 25ae704d7787..8c76dece679b 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -544,7 +544,8 @@ int luo_session_deserialize(void) =20 session =3D luo_session_alloc(sh->ser[i].name); if (IS_ERR(session)) { - pr_warn("Failed to allocate session [%s] during deserialization %pe\n", + pr_warn("Failed to allocate session [%.*s] during deserialization %pe\n= ", + (int)sizeof(sh->ser[i].name), sh->ser[i].name, session); return PTR_ERR(session); } --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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 3ED1536CDFE for ; Fri, 27 Mar 2026 03:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582421; cv=none; b=aoOYYbUJ+aYYiiHW1KGo/1jGQ1Yhkno4+P/wFgTm6eVtfhdZ98grWj2KHxRqTI1OjLVg0V3+IEELfeveuSdsKNoHY0/ywNgsxgLDvuSaNHVKdQ6CsvZygrBaeoLxknuCrymz+alMatRjbw6+7qCgNZ/AVyzjKbPlNQGqXWGEtAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582421; c=relaxed/simple; bh=9nimeFZPQhAj+PyTPjWVOo8WOEyYl0Utw6litWdH8W4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cd7Y77gttsD59xLGaI1NgYc3B6OqTpMdCxLENGZqVFWEAIbgAPwcUyjPKPrySVHbZuOiv2yJdCbNvlwX0PRtXIpOQwYDqrdYP+VtFuwT+lJ1ZsD/0DIJCgB6WxCWzmPuHnLCrxX+4Z4mXUTHVf42BHe8exINng5r9mQFqsZzbY8= 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=XU1qpxHT; arc=none smtp.client-ip=209.85.219.51 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="XU1qpxHT" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-89c5446f3caso20518166d6.2 for ; Thu, 26 Mar 2026 20:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582419; x=1775187219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=w0STs1QLqmbfKiY/OTrM4XieB5E7WPH8bzjLowLKVe4=; b=XU1qpxHT/zkWpV/AyKUyb9kruDnavCOYzy0X697vDHOzxhJYB7QCoRdtjGyvGIBfk1 qkCnQoyPBSbVGDmNPyrzLy3WPN6QftjJ76N2Ygwsao/FGAoJHaI2kpJCMNpo2UCaCN2M lAfBAt0oAMVu+DPtiEb+pJL9Tq9kUr8sgohPu3Sc5xx1BWArS0Q6c4g/hyqss7FDi4/C DXPzdfutAsjugVoPuH6ITxN11KOH56TBrgZa9vmi86MtUIjr8qZbPuQVOaw80OqxJ/BU gigkyS1fCqt8R8l1e2D2xtvf+qkwKY+sEZb5E1Xw1/gTUtlbgbjRcn7gXGfWwYmPr2KJ CIMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582419; x=1775187219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=w0STs1QLqmbfKiY/OTrM4XieB5E7WPH8bzjLowLKVe4=; b=tVgzCaXtzz5otghwORq+opaxV6ym9rifnLr6EPNKWGOelRYGM6ObrMop6fP3HSZOQw yhQ/99zZIiPL0ZuItc0UtKxTaeW6yNKdzGHuS9ww4NtuXmTUFRdgeOa7iiBpP5aSysYd HVBMTwx6wSbddKYd+ImzG2KLZkDc4L0S/3sDO4KYMBf7hZuU7kXIFVf9m8Zjf9097+1Z 0Q/oCYUtxUoOKVKzQ69ImAncwdi/cELzy6z4q+8KroXcyOe8GMB3M6yPUDoLI/Q+Spr3 8AujgkAWTnb6AgSHNfyCRV6vwKIYFN2WY33hPsT4ItIYapVdw9HDRRtIzaypgx+Db2ZR m+/w== X-Forwarded-Encrypted: i=1; AJvYcCX495ybxea7Qc3FmDLfk6Rygq2pgLs+3QGr03h9uTT6S1JIRMpb+9Nc63yiBqyLRBR4/7h2h37r9hpP3cM=@vger.kernel.org X-Gm-Message-State: AOJu0YyITROHc3Sy+EAN32QBDza5X+voehwMUb7jbfBhvB3BFuDY3ZhG kTBDEBknGERkJtJJhGpHEg4dgbNP2ezW5ijq7oLWiP6JCVSL7m40Wbu+QIaA2Kr7dVE= X-Gm-Gg: ATEYQzzaHtaMzM14M3f8oeiYsc3ARgIGvYwWNZe3YXqNRypSrOrZXxppK2NwVoZa4u1 qg+jAKyiNpvE6mX1OGEtQwOU08Hm8nNi8841kvc8/cdtP89Rv4dMHl+nXCIORF6DikbE6LnTWN5 QE7bAlp6rmuFlZKryp9ISTVQ9qUbmY79q4suB93HKcWvnzzD9X3EgkCKmydyUWyHf3pfn4WFuzL kz49HnRWgX7WtJzw+lqfxQ3sAmrPspDOzwMomzOjyKPoJw186Gbj+QVGUBRq8uTu1Dy08e8wOgA AJJMSmpDMHSTWwEgOlHhHeT+x3x2wA3FZUV9A24frOavLQBlQzZlZFSOiOVIi2rCFjb5jAV0Ev3 js/suuFJup8zPpy8a3i+lkusF/KKG1ag/FOD5B+ERllUeqyNJ/hujhM3bFuelYs1ANJct5f1Cuv K4bN3urBtuPieUVLLuHMqVLQBJTwO8BPYctvn6qg7UWa8s9uZr+tshIB/U8SSPwV77yx9QNlpJx NN1 X-Received: by 2002:a05:6214:4a04:b0:89c:d408:b52b with SMTP id 6a1803df08f44-89ce8f436f1mr11006356d6.48.1774582419011; Thu, 26 Mar 2026 20:33:39 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:38 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 02/10] liveupdate: Synchronize lazy initialization of FLB private state Date: Fri, 27 Mar 2026 03:33:26 +0000 Message-ID: <20260327033335.696621-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The luo_flb_get_private() function, which is responsible for lazily initializing the private state of FLB objects, can be called concurrently from multiple threads. This creates a data race on the 'initialized' flag and can lead to multiple executions of mutex_init() and INIT_LIST_HEAD() on the same memory. Introduce a static spinlock (luo_flb_init_lock) local to the function to synchronize the initialization path. Use smp_load_acquire() and smp_store_release() for memory ordering between the fast path and the slow path. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav --- kernel/liveupdate/luo_flb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 855af655b09b..317c02a94da5 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -89,13 +89,18 @@ struct luo_flb_link { static struct luo_flb_private *luo_flb_get_private(struct liveupdate_flb *= flb) { struct luo_flb_private *private =3D &ACCESS_PRIVATE(flb, private); + static DEFINE_SPINLOCK(luo_flb_init_lock); =20 + if (smp_load_acquire(&private->initialized)) + return private; + + guard(spinlock)(&luo_flb_init_lock); if (!private->initialized) { mutex_init(&private->incoming.lock); mutex_init(&private->outgoing.lock); INIT_LIST_HEAD(&private->list); private->users =3D 0; - private->initialized =3D true; + smp_store_release(&private->initialized, true); } =20 return private; --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 22D3036E482 for ; Fri, 27 Mar 2026 03:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582422; cv=none; b=b3pn+oIiDsmA2lHstXZf+bP9mOl0NXevzYjhEEg4gre/GxYWQ3GuoMKE5KsS/ZfnFMKCTOAeLSBSnTNMOzZowyW67WWi9e7E0fcWLY7xBjZLzFx/4LrtOfzXAIp04Lco4KI6R3ku3LX+nU40+Hn/Vkym1ZlbKzusr1o+tNNxmzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582422; c=relaxed/simple; bh=wAWOJdQ2lJZNDFwBbLTs3uK2E6jcDIXtd9lK4m5SsE8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lOuzV3FJBBMltRQTmNyyJS74W8lHGxb3BgtiBxpDslvVG4w/1Z+hAWKAp5zSJyXvrGug9qEHVUxcH2GYSKgFxHWRdWGw4QFkyWU//AUAX6+Au6evIdFIRxzm9Q32O5zSvQGuZjyh70lM8gJLA8xA7lItjDFUU2pTjEd6R71i1bs= 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=O8WBD9CV; arc=none smtp.client-ip=209.85.219.43 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="O8WBD9CV" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-89a1347051aso26279026d6.2 for ; Thu, 26 Mar 2026 20:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582420; x=1775187220; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4wsuYjjRM0hOSuiSmqKTO5rWSTT9azGBUD//zIgxv50=; b=O8WBD9CV5YtvJHfiyAnWxR7fK0Erjyq9gAdHLfmZxzGFes9VFX8L33gnImZOZAg7wT wPIqJL3QW/8qHGMcJFuSuAryGmMS3OrVDfLn0OQAYPYGP8Goi03zGWYmkEX2Ib6CuKno RHfCHyIIBJMe8uj0Y9m1xS14WHBLBLHQDsaGhxFtzMucXh/UPycMpHR2ZfKeV22RMmo3 nNyNPKXahAt5Nhj+cMb2goZ6n+ucsuz8TQWPrH9pLj/m3japzNcMeIMPfIfFN53kA41Y XGLuqJl0nnkyeU0QqcFNIaTWi1uyZ40jjzNGIycwosLN67SbwZNhgNQXkAcemlTgcL6r 0wRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582420; x=1775187220; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=4wsuYjjRM0hOSuiSmqKTO5rWSTT9azGBUD//zIgxv50=; b=ILeDYWFezMi8L91w7LzvP/RIrAISEyTfJpMn+vst6TDVCIVNNqHcVnRcNlQ4R/pwAA Cdd8p0ss9EKYh2dutLVOT6PtK42xEu6VRRHmDzHvVkqv794RYWDKLvOxs/mqRNQ+LGo1 C0D+96tiDen1MKVEzzfiI3mQle7Y6y6q70Uje8sLhXl+dqHS5kQ7D48edeLOp1EdOrnM QM3OpPIxPGq/74QOSAgvjAwcrg26sGKOgDp2MarCMxM970XXBeXgrdSSnW594Zn3hCRo lNDo3R4/3amg/SeC446qH3fOXxfpWyQQimJmiZEzsdbyrsWk+QMUnZbGPTsj/mUYiOz0 Gitg== X-Forwarded-Encrypted: i=1; AJvYcCVNp6od4/LoMtF1034Wmlb2Hj0WwgJin2EqSq7WMpbh2gTGruAAiVhzqd9q7DGc1LRXFr9kE9S+ntpvkfg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1cHceMMQY7OlWxglJADE48bPP3iukJ8agCpIqf40WIW8P6Kyi VJAuGGLykMlLQAhCgOErzxLHNR71uTfdXyZBf5gcSo+y5FiAvaqV6/Fbvdg2Xd4Vluw= X-Gm-Gg: ATEYQzwg5lHPeIsyl70QLo94rmUtGAIins77yX5hAPTChqBs5R2qaX6UuOJQ/f5bcOa EgulAD9z+GK49ZOPXRm9FuhauWkXEHRkzdr2PR7kfdmHMAoJJOL1C+1F53vAQUJW3dPH3cPUTOF gEW3leVSl7A+XgEcUZTpgOAWCWt5GO+zj01zFBY77G3DUImia9D7T/6lgby0Dq+6Hs5GbmTWw4x a1Vdf+dKRdHfh0klWLo7FYYs7PT48otWr9wFzThkM1f1GAiHr43XxHh6XVexrmluuaWex4Ik3lC LjbOX+FvzZnPP5TTvd1HjIOTr2Y8qAUV/V6m2pnsdgPnPiWG5qbeHKYAJD6/xzoE4bPDasauUJG 9k2tva/zkx8sCXFeYdZvtU4c3uVwjBjz7RUni0ZFQ7hhsp001nuOxmr1MlSBui17tYplR35a3/9 a5zKujaOyoEUH5ELE1X3i2ig4Hm7tavOuOIBz1s+Soo6pv6hCQqbLDusHXv7sLowXHrw== X-Received: by 2002:a05:6214:2f0a:b0:896:f47e:fd53 with SMTP id 6a1803df08f44-89ce8d15897mr12694906d6.17.1774582420090; Thu, 26 Mar 2026 20:33:40 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:39 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 03/10] liveupdate: Protect file handler list with rwsem Date: Fri, 27 Mar 2026 03:33:27 +0000 Message-ID: <20260327033335.696621-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because liveupdate file handlers will no longer hold a module reference when registered, we must ensure that the access to the handler list is protected against concurrent module unloading. Utilize the global luo_register_rwlock to protect the global registry of file handlers. Read locks are taken during list traversals in luo_preserve_file() and luo_file_deserialize(). Write locks are taken during registration and unregistration. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) --- kernel/liveupdate/luo_core.c | 6 ++++++ kernel/liveupdate/luo_file.c | 22 +++++++++++++++++----- kernel/liveupdate/luo_internal.h | 2 ++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c index dda7bb57d421..f9ae9364a962 100644 --- a/kernel/liveupdate/luo_core.c +++ b/kernel/liveupdate/luo_core.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include @@ -68,6 +69,11 @@ static struct { u64 liveupdate_num; } luo_global; =20 +/* + * luo_register_rwlock - Protects registration of file handlers and FLBs. + */ +DECLARE_RWSEM(luo_register_rwlock); + static int __init early_liveupdate_param(char *buf) { return kstrtobool(buf, &luo_global.enabled); diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index a6d98fc75d25..4aea17a94b4f 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -277,12 +277,14 @@ int luo_preserve_file(struct luo_file_set *file_set, = u64 token, int fd) goto err_fput; =20 err =3D -ENOENT; + down_read(&luo_register_rwlock); list_private_for_each_entry(fh, &luo_file_handler_list, list) { if (fh->ops->can_preserve(fh, file)) { err =3D 0; break; } } + up_read(&luo_register_rwlock); =20 /* err is still -ENOENT if no handler was found */ if (err) @@ -777,12 +779,14 @@ int luo_file_deserialize(struct luo_file_set *file_se= t, bool handler_found =3D false; struct luo_file *luo_file; =20 + down_read(&luo_register_rwlock); list_private_for_each_entry(fh, &luo_file_handler_list, list) { if (!strcmp(fh->compatible, file_ser[i].compatible)) { handler_found =3D true; break; } } + up_read(&luo_register_rwlock); =20 if (!handler_found) { pr_warn("No registered handler for compatible '%.*s'\n", @@ -851,32 +855,36 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) if (!luo_session_quiesce()) return -EBUSY; =20 + down_write(&luo_register_rwlock); /* Check for duplicate compatible strings */ list_private_for_each_entry(fh_iter, &luo_file_handler_list, list) { if (!strcmp(fh_iter->compatible, fh->compatible)) { pr_err("File handler registration failed: Compatible string '%s' alread= y registered.\n", fh->compatible); err =3D -EEXIST; - goto err_resume; + goto err_unlock; } } =20 /* Pin the module implementing the handler */ if (!try_module_get(fh->ops->owner)) { err =3D -EAGAIN; - goto err_resume; + goto err_unlock; } =20 INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); + up_write(&luo_register_rwlock); + luo_session_resume(); =20 liveupdate_test_register(fh); =20 return 0; =20 -err_resume: +err_unlock: + up_write(&luo_register_rwlock); luo_session_resume(); return err; } @@ -910,16 +918,20 @@ int liveupdate_unregister_file_handler(struct liveupd= ate_file_handler *fh) if (!luo_session_quiesce()) goto err_register; =20 + down_write(&luo_register_rwlock); if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) - goto err_resume; + goto err_unlock; =20 list_del(&ACCESS_PRIVATE(fh, list)); + up_write(&luo_register_rwlock); + module_put(fh->ops->owner); luo_session_resume(); =20 return 0; =20 -err_resume: +err_unlock: + up_write(&luo_register_rwlock); luo_session_resume(); err_register: liveupdate_test_register(fh); diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_inter= nal.h index 8083d8739b09..4bfe00ac8866 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -77,6 +77,8 @@ struct luo_session { struct mutex mutex; }; =20 +extern struct rw_semaphore luo_register_rwlock; + int luo_session_create(const char *name, struct file **filep); int luo_session_retrieve(const char *name, struct file **filep); int __init luo_session_setup_outgoing(void *fdt); --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (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 1CA1336D4EA for ; Fri, 27 Mar 2026 03:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582423; cv=none; b=oueDaGRxUTF3RvlVwFZwFPpo7tdExF3kvDA5GVwAwMQ/7L4J/iBm38x/VZzgXCWuVobIiOQh6H1tRPGaMOHSdrOBcKJr9YQQrSaYtKoJzakChanTnGSAvEl/A7/xWU4sqmzi5Gnh2S9jYefSZaSPe/J8IY+FoWGnIYJFJ1rks18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582423; c=relaxed/simple; bh=pb84xbfdOieLozpDXoOkUGf0V6qrtCpPAUJkZTpvgvY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fiN94a1lTl2oW3OFa8lVnTg39Orsj9miG2rDw3BTPLtxsXocbpjZ4hPAMkHPpY4ZYRaX5GCE/y2gbL9LxSKifeL3lfvTNPFawTrG8cthCd8rzXEwPOzB+sillf8v8QEktkgs7Vos7QOCBGAyhvHSCPFx595pzaCC6P2dERWGOPU= 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=EXc4balh; arc=none smtp.client-ip=209.85.219.53 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="EXc4balh" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-89cc638496aso16612126d6.0 for ; Thu, 26 Mar 2026 20:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582421; x=1775187221; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Q2LKhamSzXfWrHIo8OAsnqwo5StsDAM8VnQ9PQ82pDM=; b=EXc4balhbHU4LYr+Rg1PozBb2IYDJSuu4KYNwtxuGaPqmEq507gaioyKTvVXfz3hOo cSa9Mqj303aH0JHKUAb9N3cyW+IZKcgLLxu7NeRrWKTQmorW54eZZ/hqKlljF3qN9x7p y+rhFDw+pO8M/bikXmA+vlkAUxHbtln3ycF9qKB0VvxQEN3p57RRf7Wp0CiX97MKiqNs /kWHXGBtWmq/Y5THVz0OINfi5OJ4OZ1OQM5lezaBajfe7kla7uwfGlBHFlm7aBOB19Nv gSOS9XNqTun0H22cRU/VdKL+OjV9GI7Jab2ZXYrrFs0gqPRUr1JoBx8WizOedBgKBrev D8mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582421; x=1775187221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q2LKhamSzXfWrHIo8OAsnqwo5StsDAM8VnQ9PQ82pDM=; b=Fm+8YLMSFFr7+xJvSuDfJLz0koPM73QngUJjigDpyhHLVZlsvcqfA8NLBWIxtUX9Dd HwQpqeDCx0Seqp5VQaHCc7adYnaQzJ/p887+ASc9cvQnP94Sa/cmUgLqztcirWA3m1nG OdWsy+OKChw+pt9P5lppQx8p+QLcW/onNyoEMkBEVHsrVvRrFB6qU13Ex6xVw0yWhKbY qrdPc0SimfI1gG2BNGBsU2yOXbb2AvbAH4mjtg7JC1sJ1RuetZLNKKG5IxQCZQ6cw8iD fRDitVIu12CRR0NKBpVT9HkAsdtFvjflMwFLz0QHFIlTiEOejLXc6SrFHnl7q3tJGnTD f0qQ== X-Forwarded-Encrypted: i=1; AJvYcCUL5nxO7Q7Z9gEhpfyhI2Bdilp2rUO3IO2CuyrYW8eJOywesmn0nKtkTzo+rXwG+Kf1P1ltQuU7aXNAYtw=@vger.kernel.org X-Gm-Message-State: AOJu0YyLXwhk8fdcRWC+BMlEH2qKcI6B2Uwl2gw6HzGSSx7I4J67DUoM e2uai+c0rMb3PI7u5wwJqVi/oQmuYdlCGe6NVDXv9V6MznFed0UBwGDj+8b3zLK/duQ= X-Gm-Gg: ATEYQzxWwspZ6Zc4XDmwHyF3L8oXCOkBK/20aBLQ2J42XmCp4pMnUHh0vkEdr3fW2lv eNf8VCHbPyJVLHo0n9FPrcy+4E6kMEXxWC7GoPVdBJbngfOlU8yD3btpSVPwYfdOK29nWixynSL tPdknXpmz7y2Z91SphXmi6Uit2CZTONfPUvqe2optoA+oPORT+FFhXTPHdFA0+dt1ZJZnMbKEwf 0WoGVRmhaH0EWDkRvLNL+iJH0mIhV8gbYw6OggHtp8nZJKQWEIJSXfCE1c5HG15MUhuKgLHdtUp YfI6MeTY9F08RjboCIe/s2uUcBVqnoK2MFFNGF8JN/cmfBT5mYyiQ2oXYWBcdM71O0Rnf/7Z0lY XNH/yXwE9saVpcQ6HorlIJvE4byqTBE4srnlhGQC77EmPSpxQu++iEM/mJjwXs1TD1gojehiM/0 0H8jcTJrd0PYwrcbEEmnSY7/sm+3ALmtVfxnEHy9vynw3haJBv8o9V/qEzqGDnsBGaB4Ffd40w6 CDY X-Received: by 2002:ad4:5ca5:0:b0:89a:2fe7:91d0 with SMTP id 6a1803df08f44-89ce8f5def7mr11945646d6.51.1774582421027; Thu, 26 Mar 2026 20:33:41 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:40 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 04/10] liveupdate: Protect FLB lists with luo_register_rwlock Date: Fri, 27 Mar 2026 03:33:28 +0000 Message-ID: <20260327033335.696621-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because liveupdate FLB objects will soon drop their persistent module references when registered, list traversals must be protected against concurrent module unloading. To provide this protection, utilize the global luo_register_rwlock. It protects the global registry of FLBs and the handler's specific list of FLB dependencies. Read locks are used during concurrent list traversals (e.g., during preservation and serialization). Write locks are taken during registration and unregistration. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) --- include/linux/liveupdate.h | 1 + kernel/liveupdate/luo_flb.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index dd11fdc76a5f..73ca84de3eae 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include =20 diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 317c02a94da5..3c91d0008eb1 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -262,17 +262,20 @@ int luo_flb_file_preserve(struct liveupdate_file_hand= ler *fh) struct luo_flb_link *iter; int err =3D 0; =20 + down_read(&luo_register_rwlock); list_for_each_entry(iter, flb_list, list) { err =3D luo_flb_file_preserve_one(iter->flb); if (err) goto exit_err; } + up_read(&luo_register_rwlock); =20 return 0; =20 exit_err: list_for_each_entry_continue_reverse(iter, flb_list, list) luo_flb_file_unpreserve_one(iter->flb); + up_read(&luo_register_rwlock); =20 return err; } @@ -294,6 +297,7 @@ void luo_flb_file_unpreserve(struct liveupdate_file_han= dler *fh) struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; =20 + guard(rwsem_read)(&luo_register_rwlock); list_for_each_entry_reverse(iter, flb_list, list) luo_flb_file_unpreserve_one(iter->flb); } @@ -314,6 +318,7 @@ void luo_flb_file_finish(struct liveupdate_file_handler= *fh) struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; =20 + guard(rwsem_read)(&luo_register_rwlock); list_for_each_entry_reverse(iter, flb_list, list) luo_flb_file_finish_one(iter->flb); } @@ -377,6 +382,8 @@ int liveupdate_register_flb(struct liveupdate_file_hand= ler *fh, if (!luo_session_quiesce()) return -EBUSY; =20 + down_write(&luo_register_rwlock); + /* Check that this FLB is not already linked to this file handler */ err =3D -EEXIST; list_for_each_entry(iter, flb_list, list) { @@ -418,11 +425,13 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, private->users++; link->flb =3D flb; list_add_tail(&no_free_ptr(link)->list, flb_list); + up_write(&luo_register_rwlock); luo_session_resume(); =20 return 0; =20 err_resume: + up_write(&luo_register_rwlock); luo_session_resume(); return err; } @@ -466,6 +475,8 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, if (!luo_session_quiesce()) return -EBUSY; =20 + down_write(&luo_register_rwlock); + /* Find and remove the link from the file handler's list */ list_for_each_entry(iter, flb_list, list) { if (iter->flb =3D=3D flb) { @@ -490,11 +501,13 @@ int liveupdate_unregister_flb(struct liveupdate_file_= handler *fh, module_put(flb->ops->owner); } =20 + up_write(&luo_register_rwlock); luo_session_resume(); =20 return 0; =20 err_resume: + up_write(&luo_register_rwlock); luo_session_resume(); return err; } @@ -660,6 +673,7 @@ void luo_flb_serialize(void) struct liveupdate_flb *gflb; int i =3D 0; =20 + guard(rwsem_read)(&luo_register_rwlock); list_private_for_each_entry(gflb, &luo_flb_global.list, private.list) { struct luo_flb_private *private =3D luo_flb_get_private(gflb); =20 --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (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 35FD536E477 for ; Fri, 27 Mar 2026 03:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582424; cv=none; b=jJJTBo524deLpkhsinFUFIVoBBZB3RqCm1nY65Tg0V9ct0CNYIv/BFb1oVuChE3iH09srDD1E6Fa6txW1oj2EXGPQelXT1gS7TwIjlkauo+J3cslN9VohYVJO+ysIN8/Kxo7YMlPJBRnsZwXyYvn9YTp48/+L3I6vzZpHntfWdw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582424; c=relaxed/simple; bh=hDYmhOCkLcuzTi8Vf3GuI5IG6D2POfCXw86QraXoLyo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y4lEFZkGSpuJA/r5TldUY/wkblLtecEMnn88bKUOVVJUpO80qweiEhxi8B6Ed/tVCNCCQCmJwTVCQKioJ+ZJWvd0mVQ4JD4lRFzoMq7wp2/yM7Opy28TRxfKQngaEY7DcubPgrn1339CV8tWorUSeTxw0e8/4LScRttH8cmTfAk= 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=JLS+czog; arc=none smtp.client-ip=209.85.222.169 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="JLS+czog" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-8c6f21c2d81so155604585a.2 for ; Thu, 26 Mar 2026 20:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582422; x=1775187222; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=6Iybl7pyAga8N/3JgGk4Dm4BTbHSRib3nIqdcUgoEHA=; b=JLS+czogmWBet57oDk0Pkzb5/OR8SSGfLizKTEnYnYaq8tud08a/J1CuOdUHkvDEqW qu1ZDBNQqlG9sXSLIhw+mIYlj/bC7OzmN/E4cKgO47xp3cjYOiBf7o7WeVO7BPljLysC A78Qea4RQg22N9ak7kOTVBtP8x+Nm8VZQr363vv5gqLs+XqDWdl3ktVxFXyrvTffdlLd 6HTxUnEHMO1O7vL34Xz7mZUcGmOxbNPUvBU8rn4J2AY7MYvmu3f/SoWLkNhIhuO91wkZ QekxPIQgdxQkNNnOo2t0w1cISTOa7CtxgUhLzSi/ZrEpONzVd9DAcU80dhWg2cHYfxHw fPCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582422; x=1775187222; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=6Iybl7pyAga8N/3JgGk4Dm4BTbHSRib3nIqdcUgoEHA=; b=dtWPmXYV+wbycbkuV5nzG8saAPZAwrKUlxSywOqpLGAj3YhrlcrzIDXVh2rxXA3qdo r3ve1/Tsu/ebTEa62Bd2yEAVDPRfeLtR74b+iEkPY5wLcvP4Q1be6PbnbHnDhhgTijA0 LxUgcYF77U1MIAyv2BP3oS0QogcahwVDthOHzSJmYB7k/pwPk63o5GR7XMgIm8U9kDUr UN9oPq/mk67HtJQJsAFuX25sPlFAJqchX80myy320yku4e4GWhxV9qryeKlKfaC5Hc+Z GcImC1gkGW7uTF/oJQE/nqurMPnPqhB/bAwxGB7YOwI5gwKHL17f57zeIBGG627T+b+0 FXMg== X-Forwarded-Encrypted: i=1; AJvYcCVCSGvowZQR70o7phdMBpIh/61tS9thDKzDbP9LrgT82XozBn27WWJlW3pu+sSSDHemLI81ShpngsSIGeI=@vger.kernel.org X-Gm-Message-State: AOJu0YzibEdS6sMRHLWOwWpFnf5WniIw9eRA/LX+gRl2rFP43BhP7YyI guRwauBzjsSiIFrx6JzhyXWW/6LgLXjV1e9lcAm3BtJ4KhQaF/q3XI1a3++4JZJ8nKY= X-Gm-Gg: ATEYQzzxVYOImkniiGoa193Fj5wF9dex3DVPGzckUsh8jgouZST++3ggnahevI/mJ3R /CqGffSK+IIol4umkR0VOTYfpZthR1OIMb8hu/wJo/Mz25qu395Q2/f5/aKvOVfu5PEZ/7XFatx 9BjOjCQW1GL6cocoE8jmhyfMnvflzG40vhkqhFpj0VIoXMhrHg1Pnb6jPHtoyU2CAnwNkixpNIv IJjetsB2tUAqpoXyZjHIPIo0DLlUZtcaaangYUvrTg3gjiQNawGrrajDSTPvU0vlqDqswp9ZHRd RHd0LY8Cc4Cs1vPmbr8OhBuvb6FdIWouphOpv+qZIC1lN8io/U2J3ZnnXoxsxleB/5pHIXiLZ93 fIRIDja/Ts7YAAc+Eg5YHEIJbf8Y3X8ZDsC9fIbVf1nsDzY5ufyLVe17tfrg01EPo+DZvfSaz6z u+ZSOUxpe+/CBzOpFisykJcQRuE2aZ0Fjo0N+qn+IAcRMuZ6F728BPciz+UJqkpuKGqA== X-Received: by 2002:ac8:7d4b:0:b0:509:26f4:64e9 with SMTP id d75a77b69052e-50ba3994b30mr12539711cf.51.1774582422102; Thu, 26 Mar 2026 20:33:42 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:41 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 05/10] liveupdate: Defer FLB module refcounting to active sessions Date: Fri, 27 Mar 2026 03:33:29 +0000 Message-ID: <20260327033335.696621-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Stop pinning modules indefinitely upon FLB registration. Instead, dynamically take a module reference when the FLB is actively used in a session (e.g., during preserve and retrieve) and release it when the session concludes. This allows modules providing FLB operations to be cleanly unloaded when not in active use by the live update orchestrator. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Samiullah Khawaja --- kernel/liveupdate/luo_flb.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 3c91d0008eb1..ce28ce9b113e 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -115,10 +115,15 @@ static int luo_flb_file_preserve_one(struct liveupdat= e_flb *flb) struct liveupdate_flb_op_args args =3D {0}; int err; =20 + if (!try_module_get(flb->ops->owner)) + return -ENODEV; + args.flb =3D flb; err =3D flb->ops->preserve(&args); - if (err) + if (err) { + module_put(flb->ops->owner); return err; + } private->outgoing.data =3D args.data; private->outgoing.obj =3D args.obj; } @@ -146,6 +151,7 @@ static void luo_flb_file_unpreserve_one(struct liveupda= te_flb *flb) =20 private->outgoing.data =3D 0; private->outgoing.obj =3D NULL; + module_put(flb->ops->owner); } } } @@ -181,12 +187,17 @@ static int luo_flb_retrieve_one(struct liveupdate_flb= *flb) if (!found) return -ENOENT; =20 + if (!try_module_get(flb->ops->owner)) + return -ENODEV; + args.flb =3D flb; args.data =3D private->incoming.data; =20 err =3D flb->ops->retrieve(&args); - if (err) + if (err) { + module_put(flb->ops->owner); return err; + } =20 private->incoming.obj =3D args.obj; private->incoming.retrieved =3D true; @@ -237,6 +248,7 @@ static void luo_flb_file_finish_one(struct liveupdate_f= lb *flb) private->incoming.data =3D 0; private->incoming.obj =3D NULL; private->incoming.finished =3D true; + module_put(flb->ops->owner); } } } @@ -412,11 +424,6 @@ int liveupdate_register_flb(struct liveupdate_file_han= dler *fh, goto err_resume; } =20 - if (!try_module_get(flb->ops->owner)) { - err =3D -EAGAIN; - goto err_resume; - } - list_add_tail(&private->list, &luo_flb_global.list); luo_flb_global.count++; } @@ -493,12 +500,11 @@ int liveupdate_unregister_flb(struct liveupdate_file_= handler *fh, private->users--; /* * If this is the last file-handler with which we are registred, remove - * from the global list, and relese module reference. + * from the global list. */ if (!private->users) { list_del_init(&private->list); luo_flb_global.count--; - module_put(flb->ops->owner); } =20 up_write(&luo_register_rwlock); @@ -527,7 +533,8 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, * * Return: 0 on success, or a negative errno on failure. -ENODATA means no * incoming FLB data, -ENOENT means specific flb not found in the incoming - * data, and -EOPNOTSUPP when live update is disabled or not configured. + * data, -ENODEV if the FLB's module is unloading, and -EOPNOTSUPP when + * live update is disabled or not configured. */ int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp) { --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (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 2CB4D37107F for ; Fri, 27 Mar 2026 03:33:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582425; cv=none; b=ihiQEx6m6kYxtSJOna4wgOeEcPHyxdPicnYMnh/mU5H2Nw5by0wga/I1vs8FjOLyLYpUtlrDkqEM6yitWwkxjMojohF18I1XhFU8cw1zEUnsAUUZTgxOukVGMoKFR1rrCqoR8Kbg+5NOjPA3znfM5R8+fn1sbVBtENTBwRRba+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582425; c=relaxed/simple; bh=DVzMDiusTWfIH5k52/TGAUQTcdsUmO8OJS5Og/rLrts=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UUfHISMPjyu8sTWJASMOqdyti7zYe0mboy1hREKpIkMwbaMKAPVqQDGpvxDJ97C4s7U4RdVlymKm6dO+4kDlfjKSWfHsAlwqwx4dq75mW2t/O/SXTZZQb+DPqmmLv65oHBhl16Ee12M9/4Pw8oJFGl/VUakMxMmY3H098/yWM9E= 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=CYa9fesc; arc=none smtp.client-ip=209.85.219.52 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="CYa9fesc" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-89a1d7cc7f0so14216516d6.1 for ; Thu, 26 Mar 2026 20:33:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582423; x=1775187223; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Mszalggt3dPTMibHtCmbJKEiDYjehfwuxFzG9yJXx/o=; b=CYa9fescwmItJkSyeZhKmAI7dtoVLCgB6BM0oMkBh/cxF5eLOhHiS55fmLqUS+Fn/i 2F3yqkqHZGLG419ruu9STYTtoBWkOjqSVE1YHVl3pZb0PiGBBVT62+sBmk+lQLREft3+ ID9mfUqDIdPtbG0SE+xhr4ekqfuGdGf+bTOft7+wOZrmJ24fSx1vPSRQblxSgLv1axLa NlqMzKTqNoxKRCoszjXnMcJcIvc4y/Cz8RVkfJy/Hluu4OLCKdPdCi8W6DIpV9+MHfIs Y8U3MkzZyyk7OiSM36tjut1feFIUP2PlwmjGoOIRxm+uBcFfXfnFALCj/0cfeOxqEnKO vBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582423; x=1775187223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Mszalggt3dPTMibHtCmbJKEiDYjehfwuxFzG9yJXx/o=; b=S4bLRfEWN00C7GdCJYjfYB74xItUc3g/fPa9J49VKJJUo0dTvmw51e9DQ6pahZy6Hl IS94HCIgXSGY0ViJdlpyv0O7vOFqr69xM0Q2k+uXN9ynV5ulQZssZIWGE3NRe9JYeOZe 8rsygatSnoKGAuPVPatc2+U/9SKEDGwLk6NDJ4yqgxpgIaWyPU1Ev0Bw0C0PSCIjMsfe fDYFj82T2ko15s12jDyjO72oo7A7DFo3trEW1v1hu4ospN08Lvs6UXIDwkrdjqTwur3T +ZnDjg5KtLVWqepZsHJjpw1btK2yUCCUZEJ185s1Bj045IZVFS6MCfWLZ9FoT1vRJZ98 Dfww== X-Forwarded-Encrypted: i=1; AJvYcCWXgdUFkj0SNqCBoXOCrLc4jp23Pd04mKvXgDjXugsCGlbp5VW1enKpqKTXgibpYRPEK7L4+ZIbU3PT1xE=@vger.kernel.org X-Gm-Message-State: AOJu0Yz3JJO1sMT4Ke49sUTeNO6qiTaK2h6Nn8p2DzaH3qTvVg+SYn9W O8JyZYRx9773qoua+wOPSdCuAE0kOIx5AUCeRh17pvSDrORQ+AFx5+lR3QypGIo0YW8= X-Gm-Gg: ATEYQzxu/uItk6gS0tbAVzNq2SKi1313LFXfZZfy/yZjqRwV9M6GovEOv0M8DjSsWix XCaQBtb5V5hbghCnZJvdmhZCGe313WW7hAZE+BwYH+ec7haOQtMbzTImlbQSz9Xc/9CMdSmx66C 0Z0BDJ7GQVxMG3PfWoqdKP8hphPssbnZg3WU+qIVyqvvzoUtRPRqXh5pbU9EIkMqQmHtmWgQ4CN Wt4acMA8SFpJPoSd7GU43K179s9PlORfFHDLMQn9RZ4fAv26pFkkXCr+oA+rMV4TkiYtitrRMbY 2l/sz03kJK5fcP198yzR5fv04JSzsYr3r9zeZ9hbgVAjsp99dya63TofrCNVizbLaWSx+dwADMA LJRk51RtRdQ5OQjkUwbvXA4x7E4h+2N821dLi9L/tYpRC/84I/qSEz2uisS3ZXSDCB42yUi7oVi T6Y1VWqYgCaZp2aX6VICXIrvO2aPCp5kqwtx4SrLjyZzYwiqVNr7f/3jk40OfOEzwcyA== X-Received: by 2002:ad4:5c8b:0:b0:89c:55b1:c8dc with SMTP id 6a1803df08f44-89ce8d8a990mr11018426d6.21.1774582423081; Thu, 26 Mar 2026 20:33:43 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:42 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 06/10] liveupdate: Remove luo_session_quiesce() Date: Fri, 27 Mar 2026 03:33:30 +0000 Message-ID: <20260327033335.696621-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that FLB module references are handled dynamically during active sessions, we can safely remove the luo_session_quiesce() and luo_session_resume() mechanism. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) --- kernel/liveupdate/luo_file.c | 21 +----------- kernel/liveupdate/luo_flb.c | 59 ++++++-------------------------- kernel/liveupdate/luo_internal.h | 2 -- kernel/liveupdate/luo_session.c | 43 ----------------------- 4 files changed, 11 insertions(+), 114 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 4aea17a94b4f..439177c10723 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -847,14 +847,6 @@ int liveupdate_register_file_handler(struct liveupdate= _file_handler *fh) return -EINVAL; } =20 - /* - * Ensure the system is quiescent (no active sessions). - * This prevents registering new handlers while sessions are active or - * while deserialization is in progress. - */ - if (!luo_session_quiesce()) - return -EBUSY; - down_write(&luo_register_rwlock); /* Check for duplicate compatible strings */ list_private_for_each_entry(fh_iter, &luo_file_handler_list, list) { @@ -877,15 +869,12 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); up_write(&luo_register_rwlock); =20 - luo_session_resume(); - liveupdate_test_register(fh); =20 return 0; =20 err_unlock: up_write(&luo_register_rwlock); - luo_session_resume(); return err; } =20 @@ -897,14 +886,12 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) * reverses the operations of liveupdate_register_file_handler(). * * It ensures safe removal by checking that: - * No live update session is currently in progress. * No FLB registered with this file handler. * * If the unregistration fails, the internal test state is reverted. * * Return: 0 Success. -EOPNOTSUPP when live update is not enabled. -EBUSY = A live - * update is in progress, can't quiesce live update or FLB is registred wi= th - * this file handler. + * update is in progress, FLB is registred with this file handler. */ int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) { @@ -915,9 +902,6 @@ int liveupdate_unregister_file_handler(struct liveupdat= e_file_handler *fh) =20 liveupdate_test_unregister(fh); =20 - if (!luo_session_quiesce()) - goto err_register; - down_write(&luo_register_rwlock); if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) goto err_unlock; @@ -926,14 +910,11 @@ int liveupdate_unregister_file_handler(struct liveupd= ate_file_handler *fh) up_write(&luo_register_rwlock); =20 module_put(fh->ops->owner); - luo_session_resume(); =20 return 0; =20 err_unlock: up_write(&luo_register_rwlock); - luo_session_resume(); -err_register: liveupdate_test_register(fh); return err; } diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index ce28ce9b113e..ac6fa5b34b43 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -365,7 +365,6 @@ int liveupdate_register_flb(struct liveupdate_file_hand= ler *fh, struct luo_flb_link *link __free(kfree) =3D NULL; struct liveupdate_flb *gflb; struct luo_flb_link *iter; - int err; =20 if (!liveupdate_enabled()) return -EOPNOTSUPP; @@ -386,21 +385,12 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, if (!link) return -ENOMEM; =20 - /* - * Ensure the system is quiescent (no active sessions). - * This acts as a global lock for registration: no other thread can - * be in this section, and no sessions can be creating/using FDs. - */ - if (!luo_session_quiesce()) - return -EBUSY; - - down_write(&luo_register_rwlock); + guard(rwsem_write)(&luo_register_rwlock); =20 /* Check that this FLB is not already linked to this file handler */ - err =3D -EEXIST; list_for_each_entry(iter, flb_list, list) { if (iter->flb =3D=3D flb) - goto err_resume; + return -EEXIST; } =20 /* @@ -408,20 +398,16 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, * is registered */ if (!private->users) { - if (WARN_ON(!list_empty(&private->list))) { - err =3D -EINVAL; - goto err_resume; - } + if (WARN_ON(!list_empty(&private->list))) + return -EINVAL; =20 - if (luo_flb_global.count =3D=3D LUO_FLB_MAX) { - err =3D -ENOSPC; - goto err_resume; - } + if (luo_flb_global.count =3D=3D LUO_FLB_MAX) + return -ENOSPC; =20 /* Check that compatible string is unique in global list */ list_private_for_each_entry(gflb, &luo_flb_global.list, private.list) { if (!strcmp(gflb->compatible, flb->compatible)) - goto err_resume; + return -EEXIST; } =20 list_add_tail(&private->list, &luo_flb_global.list); @@ -432,15 +418,8 @@ int liveupdate_register_flb(struct liveupdate_file_han= dler *fh, private->users++; link->flb =3D flb; list_add_tail(&no_free_ptr(link)->list, flb_list); - up_write(&luo_register_rwlock); - luo_session_resume(); =20 return 0; - -err_resume: - up_write(&luo_register_rwlock); - luo_session_resume(); - return err; } =20 /** @@ -456,12 +435,9 @@ int liveupdate_register_flb(struct liveupdate_file_han= dler *fh, * the FLB is removed from the global registry and the reference to its * owner module (acquired during registration) is released. * - * Context: This function ensures the session is quiesced (no active FDs - * being created) during the update. It is typically called from a - * subsystem's module exit function. + * Context: It is typically called from a subsystem's module exit function. * Return: 0 on success. * -EOPNOTSUPP if live update is disabled. - * -EBUSY if the live update session is active and cannot be quies= ced. * -ENOENT if the FLB was not found in the file handler's list. */ int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, @@ -475,14 +451,7 @@ int liveupdate_unregister_flb(struct liveupdate_file_h= andler *fh, if (!liveupdate_enabled()) return -EOPNOTSUPP; =20 - /* - * Ensure the system is quiescent (no active sessions). - * This acts as a global lock for unregistration. - */ - if (!luo_session_quiesce()) - return -EBUSY; - - down_write(&luo_register_rwlock); + guard(rwsem_write)(&luo_register_rwlock); =20 /* Find and remove the link from the file handler's list */ list_for_each_entry(iter, flb_list, list) { @@ -495,7 +464,7 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, } =20 if (err) - goto err_resume; + return err; =20 private->users--; /* @@ -507,15 +476,7 @@ int liveupdate_unregister_flb(struct liveupdate_file_h= andler *fh, luo_flb_global.count--; } =20 - up_write(&luo_register_rwlock); - luo_session_resume(); - return 0; - -err_resume: - up_write(&luo_register_rwlock); - luo_session_resume(); - return err; } =20 /** diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_inter= nal.h index 4bfe00ac8866..40a011bdfa55 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -85,8 +85,6 @@ int __init luo_session_setup_outgoing(void *fdt); int __init luo_session_setup_incoming(void *fdt); int luo_session_serialize(void); int luo_session_deserialize(void); -bool luo_session_quiesce(void); -void luo_session_resume(void); =20 int luo_preserve_file(struct luo_file_set *file_set, u64 token, int fd); void luo_file_unpreserve_files(struct luo_file_set *file_set); diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index 8c76dece679b..a3327a28fc1f 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -607,46 +607,3 @@ int luo_session_serialize(void) return err; } =20 -/** - * luo_session_quiesce - Ensure no active sessions exist and lock session = lists. - * - * Acquires exclusive write locks on both incoming and outgoing session li= sts. - * It then validates no sessions exist in either list. - * - * This mechanism is used during file handler un/registration to ensure th= at no - * sessions are currently using the handler, and no new sessions can be cr= eated - * while un/registration is in progress. - * - * This prevents registering new handlers while sessions are active or - * while deserialization is in progress. - * - * Return: - * true - System is quiescent (0 sessions) and locked. - * false - Active sessions exist. The locks are released internally. - */ -bool luo_session_quiesce(void) -{ - down_write(&luo_session_global.incoming.rwsem); - down_write(&luo_session_global.outgoing.rwsem); - - if (luo_session_global.incoming.count || - luo_session_global.outgoing.count) { - up_write(&luo_session_global.outgoing.rwsem); - up_write(&luo_session_global.incoming.rwsem); - return false; - } - - return true; -} - -/** - * luo_session_resume - Unlock session lists and resume normal activity. - * - * Releases the exclusive locks acquired by a successful call to - * luo_session_quiesce(). - */ -void luo_session_resume(void) -{ - up_write(&luo_session_global.outgoing.rwsem); - up_write(&luo_session_global.incoming.rwsem); -} --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.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 40FC3371CF7 for ; Fri, 27 Mar 2026 03:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582426; cv=none; b=ryiGUCUI3ZclaDfKBgF2qVSfsMP8sTVMReUy67jFxe8RfudD2tr2QVfT5kYoZabtqerZn6mlsp0egunkvVxol55eOdyser3dCG1JmAZ6nkn3USHV/7s3RlO5dmMTDYlO47OcurXpWVOpJ0Bk2PV+YphGZkAMGb6YtdAsPAPM/r0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582426; c=relaxed/simple; bh=9il8OaDcAvon2AOA+eJCw8pVlaLGkkhR/Q6e2Bz/FSI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QgvoZ4rY9sPM7434HJWwUkDkITgUybpS3/lllxchMtqawhrbB+Tmp/iuhhGMgErOoifuXZuzmRb5qgyDh67QxKEidMoKICLOJIS7xd1C+iJ4BZ1vLfazpegK4F3R+xKdUrMe3pf3hr8HttP/insuNeDEYkc26HBtovAlsV1/o6c= 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=FeeUJAU+; arc=none smtp.client-ip=209.85.219.54 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="FeeUJAU+" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-89cab686a9bso12275996d6.2 for ; Thu, 26 Mar 2026 20:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582424; x=1775187224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3hDiA51qt4kdhGsAF/wtP6SU35I33186MYzANJAE0/8=; b=FeeUJAU+p5eW5VfD1e4pw5MuCIwDfpquL5jbOxUUEe1aGzRLogOHLxdqkvF0Fh+Tqc yYr7VO6w0AL35Vjw/eu7lmp6uWz1cD/akDr6ehdCAFE07TCZeuehQ0LhB9iTNXcMe5LV PVEO1R7BeHKOWjELltVt4mmRFWKSV51Hoz6gtaU7TxmlY+RglsFSPYTo5CERsjJ2eXdh MbUV4yO91ILocIDGgs8uQ6U4npcnkw+Ats4jIuJaL4uzuGeADsZ8+ZXLwycOXX+gtfzW Fjo8C8VCbpZY7+vy609MWquzAnHvpJcSB2eKH6qdR1/ciOQQQicAMvxQNgVpleOOUgqu UH2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582424; x=1775187224; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=3hDiA51qt4kdhGsAF/wtP6SU35I33186MYzANJAE0/8=; b=T1QuOVxORxHcqSWX2SI3PeMq7JKrS+V3YD2eS3c9dGEmsrIdz6Mqh6wSXvE8/p06/L 4AZf7BEqTChnlRMZ5b6Bqop+HLkftCKXSRgyKFdUg03ESe5leutcyJljX+wEGbRb1J0g B+KRjc1JblWndpLSYUujpAF8oQTgMXsUX0dB5rLCcVU/Sex14sbQmgeqLO45HCdLwHc2 R2U8P4Z0tLDwaH6XFJjunE5DEljRzRcgKA6nDs7RLpRv8eX1P7Y/o3g37VR0qvuA47IV zhXliYslT7W/brifeI7+Y6Y0tx9Oti3yXFoHLjT1/6PhgkOHaT4S8NP1IAP20kiHHZ2P ti9g== X-Forwarded-Encrypted: i=1; AJvYcCVB6Np+VqX+p9ucKLRbdxPlUZRRTgHv86hNFzgbP78aw+gRmx7bhpfb6FxqdvW+SuHHF4MDqLFgqVJVg10=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3S2o74cEVnuKO66lQhVgre8143fffgzf4RhRrbthCc52zoCre eX3FmbX4c+94bwwVl90F54Rat3YL+URWWzLPJQlP1EF3p1T18P7pnOZlSkg7TmgsoKU= X-Gm-Gg: ATEYQzwdO9DaU+zIyxcYgBLmt7sNQFn54ybVwU1M9ZDKI3/v+5Or/rqhffLoS6Ekb4E Zf7Ee2BAQCH4CXOn4y1/72mG5V/hrPL3VeiNoNj2PafKOGF/1Js3+fWe1SIr9DvDfDDKM6yzFwF 2OaKfVTvnXfA13RwBH3xaDo/93Nnx2PXwpVUN1IvHPKHjNq/lyuf/HkrIkfL8UP9bB5k+j33+cG p+PjqHVvwkeaMTldqW5rM/P8YRfvrQkS6txO4hpFF4jTdSubDQ5pA8a4uQTaiw31ll6EXjRUk3A uZwix6VMFeuxM1xIroRJM6c/WXKaVwXChBldYVYE8QQbaB3GhFKTfsQ7r4JhQssDbVv2gxwmlyX au5tjxS6v3cgG4tNSLFDSszgPXvSGjdsolXR5vaNC5reRl27a9GcRsUe9jQ+Qs9fIy228AM+OtE slhqA96zP3g2pGTXW6JbTEEDollKzatQGYzzahMP7udWmXVBxfgtY6aaRI3B2RTp5PIw== X-Received: by 2002:a05:6214:d4e:b0:899:ea9e:31c4 with SMTP id 6a1803df08f44-89ce8f6abe6mr11258026d6.51.1774582424185; Thu, 26 Mar 2026 20:33:44 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:43 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 07/10] liveupdate: Auto unregister FLBs on file handler unregistration Date: Fri, 27 Mar 2026 03:33:31 +0000 Message-ID: <20260327033335.696621-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" To ensure that unregistration is always successful and doesn't leave dangling resources, introduce auto-unregistration of FLBs: when a file handler is unregistered, all FLBs associated with it are automatically unregistered. Introduce a new helper luo_flb_unregister_all() which unregisters all FLBs linked to the given file handler. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 14 +----- kernel/liveupdate/luo_flb.c | 84 ++++++++++++++++++++++---------- kernel/liveupdate/luo_internal.h | 1 + 3 files changed, 60 insertions(+), 39 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 439177c10723..80f4e3b796a6 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -895,26 +895,16 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) */ int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) { - int err =3D -EBUSY; - if (!liveupdate_enabled()) return -EOPNOTSUPP; =20 liveupdate_test_unregister(fh); =20 - down_write(&luo_register_rwlock); - if (!list_empty(&ACCESS_PRIVATE(fh, flb_list))) - goto err_unlock; - + guard(rwsem_write)(&luo_register_rwlock); + luo_flb_unregister_all(fh); list_del(&ACCESS_PRIVATE(fh, list)); - up_write(&luo_register_rwlock); =20 module_put(fh->ops->owner); =20 return 0; - -err_unlock: - up_write(&luo_register_rwlock); - liveupdate_test_register(fh); - return err; } diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index ac6fa5b34b43..f8348138de70 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -335,6 +335,62 @@ void luo_flb_file_finish(struct liveupdate_file_handle= r *fh) luo_flb_file_finish_one(iter->flb); } =20 +static void luo_flb_unregister_one(struct liveupdate_file_handler *fh, + struct liveupdate_flb *flb) +{ + struct luo_flb_private *private =3D luo_flb_get_private(flb); + struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); + struct luo_flb_link *iter; + bool found =3D false; + + /* Find and remove the link from the file handler's list */ + list_for_each_entry(iter, flb_list, list) { + if (iter->flb =3D=3D flb) { + list_del(&iter->list); + kfree(iter); + found =3D true; + break; + } + } + + if (!found) { + pr_warn("Failed to unregister FLB '%s': not found in file handler '%s'\n= ", + flb->compatible, fh->compatible); + return; + } + + private->users--; + + /* + * If this is the last file-handler with which we are registred, remove + * from the global list. + */ + if (!private->users) { + list_del_init(&private->list); + luo_flb_global.count--; + } +} + +/** + * luo_flb_unregister_all - Unregister all FLBs associated with a file han= dler. + * @fh: The file handler whose FLBs should be unregistered. + * + * This function iterates through the list of FLBs associated with the giv= en + * file handler and unregisters them all one by one. + */ +void luo_flb_unregister_all(struct liveupdate_file_handler *fh) +{ + struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); + struct luo_flb_link *iter, *tmp; + + if (!liveupdate_enabled()) + return; + + lockdep_assert_held_write(&luo_register_rwlock); + list_for_each_entry_safe(iter, tmp, flb_list, list) + luo_flb_unregister_one(fh, iter->flb); +} + /** * liveupdate_register_flb - Associate an FLB with a file handler and regi= ster it globally. * @fh: The file handler that will now depend on the FLB. @@ -443,38 +499,12 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, struct liveupdate_flb *flb) { - struct luo_flb_private *private =3D luo_flb_get_private(flb); - struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); - struct luo_flb_link *iter; - int err =3D -ENOENT; - if (!liveupdate_enabled()) return -EOPNOTSUPP; =20 guard(rwsem_write)(&luo_register_rwlock); =20 - /* Find and remove the link from the file handler's list */ - list_for_each_entry(iter, flb_list, list) { - if (iter->flb =3D=3D flb) { - list_del(&iter->list); - kfree(iter); - err =3D 0; - break; - } - } - - if (err) - return err; - - private->users--; - /* - * If this is the last file-handler with which we are registred, remove - * from the global list. - */ - if (!private->users) { - list_del_init(&private->list); - luo_flb_global.count--; - } + luo_flb_unregister_one(fh, flb); =20 return 0; } diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_inter= nal.h index 40a011bdfa55..22f6901f89ed 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -103,6 +103,7 @@ void luo_file_set_destroy(struct luo_file_set *file_set= ); int luo_flb_file_preserve(struct liveupdate_file_handler *fh); void luo_flb_file_unpreserve(struct liveupdate_file_handler *fh); void luo_flb_file_finish(struct liveupdate_file_handler *fh); +void luo_flb_unregister_all(struct liveupdate_file_handler *fh); int __init luo_flb_setup_outgoing(void *fdt); int __init luo_flb_setup_incoming(void *fdt); void luo_flb_serialize(void); --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 4274D36E482 for ; Fri, 27 Mar 2026 03:33:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582427; cv=none; b=NA0LwwuHScuZ2r81s0xSL6JiK07E1x14A88qyfK0mddYbsvYO2Br3YW1YWTKgK6c1Me7H3ZICI0/+l+/7QIDpq4KiL7iVHwKRrAXOo8rc9mZcGkSYJbF8zvG/2RzLgDzB+ghM8YQakV8novnw/D278+d0W/NVgU9FEAGCXFnJ4Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582427; c=relaxed/simple; bh=LjXpqkYiGxW7fiDxc1dzv43YxCLmbxLGlu17w3TKrxs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KOLa8JoaOJs1b3cEAjwiJy9uUC0Ryp8QMb/aiotZ094OXI+oglcWjcSsGHyaOGE/OfHzEfKKtFPHbUHKeK48akFdjSQFvJERmRFRWTK6oB/EJovPrZpCH8pXeZTxy8JlCMuC4TFS9zh7y4CIw7hUSmWXL+L5/S/ATSCIQ1soCPo= 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=YIw0fafU; arc=none smtp.client-ip=209.85.219.45 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="YIw0fafU" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-89cc68655f8so18090886d6.0 for ; Thu, 26 Mar 2026 20:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582425; x=1775187225; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fJqonmTTst2Q8Xhofg58ZntO/52vNNR445BtBTCxCrY=; b=YIw0fafU0y87akFszOizD2wgloRz+RfRZDnNJc0H7wRHTUvzntFDjWkiXhYoMBXPzU 721pOBq9Y3OLmMrqrrggd/eGvYUHM/YVONgl9p6Bxh1RK3+XF3vanU6gmDZ+kEq0v7qM yL3Fjn0Ejf88xAYzHkTGjPxGfmd3ViELCsWM6wkWGvPTnSMv+9Ffj4WUWZAdEKPwCCPb Bds5kqs54wukHdLGjNzD9b4QKeVKgm+z0XQ+KUKoFpe0xqnPqWN4V2xyDHe7tdvXFDuw wdXDpVD+bo1piAqQr+jwB706uEtr1kt6EKfmYrgOolP3v0ggQ8kiKeIrBNkt7qkWw2nw AhEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582425; x=1775187225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=fJqonmTTst2Q8Xhofg58ZntO/52vNNR445BtBTCxCrY=; b=AhkHytptg5IgY67h9YG4wBl331zqZGQuIy7aqzXc35+dZmuMnRqjkeQ/VQi4x2jt48 ghLuCWa2K8/Seij/9NpZU6rf0n9sz86cUIFZEnygIfZgODzAK72dgJ+pg5HDX7FuVdwA 5X9AUns80uWbO7yreD689gmqJu44r9Lex8lL6/7HP8J88irOErjRuQgyjIi5hUJkoOik du6cjbyQpRdCKXLeXKz9yDytVJqsw79FDK7DvJKwok0Nns/44imhiloClGC6KN3Yxtaw F1MUgoj7++4mFIcVZd0ZsRFF8EkYr5+P0vBAlCpmkiXm93ZST8dykoOlOVy9+CGJtF3i 6YYA== X-Forwarded-Encrypted: i=1; AJvYcCWAMwDJMlqDl5prhBlWGYu4Ry7W48JeaMtnFpdMCERcs4yP/HGNPDtaxRe+X4e7fxOHYzPonKR9BrJE33A=@vger.kernel.org X-Gm-Message-State: AOJu0YykF72GBI9ojhf6s7xC/lIXSdt301qP0K/LxFe6tFGyAnXUR5iD sJKhW94JFPszO7gHg4FnbSxCqvXOXHoV06d7rFbwx6AJWuOg54hEGxilwTnEG9i8GDs= X-Gm-Gg: ATEYQzym+J6HcMdnLJ6kA+4Oi57hGRTMdYFTkx63j90MCQeWcO3TgxIIiJyVfkcbdri vr9FusYmLC7kj8mzVbiENn2kkBLf/nJf0Yf++3VLqW3f8bjyddV0/oXVCGRJLaojciFu7g6j8hJ i4rM0XtxaLKEQY3ZzoXLCoLcF6CpF8h6hBtUi2ebBZ6KC6VtevQhC4DQCFFAJ2y4gdZO3Awzftv KI6LmHfzVoZpacm8Z/oqyHEo+whUNmPnwJ1BRfuzpm7ZHgtqFxkxemAoqRbnR8vCsj2an5ThKIu +Wl63KlPJRCpr6RE+u8gn44K6/JY9pRw3Cse6JFloZHRw2WAcF4kcJZZYhhL/5sf/+G+wDhmWYf 7xM+WdIoNqWCORVtZqk+pR81srWTu2FZC+xVR9ZDGOaKqwH/p6HtFIPg1oCLVvwo3JMYHnvo58g 4r8dhdXJ1XVKHOcHsICw8DMath+35NzqKvbisqJZjrMphcInBuz521zqy6eNIdZ5PsNA== X-Received: by 2002:a05:6214:3d9a:b0:89c:7ba7:c081 with SMTP id 6a1803df08f44-89ce925f8c5mr8627426d6.25.1774582425218; Thu, 26 Mar 2026 20:33:45 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:44 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 08/10] liveupdate: Remove liveupdate_test_unregister() Date: Fri, 27 Mar 2026 03:33:32 +0000 Message-ID: <20260327033335.696621-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Now that file handler unregistration automatically unregisters all associated file handlers (FLBs), the liveupdate_test_unregister() function is no longer needed. Remove it along with its usages and declarations. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 2 -- kernel/liveupdate/luo_internal.h | 2 -- lib/tests/liveupdate.c | 18 ------------------ 3 files changed, 22 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 80f4e3b796a6..dd55e5e74d69 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -898,8 +898,6 @@ int liveupdate_unregister_file_handler(struct liveupdat= e_file_handler *fh) if (!liveupdate_enabled()) return -EOPNOTSUPP; =20 - liveupdate_test_unregister(fh); - guard(rwsem_write)(&luo_register_rwlock); luo_flb_unregister_all(fh); list_del(&ACCESS_PRIVATE(fh, list)); diff --git a/kernel/liveupdate/luo_internal.h b/kernel/liveupdate/luo_inter= nal.h index 22f6901f89ed..875844d7a41d 100644 --- a/kernel/liveupdate/luo_internal.h +++ b/kernel/liveupdate/luo_internal.h @@ -110,10 +110,8 @@ void luo_flb_serialize(void); =20 #ifdef CONFIG_LIVEUPDATE_TEST void liveupdate_test_register(struct liveupdate_file_handler *fh); -void liveupdate_test_unregister(struct liveupdate_file_handler *fh); #else static inline void liveupdate_test_register(struct liveupdate_file_handler= *fh) { } -static inline void liveupdate_test_unregister(struct liveupdate_file_handl= er *fh) { } #endif =20 #endif /* _LINUX_LUO_INTERNAL_H */ diff --git a/lib/tests/liveupdate.c b/lib/tests/liveupdate.c index 496d6ef91a30..e4b0ecbee32f 100644 --- a/lib/tests/liveupdate.c +++ b/lib/tests/liveupdate.c @@ -135,24 +135,6 @@ void liveupdate_test_register(struct liveupdate_file_h= andler *fh) TEST_NFLBS, fh->compatible); } =20 -void liveupdate_test_unregister(struct liveupdate_file_handler *fh) -{ - int err, i; - - for (i =3D 0; i < TEST_NFLBS; i++) { - struct liveupdate_flb *flb =3D &test_flbs[i]; - - err =3D liveupdate_unregister_flb(fh, flb); - if (err) { - pr_err("Failed to unregister %s %pe\n", - flb->compatible, ERR_PTR(err)); - } - } - - pr_info("Unregistered %d FLBs from file handler: [%s]\n", - TEST_NFLBS, fh->compatible); -} - MODULE_LICENSE("GPL"); MODULE_AUTHOR("Pasha Tatashin "); MODULE_DESCRIPTION("In-kernel test for LUO mechanism"); --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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 1E6722F0C7E for ; Fri, 27 Mar 2026 03:33:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582429; cv=none; b=Xbu65buC1DDVgZfA3FFfL4grtCH26ZozbUq/Pv/2zMoE+58YO8vaSkpkf4CkVgE5KYZM/OajGCzvHrM+/pOhdfIUdK8BERJH5qifPMAjPC4a01VbKn6J0s8WDjUNziRTt04VmWLs3Hk3V7Ie+Kh0Qh2jc3LStAm/0h3hppH86ik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582429; c=relaxed/simple; bh=KiVRPvd/rzk48at/tBiksGzO/I9lEBzYmy5ywXyMb+k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U3Lt7aFV7KmBZ/LNPHuTMbYuWzwn5bbz6fxWfD7Jtt9HUD1evqfDNe5/HUxvntKV4r/h9PiuM6P97aLtjg2RgkWgS+wAQpyurhMfI/Y2+v5fnff9PezZLOi0MDvJUyt4m1ysQQ63dejSh7HNt/I1mYyAKr7iY8YdCte6h6yoyPw= 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=Ej0vPuKv; arc=none smtp.client-ip=209.85.219.42 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="Ej0vPuKv" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-89c5446f3caso20519046d6.2 for ; Thu, 26 Mar 2026 20:33:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582427; x=1775187227; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=niK9b97p+Uodq6B81NUl3qD7iaGbf0m6LGlP3YYxUso=; b=Ej0vPuKvMp30aTlGRFqbRKIOLcN5Z45A7as5KR/nejhIV4d+/3x6OEY2PygNZHpI8E bt6g3BDSv/1u7MDZtsIl34YWlaKE9nBVl9v1Mf4tLbfRaZzULqK7pKnrpjW5cvdW0JaA RLr4okz2oeJM9bmVCHV9VFeX0recsM0EPKYAaoikDMOsPaQVTD8SyzeIz5nirhGtMUhq IhJ9RhflGj8Dg571E4xVoWo2PqWAisEePuHc43GxZNzKslhFpaESqbUnJzJ9bIFJyA2B Vd6hNyTT2+lqHBnqpc68yVdUlZtoW8JtybjO7EyUzlCrur7b5o9LNseOvBwxol03mZun 8l6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582427; x=1775187227; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=niK9b97p+Uodq6B81NUl3qD7iaGbf0m6LGlP3YYxUso=; b=JDKPhQ9pzcVFF4kDPdVtufDkueNO7CKD9D80k4K+VeF3lVQnkDjph77FJ8Z7IY//JX SZbKeZZX09JEghNA58nRLD1PQkm7D2YY+OMzc1FKD/eGeNh10/eimeFyr90+kqlYM3Vq SL8IYqJ8T7vRiXTWtkt1NEES2P10sQ9UCls8SOUDwaGynVuQe8juB7DKvgTDnHUfcu5G rHGtng3/7MIccRgcnqcWrrk+IZ4vN4zVsnVlEJ6qavpeNDDjEPykNjjQTiVawRL2UtDb WJ3c/fvBiPMfnryU+uJZJ9o8E25rlu8vOx8yvzumXWWrtnV4bX5492ZzHMSKpa8FS7i0 v/Uw== X-Forwarded-Encrypted: i=1; AJvYcCWTt0/Xosn4sR35A2DkAgHHCyq7Gu6/19HN/or4mjjqItIioRq7tzG7Uh56/UDcIOBcqPQVGXJ9Xkcg3YM=@vger.kernel.org X-Gm-Message-State: AOJu0YzC71OpTyMapRzWRDQBpkPONyWBvMS0y+1q+wSSMQSyLnDbsGga nPnbG655Rh0FhykbhElGl0TkFbEfYAKZPvawR/JOEoEL0lHomeNC9OFrQRN1Kn3bmy3RgezVTcI sUUgL X-Gm-Gg: ATEYQzxdUKzYJFKAKCynopHrTuvoSpbuGnnCdDIq3WAbMZBp2IU99lVrpdqsKqsFCD3 GLaatXz8M6oM/xhXz6STC4swGf+SxKMUejA76yhug3P7XHKaBZKSWqCNeNfTUaVn50Yl0WKjGl0 BgobzKX/gAfuNSrqL+OmNnkG/YiuMYRSUWZSKlaocSAi/w9vsOEsXqN+mfoWXKQFEkgwiuPs5jE p0tA0ZRM5ao5kikGnj+w1iXWA36Lt6KTMm0vW+xqSETfteM6/6UsHV831307d0fQS0DVnfEC5cw 6zbXNPtOhCtw67IUIvoiK02vtoRMbVNbW2Og7ZsovBwvXmM8QQhh2jP3zCDbJosfbT3YdWeRb6L ikx8NsJqlbkdglE767T2dJ8DOvT3rMvrpkeDinS0kePwRB0cBB3lbjstAYr3dfAZ8NVezo6dNDe Z2DmBGD6CmkHdAblagD5oEL0Jbgcr6fIVUM7YzQJ0+0gAw3hzWtSF1E4POLkf7BzhWRQ== X-Received: by 2002:a05:6214:2b0b:b0:89c:d592:3a97 with SMTP id 6a1803df08f44-89ce8ee0c69mr11196086d6.30.1774582426820; Thu, 26 Mar 2026 20:33:46 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:46 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 09/10] liveupdate: Make unregister functions return void Date: Fri, 27 Mar 2026 03:33:33 +0000 Message-ID: <20260327033335.696621-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Change liveupdate_unregister_file_handler and liveupdate_unregister_flb to return void instead of an error code. This follows the design principle that unregistration during module unload should not fail, as the unload cannot be stopped at that point. Signed-off-by: Pasha Tatashin --- include/linux/liveupdate.h | 14 ++++++-------- kernel/liveupdate/luo_file.c | 14 ++------------ kernel/liveupdate/luo_flb.c | 11 +++-------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index 73ca84de3eae..2ae27711ac41 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -229,12 +229,12 @@ bool liveupdate_enabled(void); int liveupdate_reboot(void); =20 int liveupdate_register_file_handler(struct liveupdate_file_handler *fh); -int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh); +void liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh= ); =20 int liveupdate_register_flb(struct liveupdate_file_handler *fh, struct liveupdate_flb *flb); -int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, - struct liveupdate_flb *flb); +void liveupdate_unregister_flb(struct liveupdate_file_handler *fh, + struct liveupdate_flb *flb); =20 int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, void **objp); int liveupdate_flb_get_outgoing(struct liveupdate_flb *flb, void **objp); @@ -256,9 +256,8 @@ static inline int liveupdate_register_file_handler(stru= ct liveupdate_file_handle return -EOPNOTSUPP; } =20 -static inline int liveupdate_unregister_file_handler(struct liveupdate_fil= e_handler *fh) +static inline void liveupdate_unregister_file_handler(struct liveupdate_fi= le_handler *fh) { - return -EOPNOTSUPP; } =20 static inline int liveupdate_register_flb(struct liveupdate_file_handler *= fh, @@ -267,10 +266,9 @@ static inline int liveupdate_register_flb(struct liveu= pdate_file_handler *fh, return -EOPNOTSUPP; } =20 -static inline int liveupdate_unregister_flb(struct liveupdate_file_handler= *fh, - struct liveupdate_flb *flb) +static inline void liveupdate_unregister_flb(struct liveupdate_file_handle= r *fh, + struct liveupdate_flb *flb) { - return -EOPNOTSUPP; } =20 static inline int liveupdate_flb_get_incoming(struct liveupdate_flb *flb, diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index dd55e5e74d69..761e8f7cfc82 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -884,25 +884,15 @@ int liveupdate_register_file_handler(struct liveupdat= e_file_handler *fh) * * Unregisters the file handler from the liveupdate core. This function * reverses the operations of liveupdate_register_file_handler(). - * - * It ensures safe removal by checking that: - * No FLB registered with this file handler. - * - * If the unregistration fails, the internal test state is reverted. - * - * Return: 0 Success. -EOPNOTSUPP when live update is not enabled. -EBUSY = A live - * update is in progress, FLB is registred with this file handler. */ -int liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) +void liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh) { if (!liveupdate_enabled()) - return -EOPNOTSUPP; + return; =20 guard(rwsem_write)(&luo_register_rwlock); luo_flb_unregister_all(fh); list_del(&ACCESS_PRIVATE(fh, list)); =20 module_put(fh->ops->owner); - - return 0; } diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index f8348138de70..8f3c9c63e320 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -492,21 +492,16 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, * owner module (acquired during registration) is released. * * Context: It is typically called from a subsystem's module exit function. - * Return: 0 on success. - * -EOPNOTSUPP if live update is disabled. - * -ENOENT if the FLB was not found in the file handler's list. */ -int liveupdate_unregister_flb(struct liveupdate_file_handler *fh, - struct liveupdate_flb *flb) +void liveupdate_unregister_flb(struct liveupdate_file_handler *fh, + struct liveupdate_flb *flb) { if (!liveupdate_enabled()) - return -EOPNOTSUPP; + return; =20 guard(rwsem_write)(&luo_register_rwlock); =20 luo_flb_unregister_one(fh, flb); - - return 0; } =20 /** --=20 2.43.0 From nobody Thu Apr 2 17:06:04 2026 Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (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 ACA7B372ECB for ; Fri, 27 Mar 2026 03:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582430; cv=none; b=LcZ21Y1DB9FKDzwWRORtRpob6TAeC/aN8C1axRYeID08jD3juRViftIHAH07B9TPns598k0/jqwVtF+iD7OglpsP9G1PiYRGTyoOdz2e3827uzlvlIEkfIjMT+e/fbKPtBHC1fOJagnKpdCwZXs8H19xrWaU46ctxDuIJfF9ShU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582430; c=relaxed/simple; bh=WcC2Hz9QVrMKjrTl+widwmdAWiHB/PEv+vASN7Q3Lwc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dK5Yv82bdVtiZH6upZDbLvaiZF3u9Czf8fCi0IzSP9Sv6PL1myBxsK6deed99JNVqUg2sYsDWT68bhUNgCxsrVjm13mxjw7eo5py7585TsAa/jDjs+ftNgflR0y2krpWEHDJN/Q+Obx4agFu7veTE7SFS7pFmtky5nFVQQhslGw= 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=JL0trVau; arc=none smtp.client-ip=209.85.219.42 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="JL0trVau" Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-89a000f5adeso24218866d6.3 for ; Thu, 26 Mar 2026 20:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582428; x=1775187228; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=aADyeHO5XJu6ZrJPxM1LwlVH9QhmzTzIomzhTiemGHY=; b=JL0trVauCMkLusvwvcHJQqpdO/K1BXY29zRZq6SXu9PsSB1/fPOXUa5b4yTJTXhOrr 7kaDrtYOzotE2MRsTYPu+Ltw593ApkytH+oliKaoFgg2Esb+yCCzV3cBrEyUGxi5Rpb8 uzrSCJR03icO6AGu2rGrcUUgamflADG8sATbx+f2QDG595ar49LzbeLMOKsGDrGkQ/pf oWif9ShKKRVUXxSKcYuabVFKb5ghMa6cw32o/fORBSBfoylgjVmvbBYN2zcT1dpuDwpk AzZE5oJriUroR0cjU+akSET/vWAkdYi+2nJ8A1lwFbXR5IK3hQeAG4qIpeaa7TQMLw1K rovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582428; x=1775187228; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=aADyeHO5XJu6ZrJPxM1LwlVH9QhmzTzIomzhTiemGHY=; b=TDyJ0t5LmsPpheL/lPMlAu6NT1tLKVbykK6A8le8yrLr7+qhT3OpNbYp5NXeaCvzkV K6qwMI2h4dveUpDP8v5hOq3qow4TE3idTGyvd9CwrEvEQv5Jc0hLzCqB3OdQHKqOc+Wt zGbuR2ffFFWpYok5EXt4UDYO9bT0vS4gQNFgEyuZXwynF6chRdkR1JJDS2f23P10DcJb lGVibzki4X9otpTcYjh/0mXSWetklXeruWaAhSHTUzFD+1RH1zrqqO988z+q44/fM7ez FRuOx8iqz1px3qZMfInK0u1q7bYwsmx2eJWjQyBh678GHNGmeGpCXzum+nLbK6AwfxWZ glyA== X-Forwarded-Encrypted: i=1; AJvYcCVjngUZ/v6InW8xc81BCzggDZNSCCHqM7dsldxJk3erxciJkOwDo6u0OWNGmxeKz10MmZUw795JwYLCLok=@vger.kernel.org X-Gm-Message-State: AOJu0YycqjmMVgfGh8QTiMpBL8vncbSGIvgpt7QTTl8RkXcHRQjT+aOM NCkWolhbPodPHcJnzB1vTDBacLBOscCoMfA30Aay6xAP/BFzj2047YkDraxCB4rHNWU= X-Gm-Gg: ATEYQzznoUNaZhopWzj8xeLlYkk9+BTczgqZTpwX9kIp4emet4B/Ai6uaWlIE/QaZgw SRqPC/bzvFTAadsxG8JVuwia5POATloBuYtXevRekWTMgjrdmW+zd4SYgXEfgAN/BiFCnCgVsOE sF0TfjvhpQTzmshpLmUi5IrQcGDzgkukinkf9KFrbi2HWLq+gDQF1nGesFZVfQDavzgis4CimKb t9liIKEzIXc1O6hvDrkWS55z753XKXV7fXH42ec3MFUTK5qXKqt+p3ck/mo4OGFY9GIYdJx8H65 wXAlMTlZXksIgMWSSaPPrUBDxFkN5WHGRqLq5gE4L1dNasSWLvMpz0vnUbWVcB5lqhYsGm215Pm /UjKCCHUlW6dhB39hp9/vWRFDxy8yIKGCmf7GD+I6yYs6nHv285eybyiK3E02xAAq48AXXGWsjr e9xnIXls9YURnnIB1fwbEMR10hRAd9mrTAFx9lg9Qejc0YYQN4rwgP9oicSyqn0Jw6UQ== X-Received: by 2002:a05:6214:4842:b0:89c:c685:f52d with SMTP id 6a1803df08f44-89ce8d2fb33mr10795416d6.15.1774582427783; Thu, 26 Mar 2026 20:33:47 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:47 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 10/10] liveupdate: Defer file handler module refcounting to active sessions Date: Fri, 27 Mar 2026 03:33:34 +0000 Message-ID: <20260327033335.696621-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Stop pinning modules indefinitely upon file handler registration. Instead, dynamically increment the module reference count only when a live update session actively uses the file handler (e.g., during preservation or deserialization), and release it when the session ends. This allows modules providing live update handlers to be gracefully unloaded when no live update is in progress. Signed-off-by: Pasha Tatashin --- kernel/liveupdate/luo_file.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 761e8f7cfc82..619465358798 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -280,7 +280,8 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) down_read(&luo_register_rwlock); list_private_for_each_entry(fh, &luo_file_handler_list, list) { if (fh->ops->can_preserve(fh, file)) { - err =3D 0; + if (try_module_get(fh->ops->owner)) + err =3D 0; break; } } @@ -292,7 +293,7 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) =20 err =3D luo_flb_file_preserve(fh); if (err) - goto err_free_files_mem; + goto err_module_put; =20 luo_file =3D kzalloc_obj(*luo_file); if (!luo_file) { @@ -322,6 +323,8 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) kfree(luo_file); err_flb_unpreserve: luo_flb_file_unpreserve(fh); +err_module_put: + module_put(fh->ops->owner); err_free_files_mem: luo_free_files_mem(file_set); err_fput: @@ -364,6 +367,7 @@ void luo_file_unpreserve_files(struct luo_file_set *fil= e_set) args.private_data =3D luo_file->private_data; luo_file->fh->ops->unpreserve(&args); luo_flb_file_unpreserve(luo_file->fh); + module_put(luo_file->fh->ops->owner); =20 list_del(&luo_file->list); file_set->count--; @@ -648,6 +652,7 @@ static void luo_file_finish_one(struct luo_file_set *fi= le_set, =20 luo_file->fh->ops->finish(&args); luo_flb_file_finish(luo_file->fh); + module_put(luo_file->fh->ops->owner); } =20 /** @@ -782,7 +787,8 @@ int luo_file_deserialize(struct luo_file_set *file_set, down_read(&luo_register_rwlock); list_private_for_each_entry(fh, &luo_file_handler_list, list) { if (!strcmp(fh->compatible, file_ser[i].compatible)) { - handler_found =3D true; + if (try_module_get(fh->ops->owner)) + handler_found =3D true; break; } } @@ -796,8 +802,10 @@ int luo_file_deserialize(struct luo_file_set *file_set, } =20 luo_file =3D kzalloc_obj(*luo_file); - if (!luo_file) + if (!luo_file) { + module_put(fh->ops->owner); return -ENOMEM; + } =20 luo_file->fh =3D fh; luo_file->file =3D NULL; @@ -858,12 +866,6 @@ int liveupdate_register_file_handler(struct liveupdate= _file_handler *fh) } } =20 - /* Pin the module implementing the handler */ - if (!try_module_get(fh->ops->owner)) { - err =3D -EAGAIN; - goto err_unlock; - } - INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, flb_list)); INIT_LIST_HEAD(&ACCESS_PRIVATE(fh, list)); list_add_tail(&ACCESS_PRIVATE(fh, list), &luo_file_handler_list); @@ -893,6 +895,4 @@ void liveupdate_unregister_file_handler(struct liveupda= te_file_handler *fh) guard(rwsem_write)(&luo_register_rwlock); luo_flb_unregister_all(fh); list_del(&ACCESS_PRIVATE(fh, list)); - - module_put(fh->ops->owner); } --=20 2.43.0