aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2016-07-29 09:37:54 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-31 00:11:08 -0400
commit36b232c880c99fc03e135198c7c08d3d4b4f83ab (patch)
tree619366c479c5678cda7783f575b1a0e64d66cd9c
parentc78ebe1df01f4ef3fb07be1359bc34df6708d99c (diff)
macsec: RXSAs don't need to hold a reference on RXSCs
Following the previous patch, RXSCs are held and properly refcounted in the RX path (instead of being implicitly held by their SA), so the SA doesn't need to hold a reference on its parent RXSC. This also avoids panics on module unload caused by the double layer of RCU callbacks (call_rcu frees the RXSA, which puts the final reference on the RXSC and allows to free it in its own call_rcu) that commit b196c22af5c3 ("macsec: add rcu_barrier() on module exit") didn't protect against. There were also some refcounting bugs in macsec_add_rxsa where I didn't put the reference on the RXSC on the error paths, which would lead to memory leaks. Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/macsec.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 718cf98023ff..7f5c5e0f9cf9 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -344,7 +344,6 @@ static void free_rxsa(struct rcu_head *head)
344 344
345 crypto_free_aead(sa->key.tfm); 345 crypto_free_aead(sa->key.tfm);
346 free_percpu(sa->stats); 346 free_percpu(sa->stats);
347 macsec_rxsc_put(sa->sc);
348 kfree(sa); 347 kfree(sa);
349} 348}
350 349
@@ -1653,7 +1652,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
1653 1652
1654 rtnl_lock(); 1653 rtnl_lock();
1655 rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy); 1654 rx_sc = get_rxsc_from_nl(genl_info_net(info), attrs, tb_rxsc, &dev, &secy);
1656 if (IS_ERR(rx_sc) || !macsec_rxsc_get(rx_sc)) { 1655 if (IS_ERR(rx_sc)) {
1657 rtnl_unlock(); 1656 rtnl_unlock();
1658 return PTR_ERR(rx_sc); 1657 return PTR_ERR(rx_sc);
1659 } 1658 }