[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240424144831.GD42092@kernel.org>
Date: Wed, 24 Apr 2024 15:48:31 +0100
From: Simon Horman <horms@...nel.org>
To: Petr Machata <petrm@...dia.com>
Cc: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, Ido Schimmel <idosch@...dia.com>,
Jiri Pirko <jiri@...nulli.us>, Alexander Zubkov <green@...tor.net>,
mlxsw@...dia.com
Subject: Re: [PATCH net 2/9] mlxsw: spectrum_acl_tcam: Fix race during rehash
delayed work
On Mon, Apr 22, 2024 at 05:25:55PM +0200, Petr Machata wrote:
> From: Ido Schimmel <idosch@...dia.com>
>
> The purpose of the rehash delayed work is to reduce the number of masks
> (eRPs) used by an ACL region as the eRP bank is a global and limited
> resource.
>
> This is done in three steps:
>
> 1. Creating a new set of masks and a new ACL region which will use the
> new masks and to which the existing filters will be migrated to. The
> new region is assigned to 'vregion->region' and the region from which
> the filters are migrated from is assigned to 'vregion->region2'.
>
> 2. Migrating all the filters from the old region to the new region.
>
> 3. Destroying the old region and setting 'vregion->region2' to NULL.
>
> Only the second steps is performed under the 'vregion->lock' mutex
> although its comments says that among other things it "Protects
> consistency of region, region2 pointers".
>
> This is problematic as the first step can race with filter insertion
> from user space that uses 'vregion->region', but under the mutex.
>
> Fix by holding the mutex across the entirety of the delayed work and not
> only during the second step.
>
> Fixes: 2bffc5322fd8 ("mlxsw: spectrum_acl: Don't take mutex in mlxsw_sp_acl_tcam_vregion_rehash_work()")
> Signed-off-by: Ido Schimmel <idosch@...dia.com>
> Tested-by: Alexander Zubkov <green@...tor.net>
> Reviewed-by: Petr Machata <petrm@...dia.com>
> Signed-off-by: Petr Machata <petrm@...dia.com>
Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists