Netdev List
 help / color / mirror / Atom feed
* [PATCH 0/6] Constant Time Memory Comparisons Are Important
@ 2017-06-10  2:59 Jason A. Donenfeld
  2017-06-10  2:59 ` [PATCH 2/6] net/ipv6: use constant time memory comparison for mac Jason A. Donenfeld
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Jason A. Donenfeld @ 2017-06-10  2:59 UTC (permalink / raw)
  To: linux-kernel, kernel-hardening
  Cc: Jason A. Donenfeld, Anna Schumaker, David Howells, David Safford,
	David S. Miller, Gilad Ben-Yossef, Greg Kroah-Hartman,
	Gustavo Padovan, J. Bruce Fields, Jeff Layton, Johan Hedberg,
	Johannes Berg, Marcel Holtmann, Mimi Zohar, Trond Myklebust,
	keyrings, linux-bluetooth, linux-nfs, linux-wireless, netdev

Whenever you're comparing two MACs, it's important to do this using
crypto_memneq instead of memcmp. With memcmp, you leak timing information,
which could then be used to iteratively forge a MAC. This is far too basic
of a mistake for us to have so pervasively in the year 2017, so let's begin
cleaning this stuff up. The following 6 locations were found with some
simple regex greps, but I'm sure more lurk below the surface. If you
maintain some code or know somebody who maintains some code that deals
with MACs, tell them to double check which comparison function they're
using.

Jason A. Donenfeld (6):
  sunrpc: use constant time memory comparison for mac
  net/ipv6: use constant time memory comparison for mac
  ccree: use constant time memory comparison for macs and tags
  security/keys: use constant time memory comparison for macs
  bluetooth/smp: use constant time memory comparison for secret values
  mac80211/wpa: use constant time memory comparison for MACs

Cc: Anna Schumaker <anna.schumaker@netapp.com>
Cc: David Howells <dhowells@redhat.com>
Cc: David Safford <safford@us.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Gilad Ben-Yossef <gilad@benyossef.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: Jeff Layton <jlayton@poochiereds.net>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: keyrings@vger.kernel.org
Cc: linux-bluetooth@vger.kernel.org
Cc: linux-nfs@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org

 drivers/staging/ccree/ssi_fips_ll.c   | 17 ++++++++-------
 net/bluetooth/smp.c                   | 39 ++++++++++++++++++-----------------
 net/ipv6/seg6_hmac.c                  |  3 ++-
 net/mac80211/wpa.c                    |  9 ++++----
 net/sunrpc/auth_gss/gss_krb5_crypto.c |  3 ++-
 security/keys/trusted.c               |  7 ++++---
 6 files changed, 42 insertions(+), 36 deletions(-)

-- 
2.13.1

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

* [PATCH 2/6] net/ipv6: use constant time memory comparison for mac
  2017-06-10  2:59 [PATCH 0/6] Constant Time Memory Comparisons Are Important Jason A. Donenfeld
@ 2017-06-10  2:59 ` Jason A. Donenfeld
  2017-06-11  8:13 ` [PATCH 0/6] Constant Time Memory Comparisons Are Important Kalle Valo
       [not found] ` <20170610025912.6499-1-Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org>
  2 siblings, 0 replies; 11+ messages in thread
From: Jason A. Donenfeld @ 2017-06-10  2:59 UTC (permalink / raw)
  To: linux-kernel, kernel-hardening
  Cc: Jason A. Donenfeld, David S. Miller, netdev, stable

Otherwise, we enable a MAC forgery via timing attack.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Cc: stable@vger.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 f950cb53d5e3..54213c83b44e 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -38,6 +38,7 @@
 #include <net/xfrm.h>
 
 #include <linux/cryptohash.h>
+#include <crypto/algapi.h>
 #include <crypto/hash.h>
 #include <crypto/sha.h>
 #include <net/seg6.h>
@@ -274,7 +275,7 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)
 	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;
-- 
2.13.1

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
  2017-06-10  2:59 [PATCH 0/6] Constant Time Memory Comparisons Are Important Jason A. Donenfeld
  2017-06-10  2:59 ` [PATCH 2/6] net/ipv6: use constant time memory comparison for mac Jason A. Donenfeld
@ 2017-06-11  8:13 ` Kalle Valo
       [not found]   ` <878tkzq6wi.fsf-5ukZ45wKbUHoml4zekdYB16hYfS7NtTn@public.gmane.org>
       [not found] ` <20170610025912.6499-1-Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org>
  2 siblings, 1 reply; 11+ messages in thread
