* [PATCH net v2 0/9] macsec: a few fixes
@ 2016-04-22 9:28 Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc Sabrina Dubroca
` (9 more replies)
0 siblings, 10 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
Some small fixes for the macsec driver:
- possible NULL pointer dereferences
- netlink dumps fixes: RTNL locking, consistent dumps
- a reference counting bug
- wrong name for uapi constant
- a few memory leaks
Patches 1 to 5 are the same as in v1, patches 6 to 9 are new.
Patch 6 fixes the memleak that Lance spotted in v1.
Sabrina Dubroca (9):
macsec: add missing NULL check after kmalloc
macsec: take rtnl lock before for_each_netdev
macsec: don't put a NULL rxsa
macsec: fix rx_sa refcounting with decrypt callback
macsec: add consistency check to netlink dumps
macsec: fix memory leaks around rx_handler (un)registration
macsec: fix SA leak if initialization fails
macsec: add missing macsec prefix in uapi
macsec: fix netlink attribute validation
drivers/net/macsec.c | 65 +++++++++++++++++++++++++++---------------
include/uapi/linux/if_macsec.h | 4 +--
2 files changed, 44 insertions(+), 25 deletions(-)
--
2.8.0
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:35 ` Lino Sanfilippo
2016-04-22 9:28 ` [PATCH net v2 2/9] macsec: take rtnl lock before for_each_netdev Sabrina Dubroca
` (8 subsequent siblings)
9 siblings, 1 reply; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 84d3e5ca8817..f691030ee3df 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -1622,8 +1622,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
}
rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
- if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
- secy->icv_len)) {
+ if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
+ secy->key_len, secy->icv_len)) {
rtnl_unlock();
return -ENOMEM;
}
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 2/9] macsec: take rtnl lock before for_each_netdev
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 3/9] macsec: don't put a NULL rxsa Sabrina Dubroca
` (7 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index f691030ee3df..5f3ea8026074 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2268,8 +2268,6 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
if (!hdr)
return -EMSGSIZE;
- rtnl_lock();
-
if (nla_put_u32(skb, MACSEC_ATTR_IFINDEX, dev->ifindex))
goto nla_put_failure;
@@ -2429,14 +2427,11 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
nla_nest_end(skb, rxsc_list);
- rtnl_unlock();
-
genlmsg_end(skb, hdr);
return 0;
nla_put_failure:
- rtnl_unlock();
genlmsg_cancel(skb, hdr);
return -EMSGSIZE;
}
@@ -2450,6 +2445,7 @@ static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)
dev_idx = cb->args[0];
d = 0;
+ rtnl_lock();
for_each_netdev(net, dev) {
struct macsec_secy *secy;
@@ -2467,6 +2463,7 @@ next:
}
done:
+ rtnl_unlock();
cb->args[0] = d;
return skb->len;
}
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 3/9] macsec: don't put a NULL rxsa
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 2/9] macsec: take rtnl lock before for_each_netdev Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 4/9] macsec: fix rx_sa refcounting with decrypt callback Sabrina Dubroca
` (6 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
The "deliver:" path of macsec_handle_frame can be called with
rx_sa == NULL. Check rx_sa != NULL before calling macsec_rxsa_put().
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 5f3ea8026074..2a2136b7d324 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -1161,7 +1161,8 @@ deliver:
macsec_extra_len(macsec_skb_cb(skb)->has_sci));
macsec_reset_skb(skb, secy->netdev);
- macsec_rxsa_put(rx_sa);
+ if (rx_sa)
+ macsec_rxsa_put(rx_sa);
count_rx(dev, skb->len);
rcu_read_unlock();
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 4/9] macsec: fix rx_sa refcounting with decrypt callback
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (2 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 3/9] macsec: don't put a NULL rxsa Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 5/9] macsec: add consistency check to netlink dumps Sabrina Dubroca
` (5 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
The decrypt callback macsec_decrypt_done needs a reference on the rx_sa
and releases it before returning, but macsec_handle_frame already
put that reference after macsec_decrypt returned NULL.
Set rx_sa to NULL when the decrypt callback runs so that
macsec_handle_frame knows it must not release the reference.
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 2a2136b7d324..1fd2b147fda1 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -880,12 +880,12 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
macsec_skb_cb(skb)->valid = false;
skb = skb_share_check(skb, GFP_ATOMIC);
if (!skb)
- return NULL;
+ return ERR_PTR(-ENOMEM);
req = aead_request_alloc(rx_sa->key.tfm, GFP_ATOMIC);
if (!req) {
kfree_skb(skb);
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
hdr = (struct macsec_eth_header *)skb->data;
@@ -905,7 +905,7 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
skb = skb_unshare(skb, GFP_ATOMIC);
if (!skb) {
aead_request_free(req);
- return NULL;
+ return ERR_PTR(-ENOMEM);
}
} else {
/* integrity only: all headers + data authenticated */
@@ -921,14 +921,14 @@ static struct sk_buff *macsec_decrypt(struct sk_buff *skb,
dev_hold(dev);
ret = crypto_aead_decrypt(req);
if (ret == -EINPROGRESS) {
- return NULL;
+ return ERR_PTR(ret);
} else if (ret != 0) {
/* decryption/authentication failed
* 10.6 if validateFrames is disabled, deliver anyway
*/
if (ret != -EBADMSG) {
kfree_skb(skb);
- skb = NULL;
+ skb = ERR_PTR(ret);
}
} else {
macsec_skb_cb(skb)->valid = true;
@@ -1146,8 +1146,10 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
secy->validate_frames != MACSEC_VALIDATE_DISABLED)
skb = macsec_decrypt(skb, dev, rx_sa, sci, secy);
- if (!skb) {
- macsec_rxsa_put(rx_sa);
+ if (IS_ERR(skb)) {
+ /* the decrypt callback needs the reference */
+ if (PTR_ERR(skb) != -EINPROGRESS)
+ macsec_rxsa_put(rx_sa);
rcu_read_unlock();
*pskb = NULL;
return RX_HANDLER_CONSUMED;
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 5/9] macsec: add consistency check to netlink dumps
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (3 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 4/9] macsec: fix rx_sa refcounting with decrypt callback Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 6/9] macsec: fix memory leaks around rx_handler (un)registration Sabrina Dubroca
` (4 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
Use genl_dump_check_consistent in dump_secy.
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Suggested-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 1fd2b147fda1..41fbe556ba6d 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2271,6 +2271,8 @@ static int dump_secy(struct macsec_secy *secy, struct net_device *dev,
if (!hdr)
return -EMSGSIZE;
+ genl_dump_check_consistent(cb, hdr, &macsec_fam);
+
if (nla_put_u32(skb, MACSEC_ATTR_IFINDEX, dev->ifindex))
goto nla_put_failure;
@@ -2439,6 +2441,8 @@ nla_put_failure:
return -EMSGSIZE;
}
+static int macsec_generation = 1; /* protected by RTNL */
+
static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)
{
struct net *net = sock_net(skb->sk);
@@ -2449,6 +2453,9 @@ static int macsec_dump_txsc(struct sk_buff *skb, struct netlink_callback *cb)
d = 0;
rtnl_lock();
+
+ cb->seq = macsec_generation;
+
for_each_netdev(net, dev) {
struct macsec_secy *secy;
@@ -2920,6 +2927,8 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
struct net_device *real_dev = macsec->real_dev;
struct macsec_rxh_data *rxd = macsec_data_rtnl(real_dev);
+ macsec_generation++;
+
unregister_netdevice_queue(dev, head);
list_del_rcu(&macsec->secys);
if (list_empty(&rxd->secys))
@@ -3066,6 +3075,8 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
if (err < 0)
goto del_dev;
+ macsec_generation++;
+
dev_hold(real_dev);
return 0;
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 6/9] macsec: fix memory leaks around rx_handler (un)registration
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (4 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 5/9] macsec: add consistency check to netlink dumps Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 7/9] macsec: fix SA leak if initialization fails Sabrina Dubroca
` (3 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
We leak a struct macsec_rxh_data when we unregister the rx_handler in
macsec_dellink.
We also leak a struct macsec_rxh_data in register_macsec_dev if we fail
to register the rx_handler.
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 41fbe556ba6d..826c6c9ce7fd 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2931,8 +2931,10 @@ static void macsec_dellink(struct net_device *dev, struct list_head *head)
unregister_netdevice_queue(dev, head);
list_del_rcu(&macsec->secys);
- if (list_empty(&rxd->secys))
+ if (list_empty(&rxd->secys)) {
netdev_rx_handler_unregister(real_dev);
+ kfree(rxd);
+ }
macsec_del_dev(macsec);
}
@@ -2954,8 +2956,10 @@ static int register_macsec_dev(struct net_device *real_dev,
err = netdev_rx_handler_register(real_dev, macsec_handle_frame,
rxd);
- if (err < 0)
+ if (err < 0) {
+ kfree(rxd);
return err;
+ }
}
list_add_tail_rcu(&macsec->secys, &rxd->secys);
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 7/9] macsec: fix SA leak if initialization fails
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (5 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 6/9] macsec: fix memory leaks around rx_handler (un)registration Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 8/9] macsec: add missing macsec prefix in uapi Sabrina Dubroca
` (2 subsequent siblings)
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Reported-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 826c6c9ce7fd..b37d348b8ea0 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -1627,6 +1627,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
secy->key_len, secy->icv_len)) {
+ kfree(rx_sa);
rtnl_unlock();
return -ENOMEM;
}
@@ -1771,6 +1772,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
tx_sa = kmalloc(sizeof(*tx_sa), GFP_KERNEL);
if (!tx_sa || init_tx_sa(tx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
secy->key_len, secy->icv_len)) {
+ kfree(tx_sa);
rtnl_unlock();
return -ENOMEM;
}
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 8/9] macsec: add missing macsec prefix in uapi
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (6 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 7/9] macsec: fix SA leak if initialization fails Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 9/9] macsec: fix netlink attribute validation Sabrina Dubroca
2016-04-24 18:32 ` [PATCH net v2 0/9] macsec: a few fixes David Miller
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
I accidentally forgot some MACSEC_ prefixes in if_macsec.h.
Fixes: dece8d2b78d1 ("uapi: add MACsec bits")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 12 +++++++-----
include/uapi/linux/if_macsec.h | 4 ++--
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index b37d348b8ea0..9f63cc7b0a73 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -2232,7 +2232,8 @@ static int nla_put_secy(struct macsec_secy *secy, struct sk_buff *skb)
return 1;
if (nla_put_sci(skb, MACSEC_SECY_ATTR_SCI, secy->sci) ||
- nla_put_u64(skb, MACSEC_SECY_ATTR_CIPHER_SUITE, DEFAULT_CIPHER_ID) ||
+ nla_put_u64(skb, MACSEC_SECY_ATTR_CIPHER_SUITE,
+ MACSEC_DEFAULT_CIPHER_ID) ||
nla_put_u8(skb, MACSEC_SECY_ATTR_ICV_LEN, secy->icv_len) ||
nla_put_u8(skb, MACSEC_SECY_ATTR_OPER, secy->operational) ||
nla_put_u8(skb, MACSEC_SECY_ATTR_PROTECT, secy->protect_frames) ||
@@ -3096,7 +3097,7 @@ unregister:
static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[])
{
- u64 csid = DEFAULT_CIPHER_ID;
+ u64 csid = MACSEC_DEFAULT_CIPHER_ID;
u8 icv_len = DEFAULT_ICV_LEN;
int flag;
bool es, scb, sci;
@@ -3111,8 +3112,8 @@ static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[])
icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
switch (csid) {
- case DEFAULT_CIPHER_ID:
- case DEFAULT_CIPHER_ALT:
+ case MACSEC_DEFAULT_CIPHER_ID:
+ case MACSEC_DEFAULT_CIPHER_ALT:
if (icv_len < MACSEC_MIN_ICV_LEN ||
icv_len > MACSEC_MAX_ICV_LEN)
return -EINVAL;
@@ -3185,7 +3186,8 @@ static int macsec_fill_info(struct sk_buff *skb,
if (nla_put_sci(skb, IFLA_MACSEC_SCI, secy->sci) ||
nla_put_u8(skb, IFLA_MACSEC_ICV_LEN, secy->icv_len) ||
- nla_put_u64(skb, IFLA_MACSEC_CIPHER_SUITE, DEFAULT_CIPHER_ID) ||
+ nla_put_u64(skb, IFLA_MACSEC_CIPHER_SUITE,
+ MACSEC_DEFAULT_CIPHER_ID) ||
nla_put_u8(skb, IFLA_MACSEC_ENCODING_SA, tx_sc->encoding_sa) ||
nla_put_u8(skb, IFLA_MACSEC_ENCRYPT, tx_sc->encrypt) ||
nla_put_u8(skb, IFLA_MACSEC_PROTECT, secy->protect_frames) ||
diff --git a/include/uapi/linux/if_macsec.h b/include/uapi/linux/if_macsec.h
index 26b0d1e3e3e7..4c58d9917aa4 100644
--- a/include/uapi/linux/if_macsec.h
+++ b/include/uapi/linux/if_macsec.h
@@ -19,8 +19,8 @@
#define MACSEC_MAX_KEY_LEN 128
-#define DEFAULT_CIPHER_ID 0x0080020001000001ULL
-#define DEFAULT_CIPHER_ALT 0x0080C20001000001ULL
+#define MACSEC_DEFAULT_CIPHER_ID 0x0080020001000001ULL
+#define MACSEC_DEFAULT_CIPHER_ALT 0x0080C20001000001ULL
#define MACSEC_MIN_ICV_LEN 8
#define MACSEC_MAX_ICV_LEN 32
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH net v2 9/9] macsec: fix netlink attribute validation
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (7 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 8/9] macsec: add missing macsec prefix in uapi Sabrina Dubroca
@ 2016-04-22 9:28 ` Sabrina Dubroca
2016-04-24 18:32 ` [PATCH net v2 0/9] macsec: a few fixes David Miller
9 siblings, 0 replies; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:28 UTC (permalink / raw)
To: netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter, Sabrina Dubroca
macsec_validate_attr should check IFLA_MACSEC_REPLAY_PROTECT (not
IFLA_MACSEC_PROTECT) to verify that the replay protection and replay
window arguments are correct.
Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
drivers/net/macsec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 9f63cc7b0a73..c6385617bfb2 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3147,8 +3147,8 @@ static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[])
nla_get_u8(data[IFLA_MACSEC_VALIDATION]) > MACSEC_VALIDATE_MAX)
return -EINVAL;
- if ((data[IFLA_MACSEC_PROTECT] &&
- nla_get_u8(data[IFLA_MACSEC_PROTECT])) &&
+ if ((data[IFLA_MACSEC_REPLAY_PROTECT] &&
+ nla_get_u8(data[IFLA_MACSEC_REPLAY_PROTECT])) &&
!data[IFLA_MACSEC_WINDOW])
return -EINVAL;
--
2.8.0
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc
2016-04-22 9:28 ` [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc Sabrina Dubroca
@ 2016-04-22 9:35 ` Lino Sanfilippo
2016-04-22 9:48 ` Sabrina Dubroca
0 siblings, 1 reply; 14+ messages in thread
From: Lino Sanfilippo @ 2016-04-22 9:35 UTC (permalink / raw)
To: Sabrina Dubroca, netdev
Cc: Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter
On 22.04.2016 11:28, Sabrina Dubroca wrote:
> Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---
> drivers/net/macsec.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> index 84d3e5ca8817..f691030ee3df 100644
> --- a/drivers/net/macsec.c
> +++ b/drivers/net/macsec.c
> @@ -1622,8 +1622,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
> }
>
> rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
> - if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
> - secy->icv_len)) {
> + if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
> + secy->key_len, secy->icv_len)) {
> rtnl_unlock();
> return -ENOMEM;
> }
In case that kmalloc was successful and init_rx_sa failed, the allocated memory should be freed, shouldnt it?.
Regards,
Lino
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc
2016-04-22 9:35 ` Lino Sanfilippo
@ 2016-04-22 9:48 ` Sabrina Dubroca
2016-04-22 10:06 ` Lino Sanfilippo
0 siblings, 1 reply; 14+ messages in thread
From: Sabrina Dubroca @ 2016-04-22 9:48 UTC (permalink / raw)
To: Lino Sanfilippo
Cc: netdev, Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter
2016-04-22, 11:35:03 +0200, Lino Sanfilippo wrote:
>
>
> On 22.04.2016 11:28, Sabrina Dubroca wrote:
> > Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> > Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> > ---
> > drivers/net/macsec.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
> > index 84d3e5ca8817..f691030ee3df 100644
> > --- a/drivers/net/macsec.c
> > +++ b/drivers/net/macsec.c
> > @@ -1622,8 +1622,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
> > }
> >
> > rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
> > - if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
> > - secy->icv_len)) {
> > + if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
> > + secy->key_len, secy->icv_len)) {
> > rtnl_unlock();
> > return -ENOMEM;
> > }
>
>
> In case that kmalloc was successful and init_rx_sa failed, the allocated memory should be freed, shouldnt it?.
Yep, Lance pointed that out in v1:
http://marc.info/?l=linux-netdev&m=146108796406155
But since we have the same code with init_tx_sa, I decided to fix both
in a separate patch (7/9 in this set).
Thanks,
--
Sabrina
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc
2016-04-22 9:48 ` Sabrina Dubroca
@ 2016-04-22 10:06 ` Lino Sanfilippo
0 siblings, 0 replies; 14+ messages in thread
From: Lino Sanfilippo @ 2016-04-22 10:06 UTC (permalink / raw)
To: Sabrina Dubroca
Cc: netdev, Lance Richardson, Hannes Frederic Sowa, Johannes Berg,
Dan Carpenter
On 22.04.2016 11:48, Sabrina Dubroca wrote:
> 2016-04-22, 11:35:03 +0200, Lino Sanfilippo wrote:
>>
>>
>> On 22.04.2016 11:28, Sabrina Dubroca wrote:
>>> Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
>>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>>> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
>>> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
>>> ---
>>> drivers/net/macsec.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
>>> index 84d3e5ca8817..f691030ee3df 100644
>>> --- a/drivers/net/macsec.c
>>> +++ b/drivers/net/macsec.c
>>> @@ -1622,8 +1622,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
>>> }
>>>
>>> rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
>>> - if (init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]), secy->key_len,
>>> - secy->icv_len)) {
>>> + if (!rx_sa || init_rx_sa(rx_sa, nla_data(tb_sa[MACSEC_SA_ATTR_KEY]),
>>> + secy->key_len, secy->icv_len)) {
>>> rtnl_unlock();
>>> return -ENOMEM;
>>> }
>>
>>
>> In case that kmalloc was successful and init_rx_sa failed, the allocated memory should be freed, shouldnt it?.
>
> Yep, Lance pointed that out in v1:
> http://marc.info/?l=linux-netdev&m=146108796406155
>
> But since we have the same code with init_tx_sa, I decided to fix both
> in a separate patch (7/9 in this set).
>
Ah ok, sorry about the noise then :)
Regards,
Lino
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH net v2 0/9] macsec: a few fixes
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
` (8 preceding siblings ...)
2016-04-22 9:28 ` [PATCH net v2 9/9] macsec: fix netlink attribute validation Sabrina Dubroca
@ 2016-04-24 18:32 ` David Miller
9 siblings, 0 replies; 14+ messages in thread
From: David Miller @ 2016-04-24 18:32 UTC (permalink / raw)
To: sd; +Cc: netdev, lrichard, hannes, johannes, dan.carpenter
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Fri, 22 Apr 2016 11:28:00 +0200
> Some small fixes for the macsec driver:
> - possible NULL pointer dereferences
> - netlink dumps fixes: RTNL locking, consistent dumps
> - a reference counting bug
> - wrong name for uapi constant
> - a few memory leaks
>
> Patches 1 to 5 are the same as in v1, patches 6 to 9 are new.
> Patch 6 fixes the memleak that Lance spotted in v1.
Series applied, thanks Sabrina.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2016-04-24 18:32 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-22 9:28 [PATCH net v2 0/9] macsec: a few fixes Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 1/9] macsec: add missing NULL check after kmalloc Sabrina Dubroca
2016-04-22 9:35 ` Lino Sanfilippo
2016-04-22 9:48 ` Sabrina Dubroca
2016-04-22 10:06 ` Lino Sanfilippo
2016-04-22 9:28 ` [PATCH net v2 2/9] macsec: take rtnl lock before for_each_netdev Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 3/9] macsec: don't put a NULL rxsa Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 4/9] macsec: fix rx_sa refcounting with decrypt callback Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 5/9] macsec: add consistency check to netlink dumps Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 6/9] macsec: fix memory leaks around rx_handler (un)registration Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 7/9] macsec: fix SA leak if initialization fails Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 8/9] macsec: add missing macsec prefix in uapi Sabrina Dubroca
2016-04-22 9:28 ` [PATCH net v2 9/9] macsec: fix netlink attribute validation Sabrina Dubroca
2016-04-24 18:32 ` [PATCH net v2 0/9] macsec: a few fixes David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.