netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <simon.horman@corigine.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org, oss-drivers@corigine.com,
	Yanguo Li <yanguo.li@corigine.com>,
	Dan Carpenter <error27@gmail.com>
Subject: Re: [PATCH net] nfp: flower: avoid taking mutex in atomic context
Date: Tue, 31 Jan 2023 13:15:46 +0100	[thread overview]
Message-ID: <Y9kGcnKUUO5HURZX@corigine.com> (raw)
In-Reply-To: <Y9j/Rvi9CSYX2qSk@unreal>

On Tue, Jan 31, 2023 at 01:45:10PM +0200, Leon Romanovsky wrote:
> On Tue, Jan 31, 2023 at 09:03:13AM +0100, Simon Horman wrote:
> > From: Yanguo Li <yanguo.li@corigine.com>
> > 
> > A mutex may sleep, which is not permitted in atomic context.
> > Avoid a case where this may arise by moving the to
> > nfp_flower_lag_get_info_from_netdev() in nfp_tun_write_neigh() spinlock.
> > 
> > Fixes: abc210952af7 ("nfp: flower: tunnel neigh support bond offload")
> > Reported-by: Dan Carpenter <error27@gmail.com>
> > Signed-off-by: Yanguo Li <yanguo.li@corigine.com>
> > Signed-off-by: Simon Horman <simon.horman@corigine.com>
> > ---
> >  drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
> > index a8678d5612ee..060a77f2265d 100644
> > --- a/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
> > +++ b/drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
> > @@ -460,6 +460,7 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
> >  			    sizeof(struct nfp_tun_neigh_v4);
> >  	unsigned long cookie = (unsigned long)neigh;
> >  	struct nfp_flower_priv *priv = app->priv;
> > +	struct nfp_tun_neigh_lag lag_info;
> >  	struct nfp_neigh_entry *nn_entry;
> >  	u32 port_id;
> >  	u8 mtype;
> > @@ -468,6 +469,11 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
> >  	if (!port_id)
> >  		return;
> >  
> > +	if ((port_id & NFP_FL_LAG_OUT) == NFP_FL_LAG_OUT) {
> > +		memset(&lag_info, 0, sizeof(struct nfp_tun_neigh_lag));
> 
> This memset can be removed if you initialize lag_info to zero.
> struct nfp_tun_neigh_lag lag_info = {};

Happy to change if that is preferred.
Is it preferred?

> Thanks
> 
> > +		nfp_flower_lag_get_info_from_netdev(app, netdev, &lag_info);
> > +	}
> > +
> >  	spin_lock_bh(&priv->predt_lock);
> >  	nn_entry = rhashtable_lookup_fast(&priv->neigh_table, &cookie,
> >  					  neigh_table_params);
> > @@ -515,7 +521,7 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
> >  		neigh_ha_snapshot(common->dst_addr, neigh, netdev);
> >  
> >  		if ((port_id & NFP_FL_LAG_OUT) == NFP_FL_LAG_OUT)
> > -			nfp_flower_lag_get_info_from_netdev(app, netdev, lag);
> > +			memcpy(lag, &lag_info, sizeof(struct nfp_tun_neigh_lag));
> >  		common->port_id = cpu_to_be32(port_id);
> >  
> >  		if (rhashtable_insert_fast(&priv->neigh_table,
> > -- 
> > 2.30.2
> > 

  reply	other threads:[~2023-01-31 12:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-31  8:03 [PATCH net] nfp: flower: avoid taking mutex in atomic context Simon Horman
2023-01-31 11:45 ` Leon Romanovsky
2023-01-31 12:15   ` Simon Horman [this message]
2023-01-31 13:27     ` Leon Romanovsky
2023-01-31 21:21       ` Jakub Kicinski
2023-02-01  8:21         ` Leon Romanovsky
2023-02-02  4:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y9kGcnKUUO5HURZX@corigine.com \
    --to=simon.horman@corigine.com \
    --cc=davem@davemloft.net \
    --cc=error27@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    --cc=pabeni@redhat.com \
    --cc=yanguo.li@corigine.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).