Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1265260pxb; Fri, 22 Jan 2021 10:58:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwms9ZZ7sSp62oC+0Y2Gj/U8zfgo4C9LD3ul4/abEv8esWRKgSoQ7gPXej/M/LqkscbTYFO X-Received: by 2002:a17:906:2407:: with SMTP id z7mr3951950eja.219.1611341894204; Fri, 22 Jan 2021 10:58:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611341894; cv=none; d=google.com; s=arc-20160816; b=CeDDOjwDMtK6LixbERUOEdQAESBZuuB8qeCQRm/YSCOXBfzFcl4IOUm7grknM/fNdy o01lqc+MACt4x2rGXiwYLGrUKyrFZhzK5+KNc4ThbOyLaSYD3DXpqbpAKa2LVcKAW81t /nqhSgcHs2AVZhNZTy4A13NVLE1UQ3mdRadFDJFSIL6CfkO7uwYmuXNfWMq/e80iTgRi 3POWcV1Yw1TkNzVkdcR0K2Lf/9flx/v6uirOMyueVxW5r+7dOruTOaPxvFFE3enalasr Pshxt3ixQKQKmLg82vpdlEw1BIOik7lW7xnE7V+jMfN+HwspFodleq+zSMpG7kZqNKMQ UsTg== 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=At7O6t+CtVZ/YelHarIb+GijlOwv6xAvTp4IRZcgvUc=; b=FbnXDPA6Lx/xO3sLJA60LDO0tjvFpn385o2azn5gBG2eo6ziOjMmKydAmvEQilYqRC 0qFtAjAjAi1phWNKcCK//wFtK1hWDT4TEsf+nFKnsJaIKbthbXqyDt+IH4+KLK+QtG/N HgLmQE6hA022Z2ipaLFeH85hJTAgcTuVj9fiCgj3KHFqT413UrUVMFcUslh4SoCxLaXy 7Jvl4Ad+ETWhh+rcZ/Bef34Z+OFpAGsQsVUTNBWN/oLwFfHK4oRDx3SWch84OWRioQPo YBTQv4sB0TrZk+Cl+YItF0cpzKpm1ONlRhr+C4VAU0tIGNs2JlBos7gSitgQRcf2nUnL E0Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hYT3J4Ef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r4si3256261ejj.81.2021.01.22.10.57.49; Fri, 22 Jan 2021 10:58:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hYT3J4Ef; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1730304AbhAVSx6 (ORCPT + 99 others); Fri, 22 Jan 2021 13:53:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:39306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728521AbhAVOWG (ORCPT ); Fri, 22 Jan 2021 09:22:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id ADF8723B54; Fri, 22 Jan 2021 14:16:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611324973; bh=pimP6n21U/JGJRQ910aCkQFtVX5QrplC560wCofPJnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hYT3J4EfvpPGFA9Qpuk08wejxE0uqidb6UIrDfkeX+wacQw2S4smK+eO2gDbxPned g0ZJA2BuUrlF+M8OCh9x1z1qj4akI6BIhr+Ztt6cUVnCPELU2B0IScHyw5IIY7H70f 1CXbZtUOm+wdQtf9FgkU6uZcD2ruogpwCJnbzxDA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Baptiste Lepers , Willem de Bruijn , Jakub Kicinski Subject: [PATCH 4.19 06/22] udp: Prevent reuseport_select_sock from reading uninitialized socks Date: Fri, 22 Jan 2021 15:12:24 +0100 Message-Id: <20210122135732.172920223@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210122135731.921636245@linuxfoundation.org> References: <20210122135731.921636245@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Baptiste Lepers [ Upstream commit fd2ddef043592e7de80af53f47fa46fd3573086e ] reuse->socks[] is modified concurrently by reuseport_add_sock. To prevent reading values that have not been fully initialized, only read the array up until the last known safe index instead of incorrectly re-reading the last index of the array. Fixes: acdcecc61285f ("udp: correct reuseport selection with connected sockets") Signed-off-by: Baptiste Lepers Acked-by: Willem de Bruijn Link: https://lore.kernel.org/r/20210107051110.12247-1-baptiste.lepers@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/core/sock_reuseport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/core/sock_reuseport.c +++ b/net/core/sock_reuseport.c @@ -299,7 +299,7 @@ select_by_hash: i = j = reciprocal_scale(hash, socks); while (reuse->socks[i]->sk_state == TCP_ESTABLISHED) { i++; - if (i >= reuse->num_socks) + if (i >= socks) i = 0; if (i == j) goto out;