From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8C74395AE2 for ; Tue, 30 Jun 2026 19:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782848519; cv=none; b=QrrNpltuRpsNStk8A6LPFhMxqGW7iQ0pNv34w5+SalfxGqqMvNF0tFQlVmk7Jw4nDlEb0vlUkOaN8+oEUZeksSatzy+TYHxrFh4kOUZz9gFrQqTCgoP7IM0CFM7St8h0Obm17p1ZuPNulTz1fGh43MHNnlZQOVu1Y8SKCS0YAGw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782848519; c=relaxed/simple; bh=N+fkLPaJtBHvYepijfc2DpmRWKI3YgJVvlUlJ4cGwy4=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=HYQCWZORRKuTWlB1cL5djQaUwMhlu05+rn+PRAEkla0R0WtjHr3OgbyJA27Rl+ubrQBvijzhVP5+jzrmh88JaX/IhQcZEiiy/wWXoqMOJaDeNWGnz+b5jNtxRdfFr6Y0ucimqT914PL7DipF2EQYoA7cN9p3/5SnNoYiwzMWOCA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ONzg81oF; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ONzg81oF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A0481F00A3A; Tue, 30 Jun 2026 19:41:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1782848518; bh=m1Hu7A4UhmYRhe1m1e8rBZ7Nl7tQc2Vk+DTc471ehKc=; h=Date:From:To:Cc:In-Reply-To:References:Subject; b=ONzg81oFk/PDWeX6IROp4+f0i7JoVDhUBuurseMfTapXHzDzE4scvfjRmBR1Mh/bc JPRHWvBjPQLNz2zyKN2zBhSO7L+ofXep5snit5Ar5o2i9tzWGyyReUHPZ8Ab3SUTy5 kEc+FnQK46TIjTJOFW+lpGFVyH0UXfF6txN9b9KZP77d671ndnh1Nlrsy9NbGhcM3K Ac108C2qM56ZZ0EAAxNQm/YCH1JTgX46p87ZaXmG7IjOA3QFct9v8Fl3OQxvtLSUYN 03YoYhar2ZLdz4v0dQQTz4e6gwuy0ws8PavxEteU9ssdm9Oj3TdF2qj5AsLtGqa5OB oXGb0PC+wyEyw== Received: from phl-compute-10.internal (phl-compute-10.internal [10.202.2.50]) by mailfauth.phl.internal (Postfix) with ESMTP id 6609AF40068; Tue, 30 Jun 2026 15:41:57 -0400 (EDT) Received: from phl-imap-15 ([10.202.2.104]) by phl-compute-10.internal (MEProxy); Tue, 30 Jun 2026 15:41:57 -0400 X-ME-Sender: X-ME-Proxy-Cause: dmFkZTFAPBwvbmhzGjVyCOgmT565eqnNKdGTHLZLtgQb+uinOgWLIybyc7yG3a/6L7j8v4 GFcIM16Ly/rGLMH5WPvNN9UKC9df2+sY3hLbgqnac1dARd6Sc/VyiD2xvBDcJqw916u70o HGfaclnUk5OTTXYTAyRmx9XHI/tgsTHQwBzU5XZQrus2ULNbpSCd450sGKeI9ZHQrLMLEv x1SjodKGAGhTIiWLLi8PBMDI3d8e+kjbYMsYr8X2J8BXF1Ti2LMX70Cztn6MvMOUMYOgLA DmbQt5fS4p+YHTZoKlGDQwrKsYZTN8jSXgbL3eW2Gyi7GISmx70rtLem2O5s7BXYTYlOU7 IPpIWfD978FhT7x73O15cs2u/X1u7UKiW65oJIM8HP8Ot/i3SRGJmTbZOoXaUpDbdktwFw apwjx2WOYYOBFKI10a+s4OHFqbFNWMQ+UZFHt+LrmlHnusJOpVZLzqwrXOP++Gx6x5WVg9 8SY6p1s3rzWgVLkBZy3bvSK6Az5fuhyqMupL3r3teU3woKULQWedunCkcBC5h4o/OdL5Jc y2G4TIfEoRZRjgIjJzFJZo2aDsp2Yv0hSTIoXi2DAPFeNJwWmqh3DYzlDqbBXOl1R5vGXa Yvx4iLz2sThtMsoZAb0ajHcJSxew7+AeH285WR9ExaD0DS3gA6WX+SaxMeiQ X-ME-Proxy: Feedback-ID: ifa6e4810:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 42B24780AB5; Tue, 30 Jun 2026 15:41:57 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ThreadId: A9AULPwk-68B Date: Tue, 30 Jun 2026 15:41:37 -0400 From: "Chuck Lever" To: "Liam R. Howlett (Oracle)" , "Andrew Morton" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, maple-tree@lists.infradead.org, "Chris Mason" Message-Id: In-Reply-To: <20260630190843.3563858-13-liam@infradead.org> References: <20260630190843.3563858-1-liam@infradead.org> <20260630190843.3563858-13-liam@infradead.org> Subject: Re: [PATCH v2 12/19] maple_tree: Catch race in mas_alloc_cyclic() Content-Type: text/plain Content-Transfer-Encoding: 7bit On Tue, Jun 30, 2026, at 3:08 PM, Liam R. Howlett (Oracle) wrote: > If mas_alloc_cyclic() is called during a low memory situation, it is > possible the lock may be dropped so reclaim can occur. There is a > window where some other task may allocate the same id and cause the > mas_insert() to fail with -EEXIST. In this scenario the function will > return -EEXIST, which is not expected. > > Modifying the retry on mas_nomem() to re-search for a slot means that > any race with other writes will not matter as the lock will be held > between finding the index and writing the index. > > Moving the flag logic avoids cases where the flag is modified on drop > lock/reacquire or when the write fails after clearing the flag. > > No existing users are exposed to this issue. > > Fixes: 9b6713cc75229 ("maple_tree: Add mtree_alloc_cyclic()") > Reported-by: Chris Mason > Cc: Chuck Lever > Signed-off-by: Liam R. Howlett (Oracle) Reviewed-by: Chuck Lever -- Chuck Lever