From nobody Thu Apr 2 18:49:13 2026 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CA1336D4EA for ; Fri, 27 Mar 2026 03:33:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582423; cv=none; b=oueDaGRxUTF3RvlVwFZwFPpo7tdExF3kvDA5GVwAwMQ/7L4J/iBm38x/VZzgXCWuVobIiOQh6H1tRPGaMOHSdrOBcKJr9YQQrSaYtKoJzakChanTnGSAvEl/A7/xWU4sqmzi5Gnh2S9jYefSZaSPe/J8IY+FoWGnIYJFJ1rks18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582423; c=relaxed/simple; bh=pb84xbfdOieLozpDXoOkUGf0V6qrtCpPAUJkZTpvgvY=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fiN94a1lTl2oW3OFa8lVnTg39Orsj9miG2rDw3BTPLtxsXocbpjZ4hPAMkHPpY4ZYRaX5GCE/y2gbL9LxSKifeL3lfvTNPFawTrG8cthCd8rzXEwPOzB+sillf8v8QEktkgs7Vos7QOCBGAyhvHSCPFx595pzaCC6P2dERWGOPU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=EXc4balh; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="EXc4balh" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-89cc638496aso16612126d6.0 for ; Thu, 26 Mar 2026 20:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582421; x=1775187221; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Q2LKhamSzXfWrHIo8OAsnqwo5StsDAM8VnQ9PQ82pDM=; b=EXc4balhbHU4LYr+Rg1PozBb2IYDJSuu4KYNwtxuGaPqmEq507gaioyKTvVXfz3hOo cSa9Mqj303aH0JHKUAb9N3cyW+IZKcgLLxu7NeRrWKTQmorW54eZZ/hqKlljF3qN9x7p y+rhFDw+pO8M/bikXmA+vlkAUxHbtln3ycF9qKB0VvxQEN3p57RRf7Wp0CiX97MKiqNs /kWHXGBtWmq/Y5THVz0OINfi5OJ4OZ1OQM5lezaBajfe7kla7uwfGlBHFlm7aBOB19Nv gSOS9XNqTun0H22cRU/VdKL+OjV9GI7Jab2ZXYrrFs0gqPRUr1JoBx8WizOedBgKBrev D8mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582421; x=1775187221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q2LKhamSzXfWrHIo8OAsnqwo5StsDAM8VnQ9PQ82pDM=; b=Fm+8YLMSFFr7+xJvSuDfJLz0koPM73QngUJjigDpyhHLVZlsvcqfA8NLBWIxtUX9Dd HwQpqeDCx0Seqp5VQaHCc7adYnaQzJ/p887+ASc9cvQnP94Sa/cmUgLqztcirWA3m1nG OdWsy+OKChw+pt9P5lppQx8p+QLcW/onNyoEMkBEVHsrVvRrFB6qU13Ex6xVw0yWhKbY qrdPc0SimfI1gG2BNGBsU2yOXbb2AvbAH4mjtg7JC1sJ1RuetZLNKKG5IxQCZQ6cw8iD fRDitVIu12CRR0NKBpVT9HkAsdtFvjflMwFLz0QHFIlTiEOejLXc6SrFHnl7q3tJGnTD f0qQ== X-Forwarded-Encrypted: i=1; AJvYcCUL5nxO7Q7Z9gEhpfyhI2Bdilp2rUO3IO2CuyrYW8eJOywesmn0nKtkTzo+rXwG+Kf1P1ltQuU7aXNAYtw=@vger.kernel.org X-Gm-Message-State: AOJu0YyLXwhk8fdcRWC+BMlEH2qKcI6B2Uwl2gw6HzGSSx7I4J67DUoM e2uai+c0rMb3PI7u5wwJqVi/oQmuYdlCGe6NVDXv9V6MznFed0UBwGDj+8b3zLK/duQ= X-Gm-Gg: ATEYQzxWwspZ6Zc4XDmwHyF3L8oXCOkBK/20aBLQ2J42XmCp4pMnUHh0vkEdr3fW2lv eNf8VCHbPyJVLHo0n9FPrcy+4E6kMEXxWC7GoPVdBJbngfOlU8yD3btpSVPwYfdOK29nWixynSL tPdknXpmz7y2Z91SphXmi6Uit2CZTONfPUvqe2optoA+oPORT+FFhXTPHdFA0+dt1ZJZnMbKEwf 0WoGVRmhaH0EWDkRvLNL+iJH0mIhV8gbYw6OggHtp8nZJKQWEIJSXfCE1c5HG15MUhuKgLHdtUp YfI6MeTY9F08RjboCIe/s2uUcBVqnoK2MFFNGF8JN/cmfBT5mYyiQ2oXYWBcdM71O0Rnf/7Z0lY XNH/yXwE9saVpcQ6HorlIJvE4byqTBE4srnlhGQC77EmPSpxQu++iEM/mJjwXs1TD1gojehiM/0 0H8jcTJrd0PYwrcbEEmnSY7/sm+3ALmtVfxnEHy9vynw3haJBv8o9V/qEzqGDnsBGaB4Ffd40w6 CDY X-Received: by 2002:ad4:5ca5:0:b0:89a:2fe7:91d0 with SMTP id 6a1803df08f44-89ce8f5def7mr11945646d6.51.1774582421027; Thu, 26 Mar 2026 20:33:41 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:40 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 04/10] liveupdate: Protect FLB lists with luo_register_rwlock Date: Fri, 27 Mar 2026 03:33:28 +0000 Message-ID: <20260327033335.696621-5-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Because liveupdate FLB objects will soon drop their persistent module references when registered, list traversals must be protected against concurrent module unloading. To provide this protection, utilize the global luo_register_rwlock. It protects the global registry of FLBs and the handler's specific list of FLB dependencies. Read locks are used during concurrent list traversals (e.g., during preservation and serialization). Write locks are taken during registration and unregistration. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav (Google) --- include/linux/liveupdate.h | 1 + kernel/liveupdate/luo_flb.c | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/liveupdate.h b/include/linux/liveupdate.h index dd11fdc76a5f..73ca84de3eae 100644 --- a/include/linux/liveupdate.h +++ b/include/linux/liveupdate.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include =20 diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 317c02a94da5..3c91d0008eb1 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -262,17 +262,20 @@ int luo_flb_file_preserve(struct liveupdate_file_hand= ler *fh) struct luo_flb_link *iter; int err =3D 0; =20 + down_read(&luo_register_rwlock); list_for_each_entry(iter, flb_list, list) { err =3D luo_flb_file_preserve_one(iter->flb); if (err) goto exit_err; } + up_read(&luo_register_rwlock); =20 return 0; =20 exit_err: list_for_each_entry_continue_reverse(iter, flb_list, list) luo_flb_file_unpreserve_one(iter->flb); + up_read(&luo_register_rwlock); =20 return err; } @@ -294,6 +297,7 @@ void luo_flb_file_unpreserve(struct liveupdate_file_han= dler *fh) struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; =20 + guard(rwsem_read)(&luo_register_rwlock); list_for_each_entry_reverse(iter, flb_list, list) luo_flb_file_unpreserve_one(iter->flb); } @@ -314,6 +318,7 @@ void luo_flb_file_finish(struct liveupdate_file_handler= *fh) struct list_head *flb_list =3D &ACCESS_PRIVATE(fh, flb_list); struct luo_flb_link *iter; =20 + guard(rwsem_read)(&luo_register_rwlock); list_for_each_entry_reverse(iter, flb_list, list) luo_flb_file_finish_one(iter->flb); } @@ -377,6 +382,8 @@ int liveupdate_register_flb(struct liveupdate_file_hand= ler *fh, if (!luo_session_quiesce()) return -EBUSY; =20 + down_write(&luo_register_rwlock); + /* Check that this FLB is not already linked to this file handler */ err =3D -EEXIST; list_for_each_entry(iter, flb_list, list) { @@ -418,11 +425,13 @@ int liveupdate_register_flb(struct liveupdate_file_ha= ndler *fh, private->users++; link->flb =3D flb; list_add_tail(&no_free_ptr(link)->list, flb_list); + up_write(&luo_register_rwlock); luo_session_resume(); =20 return 0; =20 err_resume: + up_write(&luo_register_rwlock); luo_session_resume(); return err; } @@ -466,6 +475,8 @@ int liveupdate_unregister_flb(struct liveupdate_file_ha= ndler *fh, if (!luo_session_quiesce()) return -EBUSY; =20 + down_write(&luo_register_rwlock); + /* Find and remove the link from the file handler's list */ list_for_each_entry(iter, flb_list, list) { if (iter->flb =3D=3D flb) { @@ -490,11 +501,13 @@ int liveupdate_unregister_flb(struct liveupdate_file_= handler *fh, module_put(flb->ops->owner); } =20 + up_write(&luo_register_rwlock); luo_session_resume(); =20 return 0; =20 err_resume: + up_write(&luo_register_rwlock); luo_session_resume(); return err; } @@ -660,6 +673,7 @@ void luo_flb_serialize(void) struct liveupdate_flb *gflb; int i =3D 0; =20 + guard(rwsem_read)(&luo_register_rwlock); list_private_for_each_entry(gflb, &luo_flb_global.list, private.list) { struct luo_flb_private *private =3D luo_flb_get_private(gflb); =20 --=20 2.43.0