From: Kalle Valo @ 2017-06-11  8:13 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: linux-kernel, kernel-hardening, Anna Schumaker, David Howells,
	David Safford, David S. Miller, Gilad Ben-Yossef,
	Greg Kroah-Hartman, Gustavo Padovan, J. Bruce Fields, Jeff Layton,
	Johan Hedberg, Johannes Berg, Marcel Holtmann, Mimi Zohar,
	Trond Myklebust, keyrings, linux-bluetooth, linux-nfs,
	linux-wireless

"Jason A. Donenfeld" <Jason@zx2c4.com> writes:

> Whenever you're comparing two MACs, it's important to do this using
> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
> which could then be used to iteratively forge a MAC.

Do you have any pointers where I could learn more about this?

-- 
Kalle Valo

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
       [not found]   ` <878tkzq6wi.fsf-5ukZ45wKbUHoml4zekdYB16hYfS7NtTn@public.gmane.org>
@ 2017-06-11 13:36     ` Kees Cook
  2017-06-11 20:48       ` Emmanuel Grumbach
  0 siblings, 1 reply; 11+ messages in thread
From: Kees Cook @ 2017-06-11 13:36 UTC (permalink / raw)
  To: Kalle Valo
  Cc: Jason A. Donenfeld, LKML,
	kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org,
	Anna Schumaker, David Howells, David Safford, David S. Miller,
	Gilad Ben-Yossef, Greg Kroah-Hartman, Gustavo Padovan,
	J. Bruce Fields, Jeff Layton, Johan Hedberg, Johannes Berg,
	Marcel Holtmann, Mimi Zohar, Trond Myklebust,
	keyrings-u79uwXL29TY

On Sun, Jun 11, 2017 at 1:13 AM, Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> wrote:
> "Jason A. Donenfeld" <Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org> writes:
>
>> Whenever you're comparing two MACs, it's important to do this using
>> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
>> which could then be used to iteratively forge a MAC.
>
> Do you have any pointers where I could learn more about this?

While not using C specifically, this talks about the problem generally:
https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html

-Kees

-- 
Kees Cook
Pixel Security
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
  2017-06-11 13:36     ` Kees Cook
@ 2017-06-11 20:48       ` Emmanuel Grumbach
       [not found]         ` <CANUX_P2b0Bx+-E_OBQ0reGW0=d6819qc=r83K0kTv0xMo8mtLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Emmanuel Grumbach @ 2017-06-11 20:48 UTC (permalink / raw)
  To: Kees Cook
  Cc: Kalle Valo, Jason A. Donenfeld, LKML,
	kernel-hardening@lists.openwall.com, Anna Schumaker,
	David Howells, David Safford, David S. Miller, Gilad Ben-Yossef,
	Greg Kroah-Hartman, Gustavo Padovan, J. Bruce Fields, Jeff Layton,
	Johan Hedberg, Johannes Berg, Marcel Holtmann, Mimi Zohar,
	Trond Myklebust <trond.myklebust@

On Sun, Jun 11, 2017 at 4:36 PM, Kees Cook <keescook@chromium.org> wrote:
>
> On Sun, Jun 11, 2017 at 1:13 AM, Kalle Valo <kvalo@codeaurora.org> wrote:
> > "Jason A. Donenfeld" <Jason@zx2c4.com> writes:
> >
> >> Whenever you're comparing two MACs, it's important to do this using
> >> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
> >> which could then be used to iteratively forge a MAC.
> >
> > Do you have any pointers where I could learn more about this?
>
> While not using C specifically, this talks about the problem generally:
> https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html
>

