Skip to content

Commit d0cfa54

Browse files
Lior Nahmansonkuba-moo
authored andcommitted
net: macsec: Verify that send_sci is on when setting Tx sci explicitly
When setting Tx sci explicit, the Rx side is expected to use this sci and not recalculate it from the packet.However, in case of Tx sci is explicit and send_sci is off, the receiver is wrongly recalculate the sci from the source MAC address which most likely be different than the explicit sci. Fix by preventing such configuration when macsec newlink is established and return EINVAL error code on such cases. Fixes: c09440f ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Lior Nahmanson <[email protected]> Reviewed-by: Raed Salem <[email protected]> Signed-off-by: Raed Salem <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 63e4b45 commit d0cfa54

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/net/macsec.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4018,6 +4018,15 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
40184018
!macsec_check_offload(macsec->offload, macsec))
40194019
return -EOPNOTSUPP;
40204020

4021+
/* send_sci must be set to true when transmit sci explicitly is set */
4022+
if ((data && data[IFLA_MACSEC_SCI]) &&
4023+
(data && data[IFLA_MACSEC_INC_SCI])) {
4024+
u8 send_sci = !!nla_get_u8(data[IFLA_MACSEC_INC_SCI]);
4025+
4026+
if (!send_sci)
4027+
return -EINVAL;
4028+
}
4029+
40214030
if (data && data[IFLA_MACSEC_ICV_LEN])
40224031
icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
40234032
mtu = real_dev->mtu - icv_len - macsec_extra_len(true);

0 commit comments

Comments
 (0)