summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorLior Nahmanson <liorna@nvidia.com>2022-01-30 13:37:52 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-08 18:15:29 +0100
commit14b2834992454a93b1cafebe712f2d95b3717e34 (patch)
treec891c788a788f09a2601af0981ba6a7b500b0b9e /drivers
parent6c81b9e39cb7db5f1f72430726db87813b67d138 (diff)
downloadlinux-14b2834992454a93b1cafebe712f2d95b3717e34.tar.gz
linux-14b2834992454a93b1cafebe712f2d95b3717e34.tar.bz2
linux-14b2834992454a93b1cafebe712f2d95b3717e34.zip
net: macsec: Verify that send_sci is on when setting Tx sci explicitly
commit d0cfa548dbde354de986911d3913897b5448faad upstream. 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: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Lior Nahmanson <liorna@nvidia.com> Reviewed-by: Raed Salem <raeds@nvidia.com> Signed-off-by: Raed Salem <raeds@nvidia.com> Link: https://lore.kernel.org/r/1643542672-29403-1-git-send-email-raeds@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/macsec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 774b9db0c811..0d3baa86cf17 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -3230,6 +3230,15 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
macsec->real_dev = real_dev;
+ /* send_sci must be set to true when transmit sci explicitly is set */
+ if ((data && data[IFLA_MACSEC_SCI]) &&
+ (data && data[IFLA_MACSEC_INC_SCI])) {
+ u8 send_sci = !!nla_get_u8(data[IFLA_MACSEC_INC_SCI]);
+
+ if (!send_sci)
+ return -EINVAL;
+ }
+
if (data && data[IFLA_MACSEC_ICV_LEN])
icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
mtu = real_dev->mtu - icv_len - macsec_extra_len(true);