Skip to content

Commit f46040e

Browse files
qsndavem330
authored andcommitted
macsec: fix NULL deref in macsec_add_rxsa
Commit 48ef50f added a test on tb_sa[MACSEC_SA_ATTR_PN], but nothing guarantees that it's not NULL at this point. The same code was added to macsec_add_txsa, but there it's not a problem because validate_add_txsa checks that the MACSEC_SA_ATTR_PN attribute is present. Note: it's not possible to reproduce with iproute, because iproute doesn't allow creating an SA without specifying the PN. Fixes: 48ef50f ("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)") Link: https://bugzilla.kernel.org/show_bug.cgi?id=208315 Reported-by: Frantisek Sumsal <fsumsal@redhat.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1aaa62c commit f46040e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/macsec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1753,7 +1753,8 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
17531753
}
17541754

17551755
pn_len = secy->xpn ? MACSEC_XPN_PN_LEN : MACSEC_DEFAULT_PN_LEN;
1756-
if (nla_len(tb_sa[MACSEC_SA_ATTR_PN]) != pn_len) {
1756+
if (tb_sa[MACSEC_SA_ATTR_PN] &&
1757+
nla_len(tb_sa[MACSEC_SA_ATTR_PN]) != pn_len) {
17571758
pr_notice("macsec: nl: add_rxsa: bad pn length: %d != %d\n",
17581759
nla_len(tb_sa[MACSEC_SA_ATTR_PN]), pn_len);
17591760
rtnl_unlock();

0 commit comments

Comments
 (0)