From nobody Thu Jun 11 21:37:02 2026 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 9366C34DB41 for ; Mon, 13 Apr 2026 18:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106292; cv=none; b=HgBYDkR3+DS9+DWuTO4ZwR3lo3gONs2RV1726mmX00ci8U7EfgNy3o/TTRsk6TYafKF/uIWVZQkhPjiZiDXHjHPcvbgL511LJ8jT6onzXlo5AlaiSBrM/tHcw5JTII175Iuiy1dR3Tn7beEwMLRN8gUlSdyUptF2yNunfd5e67c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106292; c=relaxed/simple; bh=serIL9j4qbLJFwH7OPVqv5OIg9Xe6Ycal166G/HAGbk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FoKp7zyNI4nUeAA4ICDkyPbduSdOVxfM6V5nP6dE0gASXl394nLC/qd0z3I7ckqGVPRKFHUvTKLGKfng5ML0U8F+OLEOO7DAiTsjIjpcZyG1/Imn2LeAQlNzS8JT1qATEuJq8PSzZcfcdop0P+wIwORd3VE/hmD1kMEf8cNPOFM= 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=Q58dby7q; arc=none smtp.client-ip=209.85.222.182 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="Q58dby7q" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-8cbb6d5f780so417804985a.1 for ; Mon, 13 Apr 2026 11:51:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106290; x=1776711090; 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=8pD98uNJoq0iIfAL/ef2oCcGmXF7EEZvJYI/x8l5WNI=; b=Q58dby7qWRP7V7V/r/pdHOMCUuH0h6zOG2gi26IZ3OALPpKVdMdwQ0isDsihel94Dl MTkXoASz+BEgz8lJu2/OaZPzxO22/NThHu+0aUqgNHINuDXBuTOmMfj9cvWJsfO2r64V PGplobK5wsTXxyHMtYqU7FFFHgwRYdX6YT2Qk+dXtdYnmhqa09EoxzunraI4WmhBXEGu S26avzidbBXE6qtBjI7C8LxGMW4zxHp/Hl8iMGxcfw1dBmDePgOQrdRyAf5X0oTS7n9v PlG52JNzCkPjObEKlLJrvClK+SpzHWPq4a73wUTpX77uLgbgI3OCInvpiJyfQjQsc81x Ogjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106290; x=1776711090; 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=8pD98uNJoq0iIfAL/ef2oCcGmXF7EEZvJYI/x8l5WNI=; b=Ah2WFOIHW1uJjWZ5K6eOf3crAfvAuzxapTocLlheptZ4d1unG6Uu7ch3/5smnEfpqO sbC2qZYfJGcwKUQT5AI9+JGT6dC0wsP7udZEoImGwsCgW656CkfUqGe1G13E/Fdd2P46 0qzNKKi0Vj2rzO0NBc1k/a8KQwItPSjSatfUN6d4dw/Cads7cOIi2Quh2yVEIaqgoc9/ m5YS6a7ZP1ukL6QCv4rwjVci/1VUSdTx6fb0iE1nCyTf6sx3jkzEcoT1VQWi7vXg1i8p Q4FyX6PqYvjLFqBY54fxmzkzyz7i2M5ux2QUIIHSBKeDUbbvAK87lO+usgJ8UVlB1KB+ EPUA== X-Forwarded-Encrypted: i=1; AFNElJ/IYKiWqLQ8YQNn/r6damHgriQELLkr12aOA3CF7pajJJsKSRvGRHfvRBA0NfCWEGyaGnSK+xDmyEisDCY=@vger.kernel.org X-Gm-Message-State: AOJu0YzvZ4H0SZQ9vYXXHQpi615rKavbUqh+JF61hGlGDkeFyJnk/myE V6q6lbHDow6w+IZi3+WB3Qz4QSkNo8+abMBSGKBufBxY9hBuDtGjyUmrdUbNF7huZ+g= X-Gm-Gg: AeBDiesa+vvEmckasJREIgLUfPYkvI/kDENr3k9yqGi+n2QWOApzxTd7jGas6LTjemc hs2xbJ7B2/hOtALELRteiCKIIgRqAFRn9ouEZcXqmZCJILpoCfUYlyd1xewF9xLYmHOezYrs74X vOESN9QDc9h5iVmbc/QzvtnD1EzNs+TD83Q0wQidzBuMXYCu9aaaQAAJtW5MKEPpAihXghnWmTH jfwioftBR8ixE8MM+Pm5bHSHn6SRR0iQM1CYh4w689r5cn3UBwkXeVOoWrZ7rxmOdqoUPBkhzGe E7DMOzHp/RuTUsax9ko0NRxiZW1A23TyLReYQpET0K8vldrC6uAhTi6ddNZsfBVH0MxrLkWjK+s GugPB1G0oN/ykfWz2uKpmYgPQlv9hfwaAZ9JKoiOelrLQdrpoLYb6afOEBiGKpB5wxKZko8Ztxf saQGfQsbyPE0ROFWc9skT3qPugVXHWVyjVfiN5YMzBCJpkVUwCG4BxQieNWgS4dNIxEQ== X-Received: by 2002:a05:620a:2585:b0:8dd:7919:153d with SMTP id af79cd13be357-8ddcd1195c1mr2060705885a.7.1776106290475; Mon, 13 Apr 2026 11:51:30 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51:29 -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 v4 01/11] liveupdate: Safely print untrusted strings Date: Mon, 13 Apr 2026 18:51:17 +0000 Message-ID: <20260413185127.128180-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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. 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) Reviewed-by: Mike Rapoport (Microsoft) --- 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 09103cf81107..8fcf302c73b6 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -813,7 +813,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 0B454390227 for ; Mon, 13 Apr 2026 18:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106294; cv=none; b=WypxxTFFziV3LaE2dKLcexRv7lOOCgffcwLzg5QfmKNfBAGasfjn76EeYohiUyE+T/44Ac92BTPKRo/q69AJFjOSg+0ySLMifgu07UeDPFzazTA/KDCgqey7qzKUnGZ0tfEygY0p8gzY+Qt4YOayoGyC1QtGUKgaOiUbV+e/jvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106294; c=relaxed/simple; bh=ww3USAhmbTCZpVUCrF6lvEU27MAC2BCHimBru0YESVI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SkLNjqzYMT5m07E1D2igc1ub+yhMdFNPE06xsk8351otM4q4s3ZYPSOkLF6ZupmcW+pa3ATkzMGWv0k/9GDQcI6d46tyd2UsLTsLeTB6RbWwB/X7QyPCMXsKYnq5aM5a3X8z1+P7FzPozqPU90tGAHiMISNQCvnAjVJcqPoq/8w= 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=PJabx1WO; arc=none smtp.client-ip=209.85.222.180 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="PJabx1WO" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8c70b5594f4so467303085a.1 for ; Mon, 13 Apr 2026 11:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106292; x=1776711092; 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=O5pBgT0tZYU/wHSJl6Q7z5nPOqIISujBps3y+cjKycw=; b=PJabx1WOsEMt6zDSIaTnGkQTFUvphOZdXaC3iJFoxcANMvfTwNQetPRO4cospVBctQ P0J/NOqVXF5yGIuDQFqzdbKx5YsJqWBa98fuT2H2MW/BFMB6B671UtZG8RRJhY7VDnAG Q+5F5NmxyqS2heg3uTJSqHrFE1cZ+jh7YwMgZ+4zNdWYuuKPe4GyA5+wG7ej+zici2SQ vmssqyAjSZpl3nU6VwFEkIyVd9bCP1xJLFt8V2lyOCcNz5vssO11sugzCjgWVFis4pYM XQZu7qo4WDQyJAEuZadgvDqF8Y5fKeSx3J1eGp+QBpTQixnBTMsp0Wap9ghkh8wI5ZJm CgRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106292; x=1776711092; 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=O5pBgT0tZYU/wHSJl6Q7z5nPOqIISujBps3y+cjKycw=; b=hH0KAJHzgfK0CGPZpIwSrMfSZ4FfrMYUcEt/aLWVy0Q5pnjaQyu+4oJ5xaI12/x/n0 zPE0pXWDzVc9yJMYCXoGE38GWSEoQsXxyfrTBSG9Jn6QdpeApGHJhlUfJxoe90Tz88UH TWrBLY7QSGdRo8CIQrXLe01POPKVFF7ysPOohxkALfzaBBMt9bsqIyAXjqsO7nYjuh0t Dmq8AIcobwF+WN6wD7JfDwn+RF4gfmW4MgfTR4QNHCOO0HPci2lHmsKNTPGKRkloizIb NleuxxJAXMCj1bwtWrBRUzeJLYh83hro0uz03TODihL10ofzgqHQOuCakByE3KamIkd/ pxGg== X-Forwarded-Encrypted: i=1; AFNElJ89Cg3WmzpV+eIg8dlN7fNmlVLucT+F+F+h6FirKOCmQ2lDR3e/jJfil3iyNJu8O7ebDe6O8lo5mGdjcjY=@vger.kernel.org X-Gm-Message-State: AOJu0YyOTcr54nAzY/gxFwOd3Esqo1igqqVe2jW5iSX/O5ksqTCKpdal ICGdWI8FGe1ZVDHbaFXFjMp7Uf5LZlFIcvR2dNX1X9tCcntEXSLiIn5Y3FESZFvY1xY= X-Gm-Gg: AeBDiesH0slmy/UjcuT8sGQ+kNvfsh/iPgyjnIWZVGIH5Df3UOZBPs8Ugy7G8MThKbl Ldoj9fxGugcunhN0hcS50S5KhAfl5VrWrqvUQP2b4EBzAWun0R8tBCqPfaqUB9Rd+4Seqie8fV1 J9TeNuMmBilKyG/kR2lkC7SVgIXRKzOUIqrMIvA6mn6qjxLSK2vp1FUmdsPVawoVuqAaXNxjwWy Enxf/bBPYumCRCQdBjtK6cSjBAxVsFyNHGKLIGwxhzXxSEgmU6Tn8hX4ItoS4A9Gn1ksE0HOhJg vmtQeNeDFftWcr04AnYLQJkUw4afH8w/FVnLqiNd8DEf2X0EWMmtWpnuPMfSezwHAla0ufm8dIN EtFgwAMwZlakp01L42Ys8Z2ozxBCF9U0I7I+HgaEzXhWjA6b2hbiNB8IQ3htTYGnkUqnR5o1jmR 7me8FcsTZWCg5tjtv5quvit0K1lKMliQUSf5P0EqArkLP9+f6O0rdn9xWBHKGGk+3JZg== X-Received: by 2002:a05:620a:c54:b0:8ca:3715:eea5 with SMTP id af79cd13be357-8dc444a9272mr2315610285a.14.1776106291953; Mon, 13 Apr 2026 11:51:31 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51:31 -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 v4 02/11] liveupdate: Synchronize lazy initialization of FLB private state Date: Mon, 13 Apr 2026 18:51:18 +0000 Message-ID: <20260413185127.128180-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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 (Google) Reviewed-by: Mike Rapoport (Microsoft) --- 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 f52e8114837e..cf4a8f854c83 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 Jun 11 21:37:02 2026 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (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 A2DB7390981 for ; Mon, 13 Apr 2026 18:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106296; cv=none; b=tZwWBQ0VJBa02dDFs5MqegNrhPNqfFIt69gvXNP3885nJByFAmCvxdcQicmlA8IarO9U5tySw+D0trKBoEPV+rSlXiyWJaV7usxft73duPPyNBpR6YsnnlcM5ler3eNJ8D6TO51lFShBRjpMsqfh3drcEw+D6382THjA37hRAU8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106296; c=relaxed/simple; bh=WDvvg4lnyHcWQZk6isSGE06LCxMeDIbIxtMFapW9K8k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uecZTDNUCP6C1D4VXEW+3wUQMAreyXQFdtOeLSRjfsWJZPAwox5NYIXmdL17WWqsshmx7BiMAYdHWzWTrh6abZ0eXkBvQ9PxsxJmqyyRnP5BOhwEV7BLtECxU9+FjMCr8v1nmDHTQTzqMKROctbh3AbgPpwswqSfr6iwHca7tQc= 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=MzuSoZqP; arc=none smtp.client-ip=209.85.222.174 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="MzuSoZqP" Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-8c6f21c2d81so359174085a.2 for ; Mon, 13 Apr 2026 11:51:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106294; x=1776711094; 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=waUYooNMPBQNAZcuPuj3TkxfF0rm3JDxq1HAEw9JCDI=; b=MzuSoZqPdWDKYdQmbQ49Cp1kJJ+X66zVvoKNuYdUVB0IL6X7aFrzGwI1zKkerZQZQ5 G6qk/3XeAs2EsgEyGmrxaiiZsqVkdrxjOU9b0sj1DlzdRdlP3V/PrR1Zq0MboNNO9r3A 8RhF/Bo74MGsWWwwA31W2WMC/wwRNXytmsIfMO1UTFjpYKecdIbxPezsfa2Y29+UYxeS iUsbSTE9o1sSXngtn+JeJcJugZDBkuV2TBNvI96WQil5HkQBHOKbFR7M/OQ7zP+f9w4U OUgkcuuOd1JVpmYjrtSw3jzxV66H65eykVEYcDa+dg4n4h4apv1icfX/m6lfm7DjGSQe IX4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106294; x=1776711094; 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=waUYooNMPBQNAZcuPuj3TkxfF0rm3JDxq1HAEw9JCDI=; b=QRfIWQ1OrJbR5fSvybLf/itKTqEcLg7hRoy/CKMZPCE8S8VlNb8REtE6w90tEK6+cN qF/yMhWAWYekIpACtx/g6qRpS1Bu3lqMYGmHzOCDNPDCIRyjECrzpQ2HQA6Zh8hcGqX/ s7de71z2wloN9XQFzTb9ZD804Xd109/70+ZFyOVJbeVWguOXzk4W7jZtgVvukJUKCbuD d55FWLF1STn/GQGSYbf/uXA5sWKZuTPsbFnWeNXAfH7tHVHvG1JZm4uY5bAvtzqyqEeP e4k58Duwt8xsp3NViNBZPPij9vgGhqfb24WlBkub1jTpZ/rElT+vpotWj404ABoo5lg+ PdBg== X-Forwarded-Encrypted: i=1; AFNElJ+sk/+T/UKQ6EmW/WBxHIZ8b3qU51JGGWsI/jeLsfGxhhsVO7Vu/CFuOwB0wBWuHSRaSU4YG/ocavlzpAM=@vger.kernel.org X-Gm-Message-State: AOJu0YzsLqpGUNYnK/ZWcUGHJTRdKINLNeFxvvc+2PuTshBv0RiiiXud h+Puyzg1FqvGa1jmzlZuqZ/ObIIJ4WAibwf4tgyuaRdoqfW8x6Jllvqjjx2iqa7Cq0k= X-Gm-Gg: AeBDietYXmcQewZftIKvDnoTYEaHhzDzWzPV9Bc0y46f3vEtqqIC6qtAlHsTEjTX0nx oCwVD3c8BTYie4uD+03HjQUFJ5sm3uuJyeWLOIIm5v2L2FTmE6LYftaJduIoknaiMxLn5zj0Olt aY2qMXqRJzJEH6v58FMHGoPavoLOTiMp5YbWWLvhcndg7fPbKAxO+bXvtKIcEblgFZuF4PAuvJN nikmGYonXy65X1V9r7YRWPhetJFU6LRPN4qv4D2Kvx153GbXwSRQ8F/FYSFMn0+l/0g+ni7rhOE cu6PgfC+ajOe0vbKp6rbkzFpG+QmXwbpLvwbYA467AqdGQwDkr8gCjor5Tn+0j7x2fDy3209i8Z G3WMOR1NuoldwIjZBRWhxTKF4QgpWuOmXIVsZD1S1Ht9kN2xUBfZdxV45QQBE87LqkHWWgqJBaK aP6SSadT3sJfv4tjEwVTfVq/AWIIiAB4D5t3u68TGSDM5Mx+gzhzSouUM4dYo+s/O2vw== X-Received: by 2002:a05:620a:468b:b0:8cf:da2d:d6d6 with SMTP id af79cd13be357-8ddcecbd97bmr2034499385a.36.1776106293502; Mon, 13 Apr 2026 11:51:33 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51:32 -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 v4 03/11] liveupdate: Protect file handler list with rwsem Date: Mon, 13 Apr 2026 18:51:19 +0000 Message-ID: <20260413185127.128180-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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) Reviewed-by: Mike Rapoport (Microsoft) --- kernel/liveupdate/luo_core.c | 6 ++++++ kernel/liveupdate/luo_file.c | 31 +++++++++++++++++++++++-------- kernel/liveupdate/luo_internal.h | 2 ++ 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/kernel/liveupdate/luo_core.c b/kernel/liveupdate/luo_core.c index 48b25c9abeda..803f51c84275 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 8fcf302c73b6..ecf780d74d80 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -18,9 +18,10 @@ * * Handler Registration: * Kernel modules responsible for a specific file type (e.g., memfd, vfio) - * register a &struct liveupdate_file_handler. This handler provides a set= of - * callbacks that LUO invokes at different stages of the update process, m= ost - * notably: + * register a &struct liveupdate_file_handler. The lifecycle of the regist= ered + * handler is expected to be bound to the lifecycle of the kernel module t= hat + * implements it. This handler provides a set of callbacks that LUO invoke= s at + * different stages of the update process, most notably: * * - can_preserve(): A lightweight check to determine if the handler is * compatible with a given 'struct file'. @@ -288,17 +289,20 @@ 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) goto err_free_files_mem; =20 + /* safe to use fh because its module is pinned */ err =3D xa_insert(&luo_preserved_files, luo_get_id(fh, file), file, GFP_KERNEL); if (err) @@ -805,12 +809,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", @@ -823,6 +829,7 @@ int luo_file_deserialize(struct luo_file_set *file_set, if (!luo_file) return -ENOMEM; =20 + /* safe to use fh because its module is pinned */ luo_file->fh =3D fh; luo_file->file =3D NULL; luo_file->serialized_data =3D file_ser[i].data; @@ -879,32 +886,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; } @@ -938,16 +949,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 1E98538B7D6 for ; Mon, 13 Apr 2026 18:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106299; cv=none; b=CdT3RP2EfdUq4DiL00lAiIJhAErec56/udyPFGJE1u/thLRAwlzkRqMYCipkBcQvzDkkJhw1O1NJQMHLABe3Tmp2+mgXn/Nbqzl92/GkzdiDFfflXEafVYEqdykQDOzBPs7iIqxMsxeXnr7uYiI2Vpro3ZzsmojkvHCW/dp0DrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106299; c=relaxed/simple; bh=oNxP1B3GSDmZPHbcad23jnnXAb3w3fJ6r/CwjMPCInU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dBLJkS0FhYcEK8pmUSAzzHBq/5g4fmJWRodRP72oz7Ueef6ax7plwpPkbp9baq71A266nfjx8buadgh42xpPxalUEJ/H1uZmEzR5C7bQpmNz0NBtrOJgH6ELYlScpQFdLPmvJQrQmZwe8SHQneTnPiGj2gntwfO6YuXCpJpgUXg= 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=D/ErVuLm; arc=none smtp.client-ip=209.85.222.180 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="D/ErVuLm" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-8cfd122d78fso653373485a.3 for ; Mon, 13 Apr 2026 11:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106295; x=1776711095; 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=s51LS+4jC7M5tW3ZiOQ9JQLKwRmBqtdDOu+VdfBPYzE=; b=D/ErVuLmlxKvCM+qmUZ/dX8t/tbvveNnjTpiJyXXqb1eaCyOntmUkFWmzoAlD92HkV tFHnWbQJ60MsRmhoWyJqhRe30J2Y41Scb54yJH21wduz0ybsIZWkusW5s2zxPIA4WHSb fEz21nhykHmMc2AFPc5eq5RlODlJWE/MW7DKz6SXCc9eNmBzsBtw4O+yBSri1nzdVYVD VxJJKy5nauJwLyIlSqQv90i/t75s4yixSIFqajwaHC9oComWo0LM8vYbOpEBj461e9Ec 36WJ9EcHSR4qpyGOfP/3ph9y1tXnc18t0hgzt6Ah3GLKMCRFyJUqmqhKTD37/ZtNSRdv C4Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106295; x=1776711095; 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=s51LS+4jC7M5tW3ZiOQ9JQLKwRmBqtdDOu+VdfBPYzE=; b=Yjs5HXRTlPSvjsXwKn0MVxMn/kAsCTUVIhkT4M+fmJf6BATCjCES59gS31A+jscBsP Fp6+EPTkET3LvDdy68wQaW+VVm4YQuGM3IIjGKaER23oTLslFQ3D6kSNwRNVXILp4GDR BHbb55dxVCfozUTsGgUBqtsPus1QKj4y7aa1VtNCA3ReQGfVH6gfD/nMdqHAjNmby+pu IdvZOAV/ctIOjkyglQvw9jyo42IANJ1LmHE15Uwt9WY7JCjMTpl89bXUK2saOBxBZiKd yk6MFXxKTw/w5QmTSnXwHLjZQWty44X15Crh1HqlXlEZCUWhiP337EsWI6GLWijiZe6z /4sQ== X-Forwarded-Encrypted: i=1; AFNElJ9FZQWcMC0WASsS9ZBGOrZTa5ztxXHGlW9Ks8GdAIHDRloP0p73QW8fupWJq372Nu4PHtYxa7wYLsCBBY8=@vger.kernel.org X-Gm-Message-State: AOJu0YxFVGFWZyb5s5Tou+QgQNJ71yxRZjmaHMtFzDzN3xcK8Pu7mSCR IiwO2q3bQD9zDKPgp+gCEFYcEY07rNdtxAwd4N2RI6+VxaQ53/Q1hBrUy3gnte2iQ+I= X-Gm-Gg: AeBDievxIwOmQGXqSRkNvn173XQwf6bKjaooN63U7mX602coTBYStF3BBGHLjGJ5065 XM8Vyt3vlzcfm5Etf23wNavtZhcg6iR91j6ujzP3/vDJJ7brrnroVAdl2nW37znnGyDACh10N73 rYCelcfZsKKhu0wwKWnYosZPu/OxqCsuF8tjs87bfeOJPyzPPE46ANe0Xh05gO5DgCq5PQ7ot+k 8DHOYazoy/BpF6EweWfTaHwmLhmi4SUN5fRdPDY+pky33cuWJcZrZkXHK+ifzuh0MsgG9vZM2+0 xwe4u+x3nfxjWfEVyB3EzVjVTqnjPQzO8P03TTQSQX1lIe3w8h6+k3N9Rpe8NH0uPPFZTtGAoz5 13blCzuK/Hp4mtPg0Law8rpjeGWfQVPq1x04nmRWtUM/X5txPO+8mT2KpqNGhDRq0BS5tKgeCHc vLvCObkRH7pbq/7yBY5Jywc2tmnHnppFv40CPnL6Cgz5gVlt35wHqTiIaBGDDQpQ+B+g== X-Received: by 2002:a05:620a:690f:b0:8cd:bffa:655 with SMTP id af79cd13be357-8ddcecbc94amr2252986585a.38.1776106295061; Mon, 13 Apr 2026 11:51:35 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51:34 -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 v4 04/11] liveupdate: Protect FLB lists with luo_register_rwlock Date: Mon, 13 Apr 2026 18:51:20 +0000 Message-ID: <20260413185127.128180-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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) Reviewed-by: Mike Rapoport (Microsoft) --- 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 61325ad26526..9c761d9bacf8 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 cf4a8f854c83..fdb274410e8f 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -245,17 +245,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; } @@ -277,6 +280,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); } @@ -297,6 +301,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); } @@ -360,6 +365,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) { @@ -401,11 +408,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; } @@ -449,6 +458,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) { @@ -473,11 +484,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; } @@ -643,6 +656,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) (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 A2F8F38F647 for ; Mon, 13 Apr 2026 18:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106301; cv=none; b=lHVdbYL03RMd4Hiso4oPMp7aEgigfmi2b/r1l4pFl7h1ERZdabd1mbu6UXXZ2gqJSVcgCUHX2Oft17Sefyp2poE5d0ciM3H8OH8EKF8Xgoch3ZksCKAvodYwUHFxdtF4iE2nhjWQaiJPHyEoAMj3n1fdp3/1/9l75niCioyyyBk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106301; c=relaxed/simple; bh=ygcJPQcFQqsbcl3KKi3dehXnYHxb/yokhbTzN9828oA=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gpVm8YDaVUVH9F4zoq/QrXLY6IqkZHiqKQPQoRCbbqeiyqBriqeMEMco/zC9nNm7njvYtoMHknrNiwraY8OnXmP+d7OV09swga8DPWi3xei22bRxUz9n7X0KCgJrIcjpcu5nY2P2G5M39rwtCnRmPr8fx9Eg2JY68WYRfSm3Xno= 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=E7uSBhg2; arc=none smtp.client-ip=209.85.222.172 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="E7uSBhg2" Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-8dbbc6c16b2so608665685a.0 for ; Mon, 13 Apr 2026 11:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106296; x=1776711096; 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=fcxL2phgHX3P6+H2aXIyKXDTUm0lhVC2d+qr2+0n4tk=; b=E7uSBhg29Uzk71EwU/+SkmXHXwN6UIK3yYnPKhliaBrPuxphHcN8eI9QfqDnhBRkMx vQKLc7ATV1H2jiIqzeotAAuEt6Oz4udynwCFCrCR0LpxA3X+ZAA54L5qZrdwktzv+7bu FSvnInRt6ReaT+hhQ4eVUfU2J6LSxhU1aVwNVuHaCYup4/QSv/sq5Y4wEPG+UpdefiWJ lHCkxrfpIPX9dxtAVrsdxoMpdZMoIjK6qkYJ7+dBVWynoMqpZnMgU1mQR1Xaxkof3IqW ZpU4SE+5/YbjFyQmG3AmhrJeiqYU0r0ci729xb4czx/NwGdrHP8M56T5Gz26sIX6VF1R pJbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106296; x=1776711096; 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=fcxL2phgHX3P6+H2aXIyKXDTUm0lhVC2d+qr2+0n4tk=; b=nqIZxY2UbfwzwA6abbuZlHxvds8SY9BKDcv+MDNsvKpq/krl91JS5WK4sc7Do4BER5 tldoP8rLFF923nTckn5MGIm2W9upJUVKeDIrIpwGoa5BeZqi0Mjr2OiCu59WXe6CRcOB B8sOczKKRK4RQsahtnlnF+QyzgE5sqeyWcaRc6ycqqq6+2c4N24n5xQoTOrL1MEVUfct wPWCUa7kQ38OJn1GIfMCeDcN5aZQwZjdM4CkP7bv2ATZe1CS69g1v1a0SU3wrZnTz1o8 d665cDFoHC1o0D+WPyx/be/oHfyqYe+sZ8xGZRj4ZMdLy1/Llw/LY930SNIDO7kwLAt7 6lGQ== X-Forwarded-Encrypted: i=1; AFNElJ/3W597X5qQx81oSFyY8G4Ur9X986tBc2OpBIQ3YTx2rAjXHec3OwWB2CPkorbNe4WdeCjtYjZDst9mw6k=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1cV+MhlWK8R/scgRRe4Ui50vAp4ieOGhTZm2/hjfKGZxvDWju weVr7LEMV9npH4YlUkLj2RjDBs8NYQN99DB8KevgvdLiPwm5Sk1lcAkp1pFlRpuysWU= X-Gm-Gg: AeBDievvpk5uE0Z5Z468M54wi7f2vcvnJh7rloAIdUvpaXZkx/qLG1QmQsYLuiyX64q CyCzKiRbbwzdO39T401aVEFFaKX+e4bn+crRVlQso8uSMVPQ04IBsPA3U3iUThVPoK0QeQGRA4a bN+kc6SFYj+i6XmyXJVN6JyfY5KrxJZ9C551j0D97zYhgKve/FXechqlDVJEqhHvDcvRdQhXpgG os7noynXER4GK+bPtiwPri+dEoMXVI7XJCv8z/3KZV2+ls6WKjoMJlgJsQR+hiV47mQYzhiLrDu 0Pu0LFEkgL7Eo46yF1ZrZLqjYiTVrYjK3/woy0FpKsgH/R7gEYbANWR2SG+FyZXI3k6jPAFoRio Tjk8O9Gzzz4+0weKVkPsI8+7XLtjK43RXGyee9Y2VlECYEzIQDkNO0CjUNjzLKj3UYo2tO3aDNi Ps4hcyq7Yzm2s3/WLvfE2knwWArPiH72ynpjw2J3/ajWeH+Mkb5NMBC6/640ygNYyuFQ== X-Received: by 2002:a05:620a:254f:b0:8cf:de26:91e2 with SMTP id af79cd13be357-8ddd03a2c5cmr1852376685a.16.1776106296523; Mon, 13 Apr 2026 11:51:36 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51:35 -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 v4 05/11] liveupdate: Defer FLB module refcounting to active sessions Date: Mon, 13 Apr 2026 18:51:21 +0000 Message-ID: <20260413185127.128180-6-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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: Samiullah Khawaja Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) --- 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 fdb274410e8f..3d439d1c8ff1 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; @@ -220,6 +231,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); } } } @@ -395,11 +407,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++; } @@ -476,12 +483,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); @@ -510,7 +516,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (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 BA15A34DB41 for ; Mon, 13 Apr 2026 18:51:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106300; cv=none; b=pqOj0QMfXRtniWmA8ceR4iEHJ8HC/wLLHTdWSdm8htGTninsaIGOx+Z3dxKEVoEE3al/8XbXcQaRbfWgqLn/0JdfaRB+VMsv19or/KIuI+6EBmxM+MAsxV2NOy1T7+/6pUvIW0qnjiQm6ml1Qr0agLr4yZ/1Qv3dSeJTk6XQtzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106300; c=relaxed/simple; bh=efvcnrVfQyhwNg7Ap0r1RDzpuHqSMIghK2fFhS104b8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XV3C1xsoBrOE74vaZ3Dacw3jQxPf5gjLCxMh7XJNuwzos84AqS6E+HmyjU8hB59Da3FdHdQN9wF/jg7I/7RjAHh+qhiAVYj6kzupNYTynYX7pEPNWV+i2qWXbRB3l6JOaVemDe4PqAz0uYnCV1O6hFHFg6wWCFhbjc+9Qm/aFog= 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=AMVJkaQy; arc=none smtp.client-ip=209.85.222.173 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="AMVJkaQy" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-8c70b5594f4so467316485a.1 for ; Mon, 13 Apr 2026 11:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106298; x=1776711098; 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=lyOXH7squnkI7rGYP2+HAwesaXX15Xy0bHRGyfpZyGU=; b=AMVJkaQyCD6LMhQP1tO8/oxeI4YcaZ8trrDm+9+UhXzr87I3pz8HP51UwRdqcKEu9Z n5jsydYlrScrycChUIwmeezzIHHeE8IG42Qj6hHoFs5CETssk13eE/lfgH1xNyP3cng5 xABXIlr0smHO79oj/u46dYJ0ScTRumdyqambIky3YCNcOJHgKsKsmxHrliTf9WIpeV1g iX0IySyj/Ky+/6wdaVqjzyu9u4FeF4EbbT+d/QVaPRZPEsEmlSX5YtzrUBfvlGPjQfAb Si/kpqEKgCjDg5FRHWpe9w048Fy14bshcd94Rj6DP3D8XqAilhvYlTYLoOb9J+j9a4rZ w0hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106298; x=1776711098; 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=lyOXH7squnkI7rGYP2+HAwesaXX15Xy0bHRGyfpZyGU=; b=XfXmOQlm9nkmNmaqr0Gn7eDVTOgQA0lYW9sOJxKLrK7nrfeMGOsX2qcMEf0PKk/WlO eROTemhhz42N6q7no11S7bte0oum23mXhKkVOy13O4UTsyjL4gWHH1wU6jG1Wsaaz+FF KsFalf3VSk/t+SjlTjsoPtoPu0y5/JaP57Z41MY6pHe9w0SHPlhr7g5MPLi+DVJu52eX Pwf3oQdJkBonZKYqx4iO6mrGsLsE6nR+p+OeSPovKVcA/XQO44SIwuFO+IeAJYzY9e6W 4OLx8uXH+rlBy2qbcaId/Km3Coi3rSAqAW19cEf0uj0fGLboXmWYCKKEClQdjD3d0gNR DcnQ== X-Forwarded-Encrypted: i=1; AFNElJ+fSV98QvV3hMobAVrgp5BSGrBKIcCzmnpsU2L6G/4Db8WvFEnJqmcKfEIX6D5SSs0616vX5Du5fsa2JXI=@vger.kernel.org X-Gm-Message-State: AOJu0YxddV++bsesDrv5lHTWNf1AA29OYpY//6tnSR9e3a9gDihn/T2K KsZ+cBnogUFhtV33Y1dnXL895o1HmNfgZ+zl61NyDK+vrkI8rSuPBdtGp7/hY7UzTXY= X-Gm-Gg: AeBDieuOfMLnWXJODkVLvaKCVvlQDdDD9tY9ppp6kghOyChwvRIMIHvXadCEvKRVFM4 V8V3NBR4KBOpkWuiLs5ZsWdxP+x0Uta2374gisEU/WKC+8eySadhtMlamvIAtXG1wRXr7GGjJlb vD4+U17vq2nEzOy6ii0tfnbPDgNYpqtoZaMzFmwpoUd+TyMLih9oaNfNzSr0LiYXpn5G9lEZRVZ cY5iut+dda90KoAAGd5cwlEFUhnWJtWq+lN+LftrOj33dPXU5rbgefk1QP18Rt1RGDCm6Ilq/D2 WrWMAVW51pP6n4OqXDGGdor11tVewwZVAWzHLP0vtNJg5oznw6KNCVOnUQFVdRQtAjt0Sa6qDhl nPCH3jMjpfOu3VLGGSNFaEaEptciYUzOTsh07fghJfMveDT9K3nBtHd5E6BqZBZMZlznWfzvcOL DIuSnqHhXDvKSSqAw725IVV2yHqPsPkO8zCMuppbgaK4X8XWDIbdjAx0rUWXpiNf4o6g== X-Received: by 2002:a05:620a:2547:b0:8d8:697:1cf2 with SMTP id af79cd13be357-8dc467daa79mr2353546685a.30.1776106297609; Mon, 13 Apr 2026 11:51:37 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51: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 v4 06/11] liveupdate: Remove luo_session_quiesce() Date: Mon, 13 Apr 2026 18:51:22 +0000 Message-ID: <20260413185127.128180-7-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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) Acked-by: Mike Rapoport (Microsoft) --- 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 ecf780d74d80..63ddcf6dcddb 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -878,14 +878,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) { @@ -908,15 +900,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 @@ -928,14 +917,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) { @@ -946,9 +933,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; @@ -957,14 +941,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 3d439d1c8ff1..13f96d11ecc9 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -348,7 +348,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; @@ -369,21 +368,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 /* @@ -391,20 +381,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); @@ -415,15 +401,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 /** @@ -439,12 +418,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, @@ -458,14 +434,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) { @@ -478,7 +447,7 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, } =20 if (err) - goto err_resume; + return err; =20 private->users--; /* @@ -490,15 +459,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) (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 09582390228 for ; Mon, 13 Apr 2026 18:51:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106301; cv=none; b=qiuQGKDTY16WGGUuEUJt0R1slKJheqNSqD0+dKGdCChADYEDXrrfooTUaIDPM1pAu8Ekqb2favPhwFIG9z/nNeAcumxF9SlYc86BahKFPA/0j+Lz4P0nXnUOsi/Q/mjZhi98PkiREnpDN1o0Rqyr1NqPsdI0z2tBFwjee00qMew= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106301; c=relaxed/simple; bh=7bTj6Wqkb2WIA9nYPD8Bj9Xe3On4hjDmI/4yvCzElrE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ojoT6P20mhnPQn7tdtrUdHvkV1AiglodNssOaYmnAazR+580ktjiRcaFDakMrMjo2bbbkQ3KM0tXYFXQ5Hn71a+l0jTijP7Nq6K33RgCRrhYhOy9IdtXEQTMoLJsuhOAWuZVzdZ+F1Cow5GkP2qXX/xW6WLwbFmEz5q+kC8Fx5U= 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=BwekVnq4; arc=none smtp.client-ip=209.85.222.170 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="BwekVnq4" Received: by mail-qk1-f170.google.com with SMTP id af79cd13be357-8d933da14f0so521163985a.2 for ; Mon, 13 Apr 2026 11:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106299; x=1776711099; 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=3yRh7amP+FpWvXP+5yjdJzcKbkg1zLQsfC2/lVN1Vw0=; b=BwekVnq4LNN7uZn6efe/G9gfMYUXal86gAKVP348sDBQc4zffHw52vOCQ8HSJWhF/C HNQENjXt+guqunEqyEbgIQxGZUwc22Pn/IzZHoFIzUPuq5mDGFEgT3J+bH78XFd7wHRF Z0BR2WZdH14DQKB44yAXD4+U6++GQ+xEW4krafk+hboQ+fvYiCNY3mkEkPoWw8LAicB+ 9qW467z7EiKpbxi5AavknbJVOOoWngmeF4C8ZoIfsnlfgVfWbxGoHSayBaE59xoLiMtH YtY8jvktCB8vDPonbKFsLz2hOrca1pi5Oii1jXrN25TT0Flt7aVo9CcZno9Z0vl+AP4d rfWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106299; x=1776711099; 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=3yRh7amP+FpWvXP+5yjdJzcKbkg1zLQsfC2/lVN1Vw0=; b=MPkMBgodxWV9z1wUWrtDILVv1M1QedWpIvzzdMBhwigbfl8Mi14+Ki2XTdJMe3qN0T MOj0mVgLraNFQWEOTW2U5Y3jiw9RLPhG4QPdjWTixNqcudYMKto5HF5338K5dtQqE31I kwTmLf5e7LVE1u4Ywsahr/2zM7beVl3p6Qd8n6uYRu50ZXc+8eWvDgPSc8WZ8aV3I1Kc x5U+MfmU8+3eNWxBGvoAdInbq5PYrD2mpdoCZ3+6xs2lm9/J5/83xSPep0/m60TNrlwb LP69N5R6N+g+H+4FQlCTUCd2g84x5hWbS7csKKqwnOBOLq6btnb3KEQBZ7cmP77SBtDS EnqA== X-Forwarded-Encrypted: i=1; AFNElJ/JRRCfpGS6cuP4MIAhX4ODN9knmexNgUzriY6J3qIc5bb9ORUFfEiAfsTrbxMmiWQaqLLfVthveVYiDvs=@vger.kernel.org X-Gm-Message-State: AOJu0YzF+nRf3HxVyfxEWWmimx+tsn6u6x5quzWa5REFhkoBe7QqYuJm 19Tiec7e7j1mPt222htXyvOybCpA40avBkcDn7eQTdFmoYWQx0rT1+PmVG1sasfrSdI= X-Gm-Gg: AeBDieuszzSLMlNJaTJa/+TZrmNgSTs9p+nM/Za0lJFa+tFO6kctg4TcCFLudnbfUVk qWNDr8Mozgzav69DJbLr29k9e03wzMRz2szW7UoMYm88Iz2XE1GnNF9uSlDMiZOAcFVrLmZ3KoG p67pn60Yk9v0Ikeu1IWQcbvJS7LB0udXHs5vGDf/l/zvLRnaXd4hL3LQvbV5hET4CvbqJ929IpE OMLxPr2Y7rftc3xxgfOaUSFp6UkokF2oRSrzQ+uLQMkyo/l1qHfK+nPLc/4+zIqZmWKYys6YtEd 0IUDrJaR8qUEcXxR0KbFXBVc43BId7FksjjtlnP/NXNC8ZhU+ANzyFzQP71driULME2wlYX/qtb al3woanuAR7kf9IBlwCUgth5ysLivxbwXvRNIBSDLHwFALMvWrrROUD7cnkVMavBurPZ9pVPcb/ PTK+Q5PaL0Tf7hkroe91jBDXgfWflety+T1kTnFKJUeObXsuhTh2o1yiCokD/hmiiw3A== X-Received: by 2002:a05:620a:40d4:b0:8cd:93b7:ec10 with SMTP id af79cd13be357-8ddd06966afmr2127489385a.64.1776106298953; Mon, 13 Apr 2026 11:51:38 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51: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 v4 07/11] liveupdate: Auto unregister FLBs on file handler unregistration Date: Mon, 13 Apr 2026 18:51:23 +0000 Message-ID: <20260413185127.128180-8-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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 Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) --- kernel/liveupdate/luo_file.c | 14 +----- kernel/liveupdate/luo_flb.c | 85 ++++++++++++++++++++++---------- kernel/liveupdate/luo_internal.h | 1 + 3 files changed, 61 insertions(+), 39 deletions(-) diff --git a/kernel/liveupdate/luo_file.c b/kernel/liveupdate/luo_file.c index 63ddcf6dcddb..b37bd79974ce 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -926,26 +926,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 13f96d11ecc9..b9f5d452a998 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -318,6 +318,63 @@ 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 */ + lockdep_assert_held_write(&luo_register_rwlock); + 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. @@ -426,38 +483,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 39BFD390999 for ; Mon, 13 Apr 2026 18:51:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106304; cv=none; b=jSaYN7MPfoC1zuB25KSsnQK3fhDDBSOc6DzDneiGE2/WIkF9ER/MeOfBWtbNRRwELt4rs6zf6w+FzCrIseFM04HghpDcdIfRKOKYpAEmrvBKCwMdG1hw3NwlOdp4xuxGK0CTcqNqiBoHQwxblxwJsaEkpSxrC8EgJVZW2SdJLrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106304; c=relaxed/simple; bh=g3uwJ1p09FCwztofh2LgMyiLTXnc5ZULEi4NFdxHTX4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cbhzmZBUeXedXRo6PaRROVMuvdbukr6nA88eMYe6c3fmc3phSecXsSyGFydWzcXFfcm+qema6qDHaVjfehaBERIs1MGWikHHIk973bz0EKpzckKFwwoGfhcfked1z/JEuP+7Jsnd9hhNDel6j1dFfylyopj7zv1Ds/OX7qXN2nY= 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=cHI48BxE; arc=none smtp.client-ip=209.85.222.182 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="cHI48BxE" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-8d736211595so338361885a.0 for ; Mon, 13 Apr 2026 11:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106300; x=1776711100; 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=H+KnbIibxWtOmzdJbC+Su2tcke2GFWOiVDDgNx6VRj8=; b=cHI48BxEdz9ohVLHTWjhSXej727fi/ql0fM5jZdKltDcKip0l6xq7IOcthkyFx/PQb WKgY4lo22kYmmIeWab5U7hu1A+lttEgb0IwZs8xsyx+s8kOQ98VdVf+lwg1uQiW54Uud ScJxip2nbBx6VxqyBhxNNU2l14BuEx56OSNIUTpqPA06JyLrdNiO0dozcYrpPV/diaae TE5swSdA6fKO7znL05J6KQ+/fnlDqbBAC4t5WliyDPLQj50ikrfnBSfc3xa2aeS6RlQU 6e4xvnpY/+bCs1kaq7KMt6R33A7v51NjDOJxblBVWLn9gtAuUNLiNFGfUbFLxmefSIIp cqRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106300; x=1776711100; 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=H+KnbIibxWtOmzdJbC+Su2tcke2GFWOiVDDgNx6VRj8=; b=cyhCvKcod49q4TVXB8mFjVUhKi3fz4GScltSN+jH1KPSRJVrSw2fDk9ElNfzvlfr41 saKiQPrWS1jYpfJip6IK2wET+WvgnQi46Wc0u5t6qSjrFSx0Q2OVHZ1LTRUqdfiH+PJQ gpW4XGpv55S2NLUx0c/iZ9pTx2ntDp7xVmqRm74uzK4JjSEpue1vSRcj8oU4tzR86YXx z7LGdx3rToa61/bQ2pe1HWvAGff/DojVsaJkd2vX3vii/DAPFdUX5MjNbLWeEoxTCvu1 OAK7WNH5X6ttPwmU9/IYWy11bq/tE9VX4/9zsgGBngX+Su1BXQEI54sCnD1rdAxu3SVD A5Lg== X-Forwarded-Encrypted: i=1; AFNElJ8/Tutg+j1STn6565X9FI9oT5/7uIZ3O6MlO9PEebft0n99t5Ppi/Y82BQTsoo5QLADNUHW4k2rM8f98k8=@vger.kernel.org X-Gm-Message-State: AOJu0YyFKb9VvuBo9R9t7AGKbYMXN1+lEA6p8+JIr2z2Yj2gpMTVhr9B 1ac7WUpqUmJdCnoaUd1+ZNXt/M78pCITO+9qTwRjcnYjWBDfmS91Bw9Syxpr6YGWStU= X-Gm-Gg: AeBDietEyPbeTMPImGJRXyriJraCtSnMkaV3HvLGZ5VDOZX/2JlVpaQK+4q1cF2GdGA h6zM9B8bARUt4F32gfZe5EeD4fAsO/xOSoKwrxGKOsv4Mj+HPuaLC0UdIwV+GFMMMCpsxTrUvFN yw8n0WuQl+dL05GFLOnF1o5TMc1Oiot/wVUjYRBykEnYu88tsD83l63tgZOj2P5puW4ioYYvMLF lEJf8cDhcFVZm1VqhBY07u2aoD4uxid+vyvMyso0Uvd67TV0P3/jkk2A/6pwehRltruBg4LM2Qo yV7iJJlfPOixcQ33iLpV8ggi0i0MBWV08DTgOSmR2pn03uy6Poh0I4l8OjFTe3hgkstuQ04rsue Aocf9avKtJXKW3hAeONcLaFrDNvmZr+Nmj+FVRjxFFEtkXzmT3ab4XlQ2Av+8MsCs6ZpUnn9Npy efXd7yQ7NLF5lb7eOz5cCWv34Pgf32v7khGjAKoAh5zftvCOVFQI5YdROTbVmkWiftNIDc1Gbar VqJ X-Received: by 2002:a05:620a:450b:b0:8da:d152:b7ba with SMTP id af79cd13be357-8ddcf7b20b9mr1954895385a.30.1776106300047; Mon, 13 Apr 2026 11:51:40 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51: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 v4 08/11] liveupdate: Remove liveupdate_test_unregister() Date: Mon, 13 Apr 2026 18:51:24 +0000 Message-ID: <20260413185127.128180-9-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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 Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) --- 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 b37bd79974ce..f3b7bb698d3b 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -929,8 +929,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 Jun 11 21:37:02 2026 Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 3560F390C8C for ; Mon, 13 Apr 2026 18:51:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106304; cv=none; b=BvL8rGwfoxAcv8hTKzDrP4F70PvNkzsYwbqIEnVxS1WhuvKnvczd4w8SjKtnXkl13E+Df/qffaNNwi4du+cNondjv5Cor1Yj2VhVGcct/O5b+dM5DaWAAWtW6oXC7T8vQJLmyn9F4sxgqu3r+gtbKq6IjbPxDyW0r9NPghgAfbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106304; c=relaxed/simple; bh=cTCzjmmei20SetvtCQLzm41zLs7hQOOp1rsTHEUt134=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OtzoAMc4j2prq8rJonzil+rvkNTecmefJaOKHh0CwM+T+WA0Tl9If9rercrXkr7I9/EH/sbtaydfKMPKmmTQMJqz6dRAFJ7QF2ZaEPvK185xM2H4Lr7nCZwQ33fBwjNgoyj53vZX4mE0t6SZAOUTBdxV6/I9qtYTE/l5lJnl3h4= 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=NpT5Vdf0; arc=none smtp.client-ip=209.85.222.182 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="NpT5Vdf0" Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-8d6d5e45c43so570407685a.3 for ; Mon, 13 Apr 2026 11:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106301; x=1776711101; 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=DkNvNu/MJWuSgBE0j2meDc1C2+4gt5AIv+r5JMtH/i0=; b=NpT5Vdf0qzNXj2eo7g9zI8ki1+pRq5o+FutAbxiJXhszqAozFfRrcMAlChu/IqMbWD jvl0EDgAucS9zma3u+0WwRR/XF919f/4PS9o3veLM6sG6F0LxX3OO5GSxmGGI5cspyp4 pla6S8NTKakv9+Fx9sl8GNx/MnLGoHkyeCDXXh1qnC678WxJEx6n/t63r/AdviYC/gEX JQUjHrf5M57i4XBPpjXdHmMk1eaWGBLjEdEcgeBZIA1l7bCvM6jokUXGQUQdoR/3zlKm WpxRddPZ/EwlESxv/yJntiKpTM/YISGqGDwbX6vCE1R0JbEN2muabYIsJElfVj4lOBfR boRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106301; x=1776711101; 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=DkNvNu/MJWuSgBE0j2meDc1C2+4gt5AIv+r5JMtH/i0=; b=B2XlKBV9V8tG9GiZeMdphASQmVNe4yrnr17PHL0qpERtNaW23prAxJQmRMdaSJd1U+ i3DON3FSvACHoyWt8mZDSWzv3YSILGF7CkFK+zW3gs6bMD1jSoEaiIVFST2ZbW4tq+St lQ2ygxtovw0qB6pPXf0AmS9wS5gRG2huX6oKnf/OLdN1dY5Bo/xUfF2jlgtExuhPKFT1 55IWdGkQZBpsskQO1M7i5egYHOR8S3gVR5xw34ZTlvPESYJnFXqRstO3MhY4RhOBE7CW IQzwOPAxYyRAQVBWIXSjXfJPOBaeAuFQdpBeXkMY/sKPHf8x4Sp7Nn8bVFQR/1T8BDYt PDRw== X-Forwarded-Encrypted: i=1; AFNElJ+40FYbNhvAMwJgNsOTfgJBn3oRI3oDnewc6jBmo54UrP5GfvIpZbZiM8vR0qjUvkeliyhJMB1J8lUeBKc=@vger.kernel.org X-Gm-Message-State: AOJu0YyOno1v3hp/NTxZNbaQFz0zYPtaSNAKJzhAQysPtuHbOjc6mPn4 psUeKDBRkUfOKJ4ZqR+lSQE+gmwRuH9+yAaNM3wE+p4FbfLyehr0QX0Z2sK0X8dvHG8= X-Gm-Gg: AeBDiesTkjH/X0pWP8I3mzB5GvkmcKM0uawgXt3a3Pi1XYdhIEpZVN+P1cg1V/YeXpb 26r3/vFqd8IgfEwLI8E95Gzee/zowC/6VX/0ktCr0xU/HGvdT/iNPCM5DSHkK1x+RB3MawTVaLf +sIQvi7Sgx7xW21FV17HKRAmc6NNx90n9xQxC2EG/lCrlXQfg3bsVGQ9Upi27DkK7jkroV05lKx 7E5ILcdCLMMhmirYEozWIDnDRcgHN/wCNaeUWzHbrflVoxUUF9xz8VpVrEhaTj6w4CngEcHrcH9 xuRg/ymde7oQJXtmde2fkv2mgIclT41jfBJzDyLa8/XqwhQhh6oXwHh+N09/b4YJXttqfDZiGzH 8JlJv+x2WHbEPyq+Nbz5DEZwuXDYM3ly8IPxFeC2JtwvtQI1BDb1pvSTMjAvMnAs7Sh7C7jlgJG yUGEndUNyegN5D4I3eZarMDtUWPJ9vPrsonYwBD6uM/G4hciyczOVrae6t4pNbxgsVJQ== X-Received: by 2002:a05:620a:1a11:b0:8ca:2cf9:819a with SMTP id af79cd13be357-8ddcf1b8f35mr2243567485a.40.1776106301168; Mon, 13 Apr 2026 11:51:41 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51: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 v4 09/11] liveupdate: Make unregister functions return void Date: Mon, 13 Apr 2026 18:51:25 +0000 Message-ID: <20260413185127.128180-10-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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 Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) --- 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 9c761d9bacf8..30c5a39ff9e9 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -231,12 +231,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); @@ -258,9 +258,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, @@ -269,10 +268,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 f3b7bb698d3b..f8e098858c62 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -915,25 +915,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 b9f5d452a998..42c37b3c2101 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -476,21 +476,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 Jun 11 21:37:02 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 3C808390CBD for ; Mon, 13 Apr 2026 18:51: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=1776106305; cv=none; b=VdK7NCbAVg+di42JXJQ8A2TR++i7lxszk15o+Ys/94bze6yMFWh9yVUiCJJRCncZv/92K4jwgSH3SWJxNzpAZCqBBtRXVdXHLCvjl2/8iw3PzI/xh2tp4Uemge9LFbsPAzIrOLeOgYdYjPROG4eOuFdmODi32Mi4rZitvGIcTpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106305; c=relaxed/simple; bh=/hZ8Skz8OqW0DZr2sZe74RYyziWHRwx2FnzoCOg9O0M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HNgbgqzQaXZhxV+J8xcTTt26NFltYiw7ZasQQTHE+dwtQOiuN7cNIFyUsn3JAha3mXqamLUQuMX+reILEu8W5WaHmOYqI0bHLcI42KSpxz0SoVAwrUR3zvM8l7uCqDUx9czahjDEXL9sZgI/gzk/6Tp+q2TOUwh8maxFgjPl/Ro= 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=EiYRe5Tk; 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="EiYRe5Tk" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-8cb40149037so447022885a.2 for ; Mon, 13 Apr 2026 11:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106302; x=1776711102; 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=KJeEvj0LNhhqC5xfWKhLkcBWLJMMBqsm/C4oZoQsE5I=; b=EiYRe5Tk1kLyYJH1WopAogdiQvX291HDmuUGoa/tU31Sa1X8DyjOm+Uam3wLpRfbjY foms1LqEEqQyWK3aJctFTfDo9p9Pww/aOYYHobH6uG8SU2dvBR0IrFaQlGkjPdsrEF1m T/QwvfiHOJI+grJ8mwyBogwh4s0TbUOrIz0owJPEK3IokFBU/AG5kj9qE0z4M4aRnKxb LKYLee/SdNvy3HtO4yAa0cX6h/HWU9EtLySf5mXuGkwVa3fgDfExvnT5M6E5HooJ8X4X ZdWUL4mRxu4m3bWg7I43urIZc+QFdCKvAbqLxLkxkwqoTo7BPfiIsEaykqwLwHoatgUn pRyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106302; x=1776711102; 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=KJeEvj0LNhhqC5xfWKhLkcBWLJMMBqsm/C4oZoQsE5I=; b=m+BhYrytPaK2df7++aYK192wCt6ONSaJvU7gPgH4/Hrvcypi+0NINawpA5CZVTsmbj rS2LmN3hXq2MydD1sWD/15NtX9GHgBCrEOrKAGK5UcA4GrPHo0aI+p/qllRnZVPIx2Z4 gXQijVPl3wMsM02hJuJTC9UrqMweQn4vYBGmNUNcwGf2EPCWfSCr2PboRujMsOvYbksm xSZgIfy8AH+HsmxWs2V0I8dv2ftA4ewu9BqAec/XOYQLNQOD2xNaBntOJXMARmF3B2vi Hqdg4fdPU3nBVWjJBoE9cMYSv3rufb6gaGR9KvWwb+K6EtwkiHYQaxtD1syooL7DVKl6 3CNw== X-Forwarded-Encrypted: i=1; AFNElJ9dvIm8doGY9OcVPHpFG8JxtSXapOnSp/VUvtBnpzcSOXQaBHcPn30inhw1jC4ezkT+Sw1Txci9RyVl0M4=@vger.kernel.org X-Gm-Message-State: AOJu0YwhyQxozbIetBKfTCE/RI530P8GTswuK4OEIZy+3FUql2OoZ3aK sTTIgA3hJ6kAZFQoP/GmxuvjJ5fokWqz1mono8cDxYQv21aRCzql8c377yL+JYM3nmE= X-Gm-Gg: AeBDieusmVGCSiho+lj9nOWR135FUNdeBcFuHEN8N6WfV1g6I61QrG0eYFJPL0/NBGk uuZn6+vKe3QEEZJFD0Qyre+/eoih9DxHIODpvXvpRyznbOy1dUlLYRp2lKI8Ic5VVloYAkoqdbZ 0j385GU5YoBdxNeiHdfK6wIf+/xfoEZfJz2wNHXmqknZZJU0jkfyAz0OO9xvNpewgGRJkU5lCCt fCbqIIepuVTsrEjEowAFFhFu8V75hSRQevNnyMQO7+2+2Mq4Mzb/OJits8Tvb/j3A82dBEMw2Ra HZ7iDQdotLST84HfpRRKJBrkd4BOr5YrDEYgNymWTbLIucErgD4dZ3xjiIseHGkdUWwT58no7Pq 2AMPI85dJAxipApAwhXICF0ZLP4IAdHRrU2SbiWP522p0fd5hEW4+X4letTt2skNmCMsC+DYeNt gKPqRalM9iqidjow5XyZ2NrjI0UM+riBtjy+uAsLIMjHuRsEzHnUJ3dAeYxOqkQUegUA== X-Received: by 2002:a05:620a:2901:b0:8d6:39c0:e6b6 with SMTP id af79cd13be357-8ddd078bea4mr1995823285a.64.1776106302276; Mon, 13 Apr 2026 11:51:42 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51: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 v4 10/11] liveupdate: Defer file handler module refcounting to active sessions Date: Mon, 13 Apr 2026 18:51:26 +0000 Message-ID: <20260413185127.128180-11-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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 Reviewed-by: Pratyush Yadav (Google) Reviewed-by: Mike Rapoport (Microsoft) --- 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 f8e098858c62..dedbb8d02e6a 100644 --- a/kernel/liveupdate/luo_file.c +++ b/kernel/liveupdate/luo_file.c @@ -292,7 +292,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; } } @@ -306,7 +307,7 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) err =3D xa_insert(&luo_preserved_files, luo_get_id(fh, file), file, GFP_KERNEL); if (err) - goto err_free_files_mem; + goto err_module_put; =20 err =3D luo_flb_file_preserve(fh); if (err) @@ -342,6 +343,8 @@ int luo_preserve_file(struct luo_file_set *file_set, u6= 4 token, int fd) luo_flb_file_unpreserve(fh); err_erase_xa: xa_erase(&luo_preserved_files, luo_get_id(fh, file)); +err_module_put: + module_put(fh->ops->owner); err_free_files_mem: luo_free_files_mem(file_set); err_fput: @@ -384,6 +387,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 xa_erase(&luo_preserved_files, luo_get_id(luo_file->fh, luo_file->file)); @@ -675,6 +679,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 /** @@ -812,7 +817,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; } } @@ -826,8 +832,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 /* safe to use fh because its module is pinned */ luo_file->fh =3D fh; @@ -889,12 +897,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); @@ -924,6 +926,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 From nobody Thu Jun 11 21:37:02 2026 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 7AFC43914EE for ; Mon, 13 Apr 2026 18:51:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106306; cv=none; b=LZGkK5CVaV7LSrhsT5JjS9fdhTVLVPC6y3v7id6bgJtvhcgmyZIgTmVuNE3vA/MjViVn2aUmXN20JtzLr5mHZK1q8q/eMcs3YbG8Awy5g+kH1JSgxmhNoIiu3tF/DIs4+kJ2dqwpCJCv9uE0aUt5ahGkYuK5K/Hf7gkd0sdGiKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776106306; c=relaxed/simple; bh=JjQwcsmR+NR1IeE8QtURVpE4my+3KMlk8rIrLxCbDG8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GwsSoCw8PTioy6/Q1PSMBEbqTJ85XpgTY6u3NCNkY0aU2aIhcLUJlOGYzGod9M1R7Dw5loR39YrRkzTOatZr2hm0kbiQzfMFhqgarrp9Om9vOAzT2V83oipFx3lYWAT9oel1ZFSCmW1xfJ3P4j+m2F21Sb6lvfJBHQ0OS1Sh9b0= 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=KPVyppfY; arc=none smtp.client-ip=209.85.222.178 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="KPVyppfY" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-8d933da14f0so521172085a.2 for ; Mon, 13 Apr 2026 11:51:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1776106303; x=1776711103; 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=9T19sIzoZYsgH9efdR4OU8RRGWUzOru59l0S18klbK4=; b=KPVyppfYhyt4bZRUZEVXIQ4nWKAfp+dLKdpFVMpwWM0AY/THmqGfAqQDlB/a31K7jD v+Di8T2aP2ex7FuSYmAA82iTq7UfZF3rMMO+bvpo1ArYgZBISWnScsLLECokoJrJRtGq +mGoB+hR4+Tx8G5EfUsdLwKfeDoo42Npjk9X61Vn53TltBl0rzvnCqn98jC2ubQt06u6 PPHsFrMyPocyJmCupB9oJ7mX3B8kmHHJQZ0S4VGT7eYFmlvPHCK6sgD5AoQ2GyovH/Ks UOD5H88uwffATzlZ70hcOu3gpNMuDj7qIl3AWKqn0LT79CtgD+dddfkMFRtupe+7TQVH iJOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776106303; x=1776711103; 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=9T19sIzoZYsgH9efdR4OU8RRGWUzOru59l0S18klbK4=; b=CQMvXh8Rj2dU8mBEGwscxp+FIAS+WKmKenZoMg1er5DuDH/CJzdGZCXEpkw5LAI8Hr scES9R5+gq6NrlOoQXspjuqExh2Znxu5hXnA8NwMeuT7QYyXxJVP8vFmjrBMWZkmiC/x x8zeUTpu3TSy+0mNZ9LggTLNRLIqOkEylwRBgtiEa8HcPKO6LYtox14wmezrc2XiVqi4 0wEUJyLmtj+9zHwIc3ggnMQhfiikudIJy5Y+OKAKmURAYWU985H6NzlVIL818qWBap5Q 5od/sPg5js2sH00vkfiFHQCBVxxQtFohlMNykDK5b+tkqcWShHM6+tAgbr2wEZq48syr cYfw== X-Forwarded-Encrypted: i=1; AFNElJ/1/YeYpHVVIko002yDHeRG9K77HMcZVU8PABSc/kajMPfXLg6d/OIThrms3DgaTYkwldo/ptq3FeUHxkk=@vger.kernel.org X-Gm-Message-State: AOJu0YzOp9julTFyHJOuCw+cfawINAWhNCrDWzHHg/+ImzhBGLlm6Xa0 z/KW7uqyzWyBxwYPeBRUdU0eS5H2UzU42O1FUSH5yCgDe1hIC53BU2W3+U1P6Wf27FU= X-Gm-Gg: AeBDievMHzyudgLdDGDrggpQ4e5I3eKccba/vMkcFtc0THZXgLcfI8Lp8FFc9x/cCkC x8Js98Ov8Ew5YEFpoQ20FzaKKlQsgETaTNSzF4x/l/fqIu4pwSVjphu+tOt4FP6ICpCOWM0rpQO Cd9Ims7QF/eZkVxXN75DFzR3fEVJcLLnzXAOjCtRvNU7mQIzC92eCYUnQLrm8fE2gu8FEy6Qjls 3MRmTdrITpdS3gFJy4dHBpccjzP7qropsTIhK2ZQ4a8wMSyF/TO9UquzUfMXQUbh9aotkJP0vN2 QSH29LSMJRztlCh+yONEkhufC67Z9D0FYv5sx1pk5Q2FuUMm8wdm0Lbx/i/1cvTFqZ+Mo/14iIs qCAAmutI89lCvdl8PEPZ011cmBl+EqmO1I8ONHiy993XoZ/Vw+vYmGnd2bTeRLRt7FSEByKORjy 16p7WnuqEsRffBIcaSkfm3A+jpgjtyQVOLOsi5VgCf/yEVUv/q5FKh138v8uH1509dHg== X-Received: by 2002:a05:620a:400d:b0:8cf:cf2c:e003 with SMTP id af79cd13be357-8ddcd02470amr2028285485a.6.1776106303300; Mon, 13 Apr 2026 11:51:43 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8ddb6372790sm943206285a.12.2026.04.13.11.51.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 11:51: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 v4 11/11] liveupdate: fix return value on session allocation failure Date: Mon, 13 Apr 2026 18:51:27 +0000 Message-ID: <20260413185127.128180-12-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260413185127.128180-1-pasha.tatashin@soleen.com> References: <20260413185127.128180-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" When session allocation fails during deserialization, the global 'err' variable was not updated before returning. This caused subsequent calls to luo_session_deserialize() to incorrectly report success. Ensure 'err' is set to the error code from PTR_ERR(session). This ensures that an error is correctly returned to userspace when it attempts to open /dev/liveupdate in the new kernel if deserialization failed. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) --- kernel/liveupdate/luo_session.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/liveupdate/luo_session.c b/kernel/liveupdate/luo_sessio= n.c index a3327a28fc1f..92b1af791889 100644 --- a/kernel/liveupdate/luo_session.c +++ b/kernel/liveupdate/luo_session.c @@ -547,7 +547,8 @@ int luo_session_deserialize(void) 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); + err =3D PTR_ERR(session); + return err; } =20 err =3D luo_session_insert(sh, session); --=20 2.43.0