Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4490317rwb; Tue, 6 Sep 2022 08:13:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR7IU/ht7GyG0nJaNNwTfKLt4txWjY7Fe/OhJq3tf/e0TzET6lsCUpVmNhXmJ5Ql4NgwmRvx X-Received: by 2002:a63:564b:0:b0:42c:414a:95fd with SMTP id g11-20020a63564b000000b0042c414a95fdmr35060722pgm.5.1662477198082; Tue, 06 Sep 2022 08:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662477198; cv=none; d=google.com; s=arc-20160816; b=ItUdNnS0QBBwKoXc1tDc+d4eJfVZdYokzI1qQZ+zRvvjAWoHOWkHZxfTgEj5FSSM+L WvDQqW+j+lx5sW18GmSCDthyT7Y/mhC4FL5kijZImWpf3avk9mwBsgOn5xCP7SPvyTvA /q5dswi872USMiFF+yY0emwmXnFzC0gsRxU91rp2lji1NyrVOwBPRXBFcUHaJeKooUQs TPlLnDJ2iDjh38BtqQb3G9QT6jaaMLsiH7S3cI+ML0M1FONz0hVW2a9bMeJVDTNkyq5t NPrNTwlTskl5uX9tSjdlOrDe6AnFM7y1jVWcpRoPZQcZWkFhMHFG/P8fJasyC/L+Sljb bKxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E7FZTyBleQtV07na+A2TqDMHlNEEH5ocqcg+S0Sgci0=; b=lDzQ+M0TB9Je6F7jrd7i24sZc7lIIHPg3JNKrRA/DjlX2ni5K/POBSaBdJmN780fD+ 4GEGXEzExUOVoupr9/Pg8t/Ac1ON99F2QGEzbHAaErfCUnteC+PikTFywl3GoTA5rV3N 3j4FDDFEAMDtkcvbRbUgvvt4lLT0pldOT1WCuggW3ZpxrovHNvCejBT8MXPsxM3DjT4g ngJYGBI/WejopbmVOGwQVh9K+QTBzD1Bnue1aIVSJ0Mo4/xc3Yx/f4AKZ+pNY5B/icN1 IOkfj2sTs3bLQmmBMuzSe1Ec9xBrDFZCotd0iIpoJFRB0xf4uyoMTzXgWJJ8k/iMzpn+ cLYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2RpzXzxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 199-20020a6302d0000000b00434277cd636si10469193pgc.414.2022.09.06.08.13.06; Tue, 06 Sep 2022 08:13:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2RpzXzxO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240547AbiIFNeM (ORCPT + 99 others); Tue, 6 Sep 2022 09:34:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240600AbiIFNdl (ORCPT ); Tue, 6 Sep 2022 09:33:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B16DF78595; Tue, 6 Sep 2022 06:33:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 924C261545; Tue, 6 Sep 2022 13:33:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A4BDC433D6; Tue, 6 Sep 2022 13:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471181; bh=poKzl3Pl2LOmQJVEYr48xuIcZzoS+tJ8maoGqkhkdRM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2RpzXzxO5zStLcMGwFHYDGTJORHVTH5MGf4ZVC0sZe9sXFuYYMNfubOCPRtdKQfh5 l/Yf54OaBUNvz/9zeNxaggagtoEyaM7AxdEcNKcZmyMqakgFTlvkOnxl8JmIbBOovz WefLRSeV7yJuA4F5RqJ0mHSDGK694g3iER3zxHeE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Eric Dumazet , Neal Cardwell , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 18/80] tcp: annotate data-race around challenge_timestamp Date: Tue, 6 Sep 2022 15:30:15 +0200 Message-Id: <20220906132817.705298612@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet [ Upstream commit 8c70521238b7863c2af607e20bcba20f974c969b ] challenge_timestamp can be read an written by concurrent threads. This was expected, but we need to annotate the race to avoid potential issues. Following patch moves challenge_timestamp and challenge_count to per-netns storage to provide better isolation. Fixes: 354e4aa391ed ("tcp: RFC 5961 5.2 Blind Data Injection Attack Mitigation") Reported-by: syzbot Signed-off-by: Eric Dumazet Acked-by: Neal Cardwell Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv4/tcp_input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 41b44b311e8a0..e62500d6fe0d0 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -3599,11 +3599,11 @@ static void tcp_send_challenge_ack(struct sock *sk, const struct sk_buff *skb) /* Then check host-wide RFC 5961 rate limit. */ now = jiffies / HZ; - if (now != challenge_timestamp) { + if (now != READ_ONCE(challenge_timestamp)) { u32 ack_limit = READ_ONCE(net->ipv4.sysctl_tcp_challenge_ack_limit); u32 half = (ack_limit + 1) >> 1; - challenge_timestamp = now; + WRITE_ONCE(challenge_timestamp, now); WRITE_ONCE(challenge_count, half + prandom_u32_max(ack_limit)); } count = READ_ONCE(challenge_count); -- 2.35.1