Sorry for the stupid question, but the MAC address is in plaintext in
the air anyway or easily accessible via user space tools. I fail to
see what it is so secret about a MAC address in that code where that
same MAC address is accessible via myriads of ways.

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
       [not found] ` <20170610025912.6499-1-Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org>
@ 2017-06-11 21:06   ` Stephan Müller
  2017-06-11 21:21     ` Jason A. Donenfeld
  0 siblings, 1 reply; 11+ messages in thread
From: Stephan Müller @ 2017-06-11 21:06 UTC (permalink / raw)
  To: Jason A. Donenfeld
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8, Anna Schumaker,
	David Howells, David Safford, David S. Miller, Gilad Ben-Yossef,
	Greg Kroah-Hartman, Gustavo Padovan, J. Bruce Fields, Jeff Layton,
	Johan Hedberg, Johannes Berg, Marcel Holtmann, Mimi Zohar,
	Trond Myklebust, keyrings-u79uwXL29TY76Z2rM5mHXA,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA

Am Samstag, 10. Juni 2017, 04:59:06 CEST schrieb Jason A. Donenfeld:

Hi Jason,

> Whenever you're comparing two MACs, it's important to do this using
> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
> which could then be used to iteratively forge a MAC. This is far too basic
> of a mistake for us to have so pervasively in the year 2017, so let's begin
> cleaning this stuff up. The following 6 locations were found with some
> simple regex greps, but I'm sure more lurk below the surface. If you
> maintain some code or know somebody who maintains some code that deals
> with MACs, tell them to double check which comparison function they're
> using.

Are you planning to send an update to your patch set? If yes, there is another 
one which should be converted too: crypto/rsa-pkcs1pad.c.

Otherwise, I will send a patch converting this one.

Thanks.

Ciao
Stephan
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
  2017-06-11 21:06   ` Stephan Müller
@ 2017-06-11 21:21     ` Jason A. Donenfeld
  0 siblings, 0 replies; 11+ messages in thread
From: Jason A. Donenfeld @ 2017-06-11 21:21 UTC (permalink / raw)
  To: Stephan Müller
  Cc: LKML, kernel-hardening, Anna Schumaker, David Howells,
	David Safford, David S. Miller, Gilad Ben-Yossef,
	Greg Kroah-Hartman, Gustavo Padovan, J. Bruce Fields, Jeff Layton,
	Johan Hedberg, Johannes Berg, Marcel Holtmann, Mimi Zohar,
	Trond Myklebust, keyrings, linux-bluetooth, linux-nfs,
	linux-wireless

Hi Stephan,

On Sun, Jun 11, 2017 at 11:06 PM, Stephan Müller <smueller@chronox.de> wrote:
> Are you planning to send an update to your patch set? If yes, there is another
> one which should be converted too: crypto/rsa-pkcs1pad.c.

I just sent an update to this thread patching that, per your
suggestion. Since these issues are expected to be cherry picked by
their respective committer, I figure we can just pile on the patches
here, listing the 0/6 intro email as each patch's parent.

Jason

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
       [not found]         ` <CANUX_P2b0Bx+-E_OBQ0reGW0=d6819qc=r83K0kTv0xMo8mtLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-06-11 21:30           ` Emil Lenngren
       [not found]             ` <CAO1O6see6yDr-hDVNPi9Kv9wO6p-98w7YhsnnwnVOVCSEGVksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 11+ messages in thread
From: Emil Lenngren @ 2017-06-11 21:30 UTC (permalink / raw)
  To: Emmanuel Grumbach
  Cc: Kees Cook, Kalle Valo, Jason A. Donenfeld, LKML,
	kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org,
	Anna Schumaker, David Howells, David Safford, David S. Miller,
	Gilad Ben-Yossef, Greg Kroah-Hartman, Gustavo Padovan,
	J. Bruce Fields, Jeff Layton, Johan Hedberg, Johannes Berg,
	Marcel Holtmann, Mimi Zohar

2017-06-11 22:48 GMT+02:00 Emmanuel Grumbach <egrumbach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
> On Sun, Jun 11, 2017 at 4:36 PM, Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>>
>> On Sun, Jun 11, 2017 at 1:13 AM, Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> wrote:
>> > "Jason A. Donenfeld" <Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org> writes:
>> >
>> >> Whenever you're comparing two MACs, it's important to do this using
>> >> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
>> >> which could then be used to iteratively forge a MAC.
>> >
>> > Do you have any pointers where I could learn more about this?
>>
>> While not using C specifically, this talks about the problem generally:
>> https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html
>>
>
> Sorry for the stupid question, but the MAC address is in plaintext in
> the air anyway or easily accessible via user space tools. I fail to
> see what it is so secret about a MAC address in that code where that
> same MAC address is accessible via myriads of ways.

