netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: macsec: Verify that send_sci is on when setting Tx sci explicitly
@ 2022-01-30 11:37 Raed Salem
  2022-02-02  4:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Raed Salem @ 2022-01-30 11:37 UTC (permalink / raw)
  To: sd, kuba, hannes; +Cc: davem, netdev, linux-kernel, Lior Nahmanson, Raed Salem

From: Lior Nahmanson <liorna@nvidia.com>

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>
---
 drivers/net/macsec.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 33ff33c..3d08743 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -4018,6 +4018,15 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 	    !macsec_check_offload(macsec->offload, macsec))
 		return -EOPNOTSUPP;
 
+	/* 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);
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: macsec: Verify that send_sci is on when setting Tx sci explicitly
  2022-01-30 11:37 [PATCH net] net: macsec: Verify that send_sci is on when setting Tx sci explicitly Raed Salem
@ 2022-02-02  4:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-02  4:50 UTC (permalink / raw)
  To: Raed Salem; +Cc: sd, kuba, hannes, davem, netdev, linux-kernel, liorna

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Sun, 30 Jan 2022 13:37:52 +0200 you wrote:
> From: Lior Nahmanson <liorna@nvidia.com>
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net] net: macsec: Verify that send_sci is on when setting Tx sci explicitly
    https://git.kernel.org/netdev/net/c/d0cfa548dbde

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-02  4:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-30 11:37 [PATCH net] net: macsec: Verify that send_sci is on when setting Tx sci explicitly Raed Salem
2022-02-02  4:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).