diff mbox series

[net] net: bridge: mcast: Associate the seqcount with its protecting lock.

Message ID 20210928141049.593833-1-bigeasy@linutronix.de (mailing list archive)
State Accepted
Commit f936bb42aeb94a069bec7c9e04100d199c372956
Delegated to: Netdev Maintainers
Headers show
Series [net] net: bridge: mcast: Associate the seqcount with its protecting lock. | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/kdoc success Errors and warnings before: 3 this patch: 3
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 31 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 3 this patch: 3
netdev/header_inline success Link

Commit Message

Sebastian Andrzej Siewior Sept. 28, 2021, 2:10 p.m. UTC
From: Thomas Gleixner <tglx@linutronix.de>

The sequence count bridge_mcast_querier::seq is protected by
net_bridge::multicast_lock but seqcount_init() does not associate the
seqcount with the lock. This leads to a warning on PREEMPT_RT because
preemption is still enabled.

Let seqcount_init() associate the seqcount with lock that protects the
write section. Remove lockdep_assert_held_once() because lockdep already checks
whether the associated lock is held.
	
Fixes: 67b746f94ff39 ("net: bridge: mcast: make sure querier port/address updates are consistent")
Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Tested-by: Mike Galbraith <efault@gmx.de>
---
 net/bridge/br_multicast.c |    6 ++----
 net/bridge/br_private.h   |    2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

Comments

Nikolay Aleksandrov Sept. 28, 2021, 2:41 p.m. UTC | #1
On 28/09/2021 17:10, Sebastian Andrzej Siewior wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
> 
> The sequence count bridge_mcast_querier::seq is protected by
> net_bridge::multicast_lock but seqcount_init() does not associate the
> seqcount with the lock. This leads to a warning on PREEMPT_RT because
> preemption is still enabled.
> 
> Let seqcount_init() associate the seqcount with lock that protects the
> write section. Remove lockdep_assert_held_once() because lockdep already checks
> whether the associated lock is held.
> 	
> Fixes: 67b746f94ff39 ("net: bridge: mcast: make sure querier port/address updates are consistent")
> Reported-by: Mike Galbraith <efault@gmx.de>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Tested-by: Mike Galbraith <efault@gmx.de>
> ---
>  net/bridge/br_multicast.c |    6 ++----
>  net/bridge/br_private.h   |    2 +-
>  2 files changed, 3 insertions(+), 5 deletions(-)
> 
> --- a/net/bridge/br_multicast.c
> +++ b/net/bridge/br_multicast.c
> @@ -1677,8 +1677,6 @@ static void br_multicast_update_querier(
>  					int ifindex,
>  					struct br_ip *saddr)
>  {
> -	lockdep_assert_held_once(&brmctx->br->multicast_lock);
> -
>  	write_seqcount_begin(&querier->seq);
>  	querier->port_ifidx = ifindex;
>  	memcpy(&querier->addr, saddr, sizeof(*saddr));
> @@ -3867,13 +3865,13 @@ void br_multicast_ctx_init(struct net_br
>  
>  	brmctx->ip4_other_query.delay_time = 0;
>  	brmctx->ip4_querier.port_ifidx = 0;
> -	seqcount_init(&brmctx->ip4_querier.seq);
> +	seqcount_spinlock_init(&brmctx->ip4_querier.seq, &br->multicast_lock);
>  	brmctx->multicast_igmp_version = 2;
>  #if IS_ENABLED(CONFIG_IPV6)
>  	brmctx->multicast_mld_version = 1;
>  	brmctx->ip6_other_query.delay_time = 0;
>  	brmctx->ip6_querier.port_ifidx = 0;
> -	seqcount_init(&brmctx->ip6_querier.seq);
> +	seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock);
>  #endif
>  
>  	timer_setup(&brmctx->ip4_mc_router_timer,
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -82,7 +82,7 @@ struct bridge_mcast_other_query {
>  struct bridge_mcast_querier {
>  	struct br_ip addr;
>  	int port_ifidx;
> -	seqcount_t seq;
> +	seqcount_spinlock_t seq;
>  };
>  
>  /* IGMP/MLD statistics */
> 

Thanks for fixing it,
Acked-by: Nikolay Aleksandrov <nikolay@nvidia.com>
patchwork-bot+netdevbpf@kernel.org Sept. 29, 2021, 2:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 28 Sep 2021 16:10:49 +0200 you wrote:
> From: Thomas Gleixner <tglx@linutronix.de>
> 
> The sequence count bridge_mcast_querier::seq is protected by
> net_bridge::multicast_lock but seqcount_init() does not associate the
> seqcount with the lock. This leads to a warning on PREEMPT_RT because
> preemption is still enabled.
> 
> [...]

Here is the summary with links:
  - [net] net: bridge: mcast: Associate the seqcount with its protecting lock.
    https://git.kernel.org/netdev/net/c/f936bb42aeb9

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1677,8 +1677,6 @@  static void br_multicast_update_querier(
 					int ifindex,
 					struct br_ip *saddr)
 {
-	lockdep_assert_held_once(&brmctx->br->multicast_lock);
-
 	write_seqcount_begin(&querier->seq);
 	querier->port_ifidx = ifindex;
 	memcpy(&querier->addr, saddr, sizeof(*saddr));
@@ -3867,13 +3865,13 @@  void br_multicast_ctx_init(struct net_br
 
 	brmctx->ip4_other_query.delay_time = 0;
 	brmctx->ip4_querier.port_ifidx = 0;
-	seqcount_init(&brmctx->ip4_querier.seq);
+	seqcount_spinlock_init(&brmctx->ip4_querier.seq, &br->multicast_lock);
 	brmctx->multicast_igmp_version = 2;
 #if IS_ENABLED(CONFIG_IPV6)
 	brmctx->multicast_mld_version = 1;
 	brmctx->ip6_other_query.delay_time = 0;
 	brmctx->ip6_querier.port_ifidx = 0;
-	seqcount_init(&brmctx->ip6_querier.seq);
+	seqcount_spinlock_init(&brmctx->ip6_querier.seq, &br->multicast_lock);
 #endif
 
 	timer_setup(&brmctx->ip4_mc_router_timer,
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -82,7 +82,7 @@  struct bridge_mcast_other_query {
 struct bridge_mcast_querier {
 	struct br_ip addr;
 	int port_ifidx;
-	seqcount_t seq;
+	seqcount_spinlock_t seq;
 };
 
 /* IGMP/MLD statistics */