Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DF1CC432BE for ; Mon, 30 Aug 2021 00:40:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FE0460F42 for ; Mon, 30 Aug 2021 00:40:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236200AbhH3AlJ (ORCPT ); Sun, 29 Aug 2021 20:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbhH3AlH (ORCPT ); Sun, 29 Aug 2021 20:41:07 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAED8C061575 for ; Sun, 29 Aug 2021 17:40:13 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id x4so11865193pgh.1 for ; Sun, 29 Aug 2021 17:40:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VApzl8Gy8EZZu+NRj+DtopuMmiOJ4iwp2mZKPDcSa7g=; b=cGj4SFOKAY6Z4qZZQwQWXaWDQApjw05z5gIDozMAl0Lx6BqDmr3zTOXRp2Jw4rrxlC lH6aeFEkHlnkra4M4n6qXYbJCBz7f6SgsgkERi17f2yLQQ+4vSln81+KkuNglPbqLM0h f8HBCxb0cmUOVoXlt5qfQ8RJZ1l5HxAL3X9AdU9gUmCd0bWESiW+Vad7T8nc2ICzNn0K IcErlrkMNyC/rEZyruztgnjU7MNDBbvILQCFKRwi0gmw6e/azWDpn4bR0eFXsxOpjl7x mO7wT0tY3eGiw8p+NLQU+ewc1GL1Li7FUYB9m5qU8QzRyhcIvpqx+7OZRcO2SwHvny7j 0CpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VApzl8Gy8EZZu+NRj+DtopuMmiOJ4iwp2mZKPDcSa7g=; b=NtLCTVVLY9LIX1ZVCm1htgsr0aaFqun8IBtihu/Oc0vR1fz0IKPKBFDWaFV18Elh7w Urp3z00k0LGxItk1eqmX1CEUhSq3smUhUKey0w/vOTDBgkUMGtJsAV7uh0txOagf1lQ3 dJeTyVTZKikhDC++/alnOh3S8ti6rGXIfMoyfjmSb2DHjbCb58ujoWyWHZ3jQ+RECdZG z524/JVMegNTCGMD6malvBn1FvssKAPJd3UiDOvG/3atWi7Lp1hnQzFrLNSvRjXz4fkk UeZ9DFSJ/hT96UpalbvpSk6VXfmBSBuL1osSf8zEdFDIDkZ6K+WgjsenpDtlPWxiqvpH tqGg== X-Gm-Message-State: AOAM533ckTHHIvD7IJWjqZungZxLvsZyfXj4yosIsSo4HK5GX8mgh6V0 XxIcS9UyL0h65bwZG/OmJYCm3jbl27o= X-Google-Smtp-Source: ABdhPJxt1G5N1irwveNunfZc0IScyQr3yiOLJpm9O0/a7fJkO4wh1BtAS0fNdc6OLJG+nSJ5wYxRSA== X-Received: by 2002:a62:483:0:b0:3e2:8b7:8208 with SMTP id 125-20020a620483000000b003e208b78208mr20554728pfe.42.1630284013261; Sun, 29 Aug 2021 17:40:13 -0700 (PDT) Received: from Davids-MacBook-Pro.local ([8.45.42.119]) by smtp.googlemail.com with ESMTPSA id j12sm12604462pfj.54.2021.08.29.17.40.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Aug 2021 17:40:12 -0700 (PDT) Subject: Re: [PATCH net 2/2] ipv4: make exception cache less predictible To: Eric Dumazet , "David S . Miller" , Jakub Kicinski Cc: netdev , Eric Dumazet , Willy Tarreau , Keyu Man , David Ahern References: <20210829221615.2057201-1-eric.dumazet@gmail.com> <20210829221615.2057201-3-eric.dumazet@gmail.com> From: David Ahern Message-ID: <85cbe227-5eb8-bc32-7707-fe5e76aa7476@gmail.com> Date: Sun, 29 Aug 2021 17:40:11 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210829221615.2057201-3-eric.dumazet@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 8/29/21 3:16 PM, Eric Dumazet wrote: > From: Eric Dumazet > > Even after commit 6457378fe796 ("ipv4: use siphash instead of Jenkins in > fnhe_hashfun()"), 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, > by 50% in average, we do not expect this to be a problem. > > This patch is more complex than the prior one (IPv6 equivalent), > because IPv4 was reusing the oldest entry. > Since we need to be able to evict more than one entry per > update_or_create_fnhe() call, I had to replace > fnhe_oldest() with fnhe_remove_oldest(). > > Also note that we will queue extra kfree_rcu() calls under stress, > which hopefully wont be a too big issue. > > Fixes: 4895c771c7f0 ("ipv4: Add FIB nexthop exceptions.") > Signed-off-by: Eric Dumazet > Reported-by: Keyu Man > Cc: Willy Tarreau > Signed-off-by: David S. Miller > --- > net/ipv4/route.c | 44 +++++++++++++++++++++++++++++--------------- > 1 file changed, 29 insertions(+), 15 deletions(-) > Reviewed-by: David Ahern Tested-by: David Ahern