From nobody Thu Apr 2 18:49:13 2026 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3ED1536CDFE for ; Fri, 27 Mar 2026 03:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582421; cv=none; b=aoOYYbUJ+aYYiiHW1KGo/1jGQ1Yhkno4+P/wFgTm6eVtfhdZ98grWj2KHxRqTI1OjLVg0V3+IEELfeveuSdsKNoHY0/ywNgsxgLDvuSaNHVKdQ6CsvZygrBaeoLxknuCrymz+alMatRjbw6+7qCgNZ/AVyzjKbPlNQGqXWGEtAA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774582421; c=relaxed/simple; bh=9nimeFZPQhAj+PyTPjWVOo8WOEyYl0Utw6litWdH8W4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cd7Y77gttsD59xLGaI1NgYc3B6OqTpMdCxLENGZqVFWEAIbgAPwcUyjPKPrySVHbZuOiv2yJdCbNvlwX0PRtXIpOQwYDqrdYP+VtFuwT+lJ1ZsD/0DIJCgB6WxCWzmPuHnLCrxX+4Z4mXUTHVf42BHe8exINng5r9mQFqsZzbY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com; spf=pass smtp.mailfrom=soleen.com; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b=XU1qpxHT; arc=none smtp.client-ip=209.85.219.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=soleen.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=soleen.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=soleen.com header.i=@soleen.com header.b="XU1qpxHT" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-89c5446f3caso20518166d6.2 for ; Thu, 26 Mar 2026 20:33:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; t=1774582419; x=1775187219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=w0STs1QLqmbfKiY/OTrM4XieB5E7WPH8bzjLowLKVe4=; b=XU1qpxHT/zkWpV/AyKUyb9kruDnavCOYzy0X697vDHOzxhJYB7QCoRdtjGyvGIBfk1 qkCnQoyPBSbVGDmNPyrzLy3WPN6QftjJ76N2Ygwsao/FGAoJHaI2kpJCMNpo2UCaCN2M lAfBAt0oAMVu+DPtiEb+pJL9Tq9kUr8sgohPu3Sc5xx1BWArS0Q6c4g/hyqss7FDi4/C DXPzdfutAsjugVoPuH6ITxN11KOH56TBrgZa9vmi86MtUIjr8qZbPuQVOaw80OqxJ/BU gigkyS1fCqt8R8l1e2D2xtvf+qkwKY+sEZb5E1Xw1/gTUtlbgbjRcn7gXGfWwYmPr2KJ CIMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774582419; x=1775187219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=w0STs1QLqmbfKiY/OTrM4XieB5E7WPH8bzjLowLKVe4=; b=tVgzCaXtzz5otghwORq+opaxV6ym9rifnLr6EPNKWGOelRYGM6ObrMop6fP3HSZOQw yhQ/99zZIiPL0ZuItc0UtKxTaeW6yNKdzGHuS9ww4NtuXmTUFRdgeOa7iiBpP5aSysYd HVBMTwx6wSbddKYd+ImzG2KLZkDc4L0S/3sDO4KYMBf7hZuU7kXIFVf9m8Zjf9097+1Z 0Q/oCYUtxUoOKVKzQ69ImAncwdi/cELzy6z4q+8KroXcyOe8GMB3M6yPUDoLI/Q+Spr3 8AujgkAWTnb6AgSHNfyCRV6vwKIYFN2WY33hPsT4ItIYapVdw9HDRRtIzaypgx+Db2ZR m+/w== X-Forwarded-Encrypted: i=1; AJvYcCX495ybxea7Qc3FmDLfk6Rygq2pgLs+3QGr03h9uTT6S1JIRMpb+9Nc63yiBqyLRBR4/7h2h37r9hpP3cM=@vger.kernel.org X-Gm-Message-State: AOJu0YyITROHc3Sy+EAN32QBDza5X+voehwMUb7jbfBhvB3BFuDY3ZhG kTBDEBknGERkJtJJhGpHEg4dgbNP2ezW5ijq7oLWiP6JCVSL7m40Wbu+QIaA2Kr7dVE= X-Gm-Gg: ATEYQzzaHtaMzM14M3f8oeiYsc3ARgIGvYwWNZe3YXqNRypSrOrZXxppK2NwVoZa4u1 qg+jAKyiNpvE6mX1OGEtQwOU08Hm8nNi8841kvc8/cdtP89Rv4dMHl+nXCIORF6DikbE6LnTWN5 QE7bAlp6rmuFlZKryp9ISTVQ9qUbmY79q4suB93HKcWvnzzD9X3EgkCKmydyUWyHf3pfn4WFuzL kz49HnRWgX7WtJzw+lqfxQ3sAmrPspDOzwMomzOjyKPoJw186Gbj+QVGUBRq8uTu1Dy08e8wOgA AJJMSmpDMHSTWwEgOlHhHeT+x3x2wA3FZUV9A24frOavLQBlQzZlZFSOiOVIi2rCFjb5jAV0Ev3 js/suuFJup8zPpy8a3i+lkusF/KKG1ag/FOD5B+ERllUeqyNJ/hujhM3bFuelYs1ANJct5f1Cuv K4bN3urBtuPieUVLLuHMqVLQBJTwO8BPYctvn6qg7UWa8s9uZr+tshIB/U8SSPwV77yx9QNlpJx NN1 X-Received: by 2002:a05:6214:4a04:b0:89c:d408:b52b with SMTP id 6a1803df08f44-89ce8f436f1mr11006356d6.48.1774582419011; Thu, 26 Mar 2026 20:33:39 -0700 (PDT) Received: from plex.localdomain ([71.181.43.54]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89cd5a22711sm46519186d6.27.2026.03.26.20.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2026 20:33:38 -0700 (PDT) From: Pasha Tatashin To: rppt@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, pasha.tatashin@soleen.com, dmatlack@google.com, pratyush@kernel.org, skhawaja@google.com Subject: [PATCH v3 02/10] liveupdate: Synchronize lazy initialization of FLB private state Date: Fri, 27 Mar 2026 03:33:26 +0000 Message-ID: <20260327033335.696621-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260327033335.696621-1-pasha.tatashin@soleen.com> References: <20260327033335.696621-1-pasha.tatashin@soleen.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The luo_flb_get_private() function, which is responsible for lazily initializing the private state of FLB objects, can be called concurrently from multiple threads. This creates a data race on the 'initialized' flag and can lead to multiple executions of mutex_init() and INIT_LIST_HEAD() on the same memory. Introduce a static spinlock (luo_flb_init_lock) local to the function to synchronize the initialization path. Use smp_load_acquire() and smp_store_release() for memory ordering between the fast path and the slow path. Signed-off-by: Pasha Tatashin Reviewed-by: Pratyush Yadav --- kernel/liveupdate/luo_flb.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/liveupdate/luo_flb.c b/kernel/liveupdate/luo_flb.c index 855af655b09b..317c02a94da5 100644 --- a/kernel/liveupdate/luo_flb.c +++ b/kernel/liveupdate/luo_flb.c @@ -89,13 +89,18 @@ struct luo_flb_link { static struct luo_flb_private *luo_flb_get_private(struct liveupdate_flb *= flb) { struct luo_flb_private *private =3D &ACCESS_PRIVATE(flb, private); + static DEFINE_SPINLOCK(luo_flb_init_lock); =20 + if (smp_load_acquire(&private->initialized)) + return private; + + guard(spinlock)(&luo_flb_init_lock); if (!private->initialized) { mutex_init(&private->incoming.lock); mutex_init(&private->outgoing.lock); INIT_LIST_HEAD(&private->list); private->users =3D 0; - private->initialized =3D true; + smp_store_release(&private->initialized, true); } =20 return private; --=20 2.43.0