ipv6: sr: Fix MAC comparison to be constant-time
Subsystems (5)
PATCH v2 1/1 ipv6: sr: Fix MAC comparison to be constant-time
To prevent timing attacks, MACs need to be compared in constant time. Use the appropriate helper function for this.
---
v2: sent as standalone patch targeting net instead of net-next.
net/ipv6/seg6_hmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv6/seg6_hmac.c +2 -1
@@ -33,10 +33,11 @@#include <net/ip6_route.h> #include <net/addrconf.h> #include <net/xfrm.h> #include <crypto/hash.h> +#include <crypto/utils.h> #include <net/seg6.h> #include <net/genetlink.h> #include <net/seg6_hmac.h> #include <linux/random.h>
@@ -278,11 +279,11 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)return false;if (seg6_hmac_compute (hinfo, srh, &ipv6_hdr (skb)->saddr, hmac_output))return false; -if (memcmp (hmac_output, tlv->hmac,SEG6_HMAC_FIELD_LEN ) !=0 ) +if (crypto_memneq (hmac_output, tlv->hmac,SEG6_HMAC_FIELD_LEN ))return false;return true; }EXPORT_SYMBOL (seg6_hmac_validate_skb);
base-commit: 715c7a36d59f54162a26fac1d1ed8dc087a24cf1
Signature · 1 line
2.50.1
Quoted 6 lines · On Mon, 18 Aug 2025 13:27:24 -0700 Eric Biggers <[email protected]> wrote:
To prevent timing attacks, MACs need to be compared in constant time. Use the appropriate helper function for this.
Fixes bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support")Signed-off-by Eric Biggers <[email protected]>
Quoted 7 lines
---
v2: sent as standalone patch targeting net instead of net-next.
net/ipv6/seg6_hmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
The fix looks good to me. Thanks!
Ciao,
Andrea
Quoted 34 lines
net/ipv6/seg6_hmac.c +2
-1@@ -33,10 +33,11 @@#include <net/ip6_route.h> #include <net/addrconf.h> #include <net/xfrm.h> #include <crypto/hash.h> +#include <crypto/utils.h> #include <net/seg6.h> #include <net/genetlink.h> #include <net/seg6_hmac.h> #include <linux/random.h> @@ -278,11 +279,11 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)return false;if (seg6_hmac_compute (hinfo, srh, &ipv6_hdr (skb)->saddr, hmac_output))return false; -if (memcmp (hmac_output, tlv->hmac,SEG6_HMAC_FIELD_LEN ) !=0 ) +if (crypto_memneq (hmac_output, tlv->hmac,SEG6_HMAC_FIELD_LEN ))return false;return true; }EXPORT_SYMBOL (seg6_hmac_validate_skb);base-commit:
715c7a36d59f54162a26fac1d1ed8dc087a24cf1Signature · 1 line
2.50.1
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 18 Aug 2025 13:27:24 -0700 you wrote:
To prevent timing attacks, MACs need to be compared in constant time. Use the appropriate helper function for this.
Fixes bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support")Signed-off-by Eric Biggers <[email protected]>[...]
Here is the summary with links:
- [net,v2] ipv6: sr: Fix MAC comparison to be constant-time
https://git.kernel.org/netdev/net/c/a458b2902115
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html