I think you're mixing up Media Access Control (MAC) addresses with
Message Authentication Code (MAC). The second one is a cryptographic
signature of a message.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
       [not found]             ` <CAO1O6see6yDr-hDVNPi9Kv9wO6p-98w7YhsnnwnVOVCSEGVksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2017-06-12  5:03               ` Emmanuel Grumbach
  2017-06-12  7:33               ` Arend van Spriel
  1 sibling, 0 replies; 11+ messages in thread
From: Emmanuel Grumbach @ 2017-06-12  5:03 UTC (permalink / raw)
  To: Emil Lenngren
  Cc: Kees Cook, Kalle Valo, Jason A. Donenfeld, LKML,
	kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org,
	Anna Schumaker, David Howells, David Safford, David S. Miller,
	Gilad Ben-Yossef, Greg Kroah-Hartman, Gustavo Padovan,
	J. Bruce Fields, Jeff Layton, Johan Hedberg, Johannes Berg,
	Marcel Holtmann, Mimi Zohar

On Mon, Jun 12, 2017 at 12:30 AM, Emil Lenngren <emil.lenngren-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> 2017-06-11 22:48 GMT+02:00 Emmanuel Grumbach <egrumbach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>> On Sun, Jun 11, 2017 at 4:36 PM, Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>>>
>>> On Sun, Jun 11, 2017 at 1:13 AM, Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> wrote:
>>> > "Jason A. Donenfeld" <Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org> writes:
>>> >
>>> >> Whenever you're comparing two MACs, it's important to do this using
>>> >> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
>>> >> which could then be used to iteratively forge a MAC.
>>> >
>>> > Do you have any pointers where I could learn more about this?
>>>
>>> While not using C specifically, this talks about the problem generally:
>>> https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html
>>>
>>
>> Sorry for the stupid question, but the MAC address is in plaintext in
>> the air anyway or easily accessible via user space tools. I fail to
>> see what it is so secret about a MAC address in that code where that
>> same MAC address is accessible via myriads of ways.
>
> I think you're mixing up Media Access Control (MAC) addresses with
> Message Authentication Code (MAC). The second one is a cryptographic
> signature of a message.

Obviously... Sorry for the noise.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
       [not found]             ` <CAO1O6see6yDr-hDVNPi9Kv9wO6p-98w7YhsnnwnVOVCSEGVksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  2017-06-12  5:03               ` Emmanuel Grumbach
@ 2017-06-12  7:33               ` Arend van Spriel
  2017-06-12 13:46                 ` Kalle Valo
  1 sibling, 1 reply; 11+ messages in thread
From: Arend van Spriel @ 2017-06-12  7:33 UTC (permalink / raw)
  To: Emil Lenngren, Emmanuel Grumbach
  Cc: Kees Cook, Kalle Valo, Jason A. Donenfeld, LKML,
	kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org,
	Anna Schumaker, David Howells, David Safford, David S. Miller,
	Gilad Ben-Yossef, Greg Kroah-Hartman, Gustavo Padovan,
	J. Bruce Fields, Jeff Layton, Johan Hedberg, Johannes Berg,
	Marcel Holtmann, Mimi Zohar

On 6/11/2017 11:30 PM, Emil Lenngren wrote:
> 2017-06-11 22:48 GMT+02:00 Emmanuel Grumbach <egrumbach-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:
>> On Sun, Jun 11, 2017 at 4:36 PM, Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org> wrote:
>>>
>>> On Sun, Jun 11, 2017 at 1:13 AM, Kalle Valo <kvalo-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org> wrote:
>>>> "Jason A. Donenfeld" <Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org> writes:
>>>>
>>>>> Whenever you're comparing two MACs, it's important to do this using
>>>>> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
>>>>> which could then be used to iteratively forge a MAC.
>>>>
>>>> Do you have any pointers where I could learn more about this?
>>>
>>> While not using C specifically, this talks about the problem generally:
>>> https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html
>>>
>>
>> Sorry for the stupid question, but the MAC address is in plaintext in
>> the air anyway or easily accessible via user space tools. I fail to
>> see what it is so secret about a MAC address in that code where that
>> same MAC address is accessible via myriads of ways.
> 
> I think you're mixing up Media Access Control (MAC) addresses with
> Message Authentication Code (MAC). The second one is a cryptographic
> signature of a message.

While this may be obvious to those who are in the know this mixup is 
easily made outside the crypto domain and especially in the (wireless) 
networking domain (my mind wandered towards the same error path). As 
this series is touching stuff outside crypto it is good to be explicit 
and not use such abbreviations that can be misinterpreted. The article 
Kees referred to is also useful to get into the proper context here and 
at least worth mentioning this or other useful references in the cover 
letter.

Regards,
Arend
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/6] Constant Time Memory Comparisons Are Important
  2017-06-12  7:33               ` Arend van Spriel
