* [PATCH net-next 1/3] ipv6: sr: Fix MAC comparison to be constant-time [not found] <20250816031136.482400-1-ebiggers@kernel.org> @ 2025-08-16 3:11 ` Eric Biggers 2025-08-18 19:16 ` Andrea Mayer 0 siblings, 1 reply; 4+ messages in thread From: Eric Biggers @ 2025-08-16 3:11 UTC (permalink / raw) To: netdev, Andrea Mayer; +Cc: David Lebrun, Eric Biggers, stable 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") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org> --- net/ipv6/seg6_hmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c index f78ecb6ad8383..5dae892bbc73b 100644 --- a/net/ipv6/seg6_hmac.c +++ b/net/ipv6/seg6_hmac.c @@ -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); -- 2.50.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/3] ipv6: sr: Fix MAC comparison to be constant-time 2025-08-16 3:11 ` [PATCH net-next 1/3] ipv6: sr: Fix MAC comparison to be constant-time Eric Biggers @ 2025-08-18 19:16 ` Andrea Mayer 2025-08-18 19:38 ` Eric Biggers 0 siblings, 1 reply; 4+ messages in thread From: Andrea Mayer @ 2025-08-18 19:16 UTC (permalink / raw) To: Eric Biggers Cc: netdev, David Lebrun, stable, stefano.salsano, Paolo Lungaroni, Andrea Mayer On Fri, 15 Aug 2025 20:11:34 -0700 Eric Biggers <ebiggers@kernel.org> 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") > Cc: stable@vger.kernel.org > Signed-off-by: Eric Biggers <ebiggers@kernel.org> > --- > net/ipv6/seg6_hmac.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > Hi Eric, Thanks for the fix! I believe it would be best to submit this fix separately from the current patch set. Since this addresses a bug rather than an enhancement or cleanup, sending it individually with the 'net' tag will help facilitate applying this patch to the net tree. Ciao, Andrea > diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c > index f78ecb6ad8383..5dae892bbc73b 100644 > --- a/net/ipv6/seg6_hmac.c > +++ b/net/ipv6/seg6_hmac.c > @@ -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); > -- > 2.50.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/3] ipv6: sr: Fix MAC comparison to be constant-time 2025-08-18 19:16 ` Andrea Mayer @ 2025-08-18 19:38 ` Eric Biggers 2025-08-18 20:30 ` Eric Biggers 0 siblings, 1 reply; 4+ messages in thread From: Eric Biggers @ 2025-08-18 19:38 UTC (permalink / raw) To: Andrea Mayer Cc: netdev, David Lebrun, stable, stefano.salsano, Paolo Lungaroni On Mon, Aug 18, 2025 at 09:16:07PM +0200, Andrea Mayer wrote: > On Fri, 15 Aug 2025 20:11:34 -0700 > Eric Biggers <ebiggers@kernel.org> 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") > > Cc: stable@vger.kernel.org > > Signed-off-by: Eric Biggers <ebiggers@kernel.org> > > --- > > net/ipv6/seg6_hmac.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > Hi Eric, > > Thanks for the fix! > > I believe it would be best to submit this fix separately from the current patch > set. Since this addresses a bug rather than an enhancement or cleanup, sending > it individually with the 'net' tag will help facilitate applying this patch to > the net tree. > > Ciao, > Andrea Then there would be a merge conflict between the two patchsets. I can do that if you want, but then I'd probably have to wait for this patch to reach net-next before the rest can proceed. - Eric ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 1/3] ipv6: sr: Fix MAC comparison to be constant-time 2025-08-18 19:38 ` Eric Biggers @ 2025-08-18 20:30 ` Eric Biggers 0 siblings, 0 replies; 4+ messages in thread From: Eric Biggers @ 2025-08-18 20:30 UTC (permalink / raw) To: Andrea Mayer Cc: netdev, David Lebrun, stable, stefano.salsano, Paolo Lungaroni On Mon, Aug 18, 2025 at 07:38:52PM +0000, Eric Biggers wrote: > On Mon, Aug 18, 2025 at 09:16:07PM +0200, Andrea Mayer wrote: > > On Fri, 15 Aug 2025 20:11:34 -0700 > > Eric Biggers <ebiggers@kernel.org> 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") > > > Cc: stable@vger.kernel.org > > > Signed-off-by: Eric Biggers <ebiggers@kernel.org> > > > --- > > > net/ipv6/seg6_hmac.c | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > > Hi Eric, > > > > Thanks for the fix! > > > > I believe it would be best to submit this fix separately from the current patch > > set. Since this addresses a bug rather than an enhancement or cleanup, sending > > it individually with the 'net' tag will help facilitate applying this patch to > > the net tree. > > > > Ciao, > > Andrea > > Then there would be a merge conflict between the two patchsets. > > I can do that if you want, but then I'd probably have to wait for this > patch to reach net-next before the rest can proceed. I guess patches 2 and 3 have to wait for "ipv6: sr: validate HMAC algorithm ID in seg6_hmac_info_add" anyway, as they conflict with that too. Okay, I resent patch 1 as a standalone patch targeting "net": https://lore.kernel.org/netdev/20250818202724.15713-1-ebiggers@kernel.org/ - Eric ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-18 20:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250816031136.482400-1-ebiggers@kernel.org>
2025-08-16 3:11 ` [PATCH net-next 1/3] ipv6: sr: Fix MAC comparison to be constant-time Eric Biggers
2025-08-18 19:16 ` Andrea Mayer
2025-08-18 19:38 ` Eric Biggers
2025-08-18 20:30 ` Eric Biggers
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox