forked from luck/tmp_suning_uos_patched
macsec: always read MACSEC_SA_ATTR_PN as a u64
[ Upstream commit c630d1fe6219769049c87d1a6a0e9a6de55328a1 ]
Currently, MACSEC_SA_ATTR_PN is handled inconsistently, sometimes as a
u32, sometimes forced into a u64 without checking the actual length of
the attribute. Instead, we can use nla_get_u64 everywhere, which will
read up to 64 bits into a u64, capped by the actual length of the
attribute coming from userspace.
This fixes several issues:
- the check in validate_add_rxsa doesn't work with 32-bit attributes
- the checks in validate_add_txsa and validate_upd_sa incorrectly
reject X << 32 (with X != 0)
Fixes: 48ef50fa86
("macsec: Netlink support of XPN cipher suites (IEEE 802.1AEbw)")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
2daf0a1261
commit
6e0e0464f1
|
@ -1695,7 +1695,7 @@ static bool validate_add_rxsa(struct nlattr **attrs)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (attrs[MACSEC_SA_ATTR_PN] &&
|
if (attrs[MACSEC_SA_ATTR_PN] &&
|
||||||
*(u64 *)nla_data(attrs[MACSEC_SA_ATTR_PN]) == 0)
|
nla_get_u64(attrs[MACSEC_SA_ATTR_PN]) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (attrs[MACSEC_SA_ATTR_ACTIVE]) {
|
if (attrs[MACSEC_SA_ATTR_ACTIVE]) {
|
||||||
|
@ -1938,7 +1938,7 @@ static bool validate_add_txsa(struct nlattr **attrs)
|
||||||
if (nla_get_u8(attrs[MACSEC_SA_ATTR_AN]) >= MACSEC_NUM_AN)
|
if (nla_get_u8(attrs[MACSEC_SA_ATTR_AN]) >= MACSEC_NUM_AN)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (nla_get_u32(attrs[MACSEC_SA_ATTR_PN]) == 0)
|
if (nla_get_u64(attrs[MACSEC_SA_ATTR_PN]) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (attrs[MACSEC_SA_ATTR_ACTIVE]) {
|
if (attrs[MACSEC_SA_ATTR_ACTIVE]) {
|
||||||
|
@ -2292,7 +2292,7 @@ static bool validate_upd_sa(struct nlattr **attrs)
|
||||||
if (nla_get_u8(attrs[MACSEC_SA_ATTR_AN]) >= MACSEC_NUM_AN)
|
if (nla_get_u8(attrs[MACSEC_SA_ATTR_AN]) >= MACSEC_NUM_AN)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (attrs[MACSEC_SA_ATTR_PN] && nla_get_u32(attrs[MACSEC_SA_ATTR_PN]) == 0)
|
if (attrs[MACSEC_SA_ATTR_PN] && nla_get_u64(attrs[MACSEC_SA_ATTR_PN]) == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (attrs[MACSEC_SA_ATTR_ACTIVE]) {
|
if (attrs[MACSEC_SA_ATTR_ACTIVE]) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user