Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Ovidiu Panait <ovidiu.panait@windriver.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 4.19 0/3] ipv4/ipv6: backport fixes for CVE-2021-20322
Date: Fri, 29 Oct 2021 11:17:16 +0300	[thread overview]
Message-ID: <cdf08090-1f48-4a90-4c68-139b706fdd88@windriver.com> (raw)
In-Reply-To: <YXulOpILxpS+ljKY@kroah.com>

[-- Attachment #1: Type: text/plain, Size: 2220 bytes --]

Hi Greg,

On 29.10.2021 10:39, Greg KH wrote:
> [Please note: This e-mail is from an EXTERNAL e-mail address]
>
> On Thu, Oct 28, 2021 at 10:08:58PM +0300, Ovidiu Panait wrote:
>> The following commits are needed to fix CVE-2021-20322:
>> ipv4:
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6457378fe796815c973f631a1904e147d6ee33b1
>> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=67d6d681e15b578c1725bad8ad079e05d1c48a8e
>>
>> ipv6:
>> [3] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4785305c05b25a242e5314cc821f54ade4c18810
>> [4] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a00df2caffed3883c341d5685f830434312e4a43
>>
>> Commit [2] is already present in 4.19 stable, so backport the
>> remaining three fixes with minor context adjustments.
>>
>> Eric Dumazet (3):
>>    ipv4: use siphash instead of Jenkins in fnhe_hashfun()
>>    ipv6: use siphash in rt6_exception_hash()
>>    ipv6: make exception cache less predictible
>>
>>   net/ipv4/route.c | 12 ++++++------
>>   net/ipv6/route.c | 25 ++++++++++++++++++-------
>>   2 files changed, 24 insertions(+), 13 deletions(-)
>>
>> --
>> 2.25.1
>>
> You sent 0/3 but only 2 patches showed up?
>
> Can you please resend all 3?

I tried resending the full patchset, but the last patch is still not 
showing up.

git send-email doesn't report any errors:

OK. Log says:
MAIL FROM:<ovidiu.panait@windriver.com>
RCPT TO:<stable@vger.kernel.org>
RCPT TO:<gregkh@linuxfoundation.org>
From: Ovidiu Panait <ovidiu.panait@windriver.com>
To: stable@vger.kernel.org
Cc: gregkh@linuxfoundation.org
Subject: [PATCH 4.19 3/3] ipv6: make exception cache less predictible
Date: Fri, 29 Oct 2021 10:50:27 +0300
Message-Id: <20211029075027.1910142-4-ovidiu.panait@windriver.com>
X-Mailer: git-send-email 2.25.1
In-Reply-To: <20211029075027.1910142-1-ovidiu.panait@windriver.com>
References: <20211029075027.1910142-1-ovidiu.panait@windriver.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit

Result: 250


I have attached the 4.19 backport of a00df2caffed ("ipv6: make exception 
cache less predictible").


Ovidiu

> thanks,
>
> greg k-h

[-- Attachment #2: 0003-ipv6-make-exception-cache-less-predictible.patch --]
[-- Type: text/x-patch, Size: 2243 bytes --]

From c9f6f8ebbc70e5cf357f80b77400f0233027b39d Mon Sep 17 00:00:00 2001
From: Eric Dumazet <edumazet@google.com>
Date: Sun, 29 Aug 2021 15:16:14 -0700
Subject: [PATCH 4.19 3/3] ipv6: make exception cache less predictible

commit a00df2caffed3883c341d5685f830434312e4a43 upstream.

Even after commit 4785305c05b2 ("ipv6: use siphash in rt6_exception_hash()"),
an attacker can still use brute force to learn some secrets from a victim
linux host.

One way to defeat these attacks is to make the max depth of the hash
table bucket a random value.

Before this patch, each bucket of the hash table used to store exceptions
could contain 6 items under attack.

After the patch, each bucket would contains a random number of items,
between 6 and 10. The attacker can no longer infer secrets.

This is slightly increasing memory size used by the hash table,
we do not expect this to be a problem.

Following patch is dealing with the same issue in IPv4.

Fixes: 35732d01fe31 ("ipv6: introduce a hash table to store dst cache")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Keyu Man <kman001@ucr.edu>
Cc: Wei Wang <weiwan@google.com>
Cc: Martin KaFai Lau <kafai@fb.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
[OP: adjusted context for 4.19 stable]
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
---
 net/ipv6/route.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 9bc806a4ded6..d04f3951c5fb 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1454,6 +1454,7 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 	struct rt6_exception_bucket *bucket;
 	struct in6_addr *src_key = NULL;
 	struct rt6_exception *rt6_ex;
+	int max_depth;
 	int err = 0;
 
 	spin_lock_bh(&rt6_exception_lock);
@@ -1515,7 +1516,9 @@ static int rt6_insert_exception(struct rt6_info *nrt,
 	bucket->depth++;
 	net->ipv6.rt6_stats->fib_rt_cache++;
 
-	if (bucket->depth > FIB6_MAX_DEPTH)
+	/* Randomize max depth to avoid some side channels attacks. */
+	max_depth = FIB6_MAX_DEPTH + prandom_u32_max(FIB6_MAX_DEPTH);
+	while (bucket->depth > max_depth)
 		rt6_exception_remove_oldest(bucket);
 
 out:
-- 
2.25.1


  reply	other threads:[~2021-10-29  8:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-28 19:08 [PATCH 4.19 0/3] ipv4/ipv6: backport fixes for CVE-2021-20322 Ovidiu Panait
2021-10-28 19:08 ` [PATCH 4.19 1/3] ipv4: use siphash instead of Jenkins in fnhe_hashfun() Ovidiu Panait
2021-10-28 19:09 ` [PATCH 4.19 2/3] ipv6: use siphash in rt6_exception_hash() Ovidiu Panait
2021-10-29  7:39 ` [PATCH 4.19 0/3] ipv4/ipv6: backport fixes for CVE-2021-20322 Greg KH
2021-10-29  8:17   ` Ovidiu Panait [this message]
2021-10-29 15:04     ` Greg KH
  -- strict thread matches above, loose matches on Subject: below --
2021-10-29  7:50 Ovidiu Panait

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cdf08090-1f48-4a90-4c68-139b706fdd88@windriver.com \
    --to=ovidiu.panait@windriver.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox