Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3744757pxv; Mon, 26 Jul 2021 10:50:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh2++j8C7rXHAIZx1VbePRVeIUPqjpO6jxUAf7+7gMyEXFtrrf8/sxhBfEg74wU25MgujZ X-Received: by 2002:a05:6402:4413:: with SMTP id y19mr22643049eda.142.1627321846725; Mon, 26 Jul 2021 10:50:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627321846; cv=none; d=google.com; s=arc-20160816; b=o0C3YC2wQJkUM+aIXL5wcFmJgAzMdZWIipj16Y7nAGmRczqaFhLQ2usW4aRdVnhXtM 5yvPBkZeAb4a3kH+yQm4fX9De5GHoycPxXJVsBdxlm1QUYrL1UdxKC0rrXaGfX84dmnD Qo1dAyJR2BiAg9/6e8GRNvHn2l6wqYJtrFpsg12UA1sUOz0cUobaCtmhUjZH5DUGbdlr Y2P3JIijz131QZtdpjPcluObYM/kHiLhZoZv+0K1erdTJzFXTB5VaslTO2uij91U/Kkf xJ5s1eoVDkITUb+vogR2vE73FtFQ3H6dKYY+Z+FT0cdLMnrMU7sTPNw8vzlTV4IKcvWL OvEQ== 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=D4bS0KtWOrqViWkrSV8Xd6uhR+naoJoS1LDGzle4edo=; b=oOHwhGL3uKUAe5GASd8MGZln/Mww6QDOjFq56x7p4aBJXMZdJWihPamIO27XT0Rdu4 x+5QG5DA1v3zrK6z3j3qv8lgxc58EyptFvCTDBfr4bAP5aNkBWhJCSsbuLURwJl/Y/Mx SPBaI89ObE4JauvQmlBy7Lr4i71Y3dI+y/L1fAtbyOgAaDC+Sps3icGuCIPJ4nEhg4HV SuVwkIb7tX+ky930iDomVjsMd0I7VEkL6p3yIGp4xfSHXIWdDai94K7qWTokKFfPp442 6hLBKFXgZw2uyXm1t375Mrlm+p7Dd9kZSdxthXObagm8NDKV3KSx2YfrFemQikpWE/VK Lx3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vrUcH9ZI; 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 hp8si491463ejc.333.2021.07.26.10.50.18; Mon, 26 Jul 2021 10:50:46 -0700 (PDT) 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=vrUcH9ZI; 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 S237246AbhGZPiq (ORCPT + 99 others); Mon, 26 Jul 2021 11:38:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:36646 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237269AbhGZPWI (ORCPT ); Mon, 26 Jul 2021 11:22:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 665AE60F5A; Mon, 26 Jul 2021 16:02:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627315357; bh=DZtjGGNtt29N0t0MOvqpwQD/LJPMtuoT1jY/0WVijak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vrUcH9ZIR9j+LwUao2Yj+ZM34HSC7tsij77CFBdDEPrFyEY3a+XvK0FDhrWUnhidL mFy49GJ/4fJURd+CVTo1FNxlsWPbkmZ/3+S4igkkT2OQK/vxCZM/AbE5opSaInqgTn oERh7S9RgfiBsxADcFC+3+qxMlSuPS1ykaTY7EBg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakub Sitnicki , Daniel Borkmann , Cong Wang , John Fastabend , Sasha Levin Subject: [PATCH 5.10 063/167] bpf, sockmap, udp: sk_prot needs inuse_idx set for proc stats Date: Mon, 26 Jul 2021 17:38:16 +0200 Message-Id: <20210726153841.512988993@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153839.371771838@linuxfoundation.org> References: <20210726153839.371771838@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: Jakub Sitnicki [ Upstream commit 54ea2f49fd9400dd698c25450be3352b5613b3b4 ] The proc socket stats use sk_prot->inuse_idx value to record inuse sock stats. We currently do not set this correctly from sockmap side. The result is reading sock stats '/proc/net/sockstat' gives incorrect values. The socket counter is incremented correctly, but because we don't set the counter correctly when we replace sk_prot we may omit the decrement. To get the correct inuse_idx value move the core_initcall that initializes the UDP proto handlers to late_initcall. This way it is initialized after UDP has the chance to assign the inuse_idx value from the register protocol handler. Fixes: edc6741cc660 ("bpf: Add sockmap hooks for UDP sockets") Signed-off-by: Jakub Sitnicki Signed-off-by: Daniel Borkmann Reviewed-by: Cong Wang Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20210714154750.528206-1-jakub@cloudflare.com Signed-off-by: Sasha Levin --- net/ipv4/udp_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/udp_bpf.c b/net/ipv4/udp_bpf.c index 7a94791efc1a..69c9663f9ee7 100644 --- a/net/ipv4/udp_bpf.c +++ b/net/ipv4/udp_bpf.c @@ -39,7 +39,7 @@ static int __init udp_bpf_v4_build_proto(void) udp_bpf_rebuild_protos(&udp_bpf_prots[UDP_BPF_IPV4], &udp_prot); return 0; } -core_initcall(udp_bpf_v4_build_proto); +late_initcall(udp_bpf_v4_build_proto); struct proto *udp_bpf_get_proto(struct sock *sk, struct sk_psock *psock) { -- 2.30.2