@ 2017-06-12 13:46                 ` Kalle Valo
  0 siblings, 0 replies; 11+ messages in thread
From: Kalle Valo @ 2017-06-12 13:46 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: Emil Lenngren, Emmanuel Grumbach, Kees Cook, Jason A. Donenfeld,
	LKML, kernel-hardening@lists.openwall.com, Anna Schumaker,
	David Howells, David Safford, David S. Miller, Gilad Ben-Yossef,
	Greg Kroah-Hartman, Gustavo Padovan, J. Bruce Fields, Jeff Layton,
	Johan Hedberg, Johannes Berg, Marcel Holtmann,
	Mimi Zohar <zoha 

Arend van Spriel <arend.vanspriel@broadcom.com> writes:

> On 6/11/2017 11:30 PM, Emil Lenngren wrote:
>> 2017-06-11 22:48 GMT+02:00 Emmanuel Grumbach <egrumbach@gmail.com>:
>>> On Sun, Jun 11, 2017 at 4:36 PM, Kees Cook <keescook@chromium.org> wrote:
>>>>
>>>> On Sun, Jun 11, 2017 at 1:13 AM, Kalle Valo <kvalo@codeaurora.org> wrote:
>>>>> "Jason A. Donenfeld" <Jason@zx2c4.com> writes:
>>>>>
>>>>>> Whenever you're comparing two MACs, it's important to do this using
>>>>>> crypto_memneq instead of memcmp. With memcmp, you leak timing information,
>>>>>> which could then be used to iteratively forge a MAC.
>>>>>
>>>>> Do you have any pointers where I could learn more about this?
>>>>
>>>> While not using C specifically, this talks about the problem generally:
>>>> https://www.chosenplaintext.ca/articles/beginners-guide-constant-time-cryptography.html
>>>>
>>>
>>> Sorry for the stupid question, but the MAC address is in plaintext in
>>> the air anyway or easily accessible via user space tools. I fail to
>>> see what it is so secret about a MAC address in that code where that
>>> same MAC address is accessible via myriads of ways.
>>
>> I think you're mixing up Media Access Control (MAC) addresses with
>> Message Authentication Code (MAC). The second one is a cryptographic
>> signature of a message.
>
> While this may be obvious to those who are in the know this mixup is
> easily made outside the crypto domain and especially in the (wireless)
> networking domain (my mind wandered towards the same error path).

I did realise that this was about Message Authentication Code (yay!) but
I got lost because I thought this is somehow related to timestamps :)
Thanks to Kees I now understand this is about revealing execution time
to the attacker, not timestamps or anything like that.

> As this series is touching stuff outside crypto it is good to be
> explicit and not use such abbreviations that can be misinterpreted.
> The article Kees referred to is also useful to get into the proper
> context here and at least worth mentioning this or other useful
> references in the cover letter.

And the kernel documentation we have is not really helping much:

/**
 * crypto_memneq - Compare two areas of memory without leaking
 *		   timing information.
 *
 * @a: One area of memory
 * @b: Another area of memory
 * @size: The size of the area.
 *
 * Returns 0 when data is equal, 1 otherwise.
 */

For most people "leaking timing information" does not tell much. Adding
a sentence or two _why_ this function should be used would be very
helpful.

-- 
Kalle Valo

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

end of thread, other threads:[~2017-06-12 13:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-10  2:59 [PATCH 0/6] Constant Time Memory Comparisons Are Important Jason A. Donenfeld
2017-06-10  2:59 ` [PATCH 2/6] net/ipv6: use constant time memory comparison for mac Jason A. Donenfeld
2017-06-11  8:13 ` [PATCH 0/6] Constant Time Memory Comparisons Are Important Kalle Valo
     [not found]   ` <878tkzq6wi.fsf-5ukZ45wKbUHoml4zekdYB16hYfS7NtTn@public.gmane.org>
2017-06-11 13:36     ` Kees Cook
2017-06-11 20:48       ` Emmanuel Grumbach
     [not found]         ` <CANUX_P2b0Bx+-E_OBQ0reGW0=d6819qc=r83K0kTv0xMo8mtLQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-11 21:30           ` Emil Lenngren
     [not found]             ` <CAO1O6see6yDr-hDVNPi9Kv9wO6p-98w7YhsnnwnVOVCSEGVksw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-06-12  5:03               ` Emmanuel Grumbach
2017-06-12  7:33               ` Arend van Spriel
2017-06-12 13:46                 ` Kalle Valo
     [not found] ` <20170610025912.6499-1-Jason-OnJsPKxuuEcAvxtiuMwx3w@public.gmane.org>
2017-06-11 21:06   ` Stephan Müller
2017-06-11 21:21     ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox