Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3388140lkq; Mon, 23 Nov 2020 04:33:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvNZq8hyCNquLNEo9tPtVNhAzA+ldGYlpva4y/pfgpmjcDKXxmthrnVsLaO9T3sVKeKGTj X-Received: by 2002:a05:6402:2373:: with SMTP id a19mr18062539eda.212.1606134802968; Mon, 23 Nov 2020 04:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134802; cv=none; d=google.com; s=arc-20160816; b=UHatHJ7/ICBolrO+0pKJFGUzj0XC60Do2HUSS76o0OM5u3/fvL/3euF9L/iiYolQVv 06wtVTBYlUI6fW4UNIOZ0TQAum387RCDA1gv024qS8ii2Uw/q0q+Qm/Pj/kfdybQk7d3 6RxUc/W3bu3R2+6cHMRpLf0jvyoZ83JslMJN/0JpxZR6+Gf7l+QP8BtH7Bw8DUBpK4Wg vnRFhmtyzQrYjq9TlX75SOqQ1Y68SMz//oWvhzgEUAsmq8MyA8WIFVkqmGqmowjCp/yg +Uv3cNzii/Cgso5Iz9a4EmBa/Fwqe9+3w1z56MtlJiS7lc7QMBighJB7W+Ns77M+sbZI JKAg== 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=LNW6rsNcrj/5xN09iRS5UCbPqhVNdcxhxmWIhwouvS0=; b=SExorqIM+6RDxfDvCxOU8w6mNh2XZWKDV0VnLP5htj1Zi7Yvr2Hj5uF9sCXkz+HuTc ctWpVCNxNjK25ClvY6oXieecLtqaMvXuaJ/zBNdDam9QBr8eQiCpvKnRGHkDy4DEdc/P mayclgBPGrcCG9n9xsiHQjJx2VHISPaCrTQU1IdGyao5/SKiCls2w30u3iF+4OMnu5bT sFjds79nzuETjOGzBez/iSE0qQoNr3LaxgrJm53uwksWsGHbgFxEyxPmM7oszWWTQVdJ rva23552bXyJmLD/CXt1mZ7frl6QR992y/X0SdiGogbNEHHq6UQwJ8QAfLNZG0IQ/eFo v5/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vdDVGgWC; 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 j27si6464417eje.30.2020.11.23.04.32.59; Mon, 23 Nov 2020 04:33:22 -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=vdDVGgWC; 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 S1730672AbgKWM35 (ORCPT + 99 others); Mon, 23 Nov 2020 07:29:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:40266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730647AbgKWM3u (ORCPT ); Mon, 23 Nov 2020 07:29:50 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B79422076E; Mon, 23 Nov 2020 12:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134590; bh=tW+TLAeov768jDsPmbg6pb66torvsqfj+KJgR8LR+HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vdDVGgWCplFVhBtFVwMP8GwsHhgPdc10hepSGWnmsw5a3jw0Tis5I4joZqxRYDFtm 0KK8UW19/V7imeFHX3MBw+FEokP10/i8fPo+RGrTIxqT1Q/vlKuD2uLx2YFQMEeymD 1xRrmpctaLE0Kzfvc1fgSjxR5RpRWYmG88y9gpNs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Moore , Jakub Kicinski Subject: [PATCH 4.19 13/91] netlabel: fix our progress tracking in netlbl_unlabel_staticlist() Date: Mon, 23 Nov 2020 13:21:33 +0100 Message-Id: <20201123121809.945357311@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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: Paul Moore [ Upstream commit 866358ec331f8faa394995fb4b511af1db0247c8 ] The current NetLabel code doesn't correctly keep track of the netlink dump state in some cases, in particular when multiple interfaces with large configurations are loaded. The problem manifests itself by not reporting the full configuration to userspace, even though it is loaded and active in the kernel. This patch fixes this by ensuring that the dump state is properly reset when necessary inside the netlbl_unlabel_staticlist() function. Fixes: 8cc44579d1bd ("NetLabel: Introduce static network labels for unlabeled connections") Signed-off-by: Paul Moore Link: https://lore.kernel.org/r/160484450633.3752.16512718263560813473.stgit@sifl Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/netlabel/netlabel_unlabeled.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/net/netlabel/netlabel_unlabeled.c +++ b/net/netlabel/netlabel_unlabeled.c @@ -1179,12 +1179,13 @@ static int netlbl_unlabel_staticlist(str struct netlbl_unlhsh_walk_arg cb_arg; u32 skip_bkt = cb->args[0]; u32 skip_chain = cb->args[1]; - u32 iter_bkt; - u32 iter_chain = 0, iter_addr4 = 0, iter_addr6 = 0; + u32 skip_addr4 = cb->args[2]; + u32 iter_bkt, iter_chain, iter_addr4 = 0, iter_addr6 = 0; struct netlbl_unlhsh_iface *iface; struct list_head *iter_list; struct netlbl_af4list *addr4; #if IS_ENABLED(CONFIG_IPV6) + u32 skip_addr6 = cb->args[3]; struct netlbl_af6list *addr6; #endif @@ -1195,7 +1196,7 @@ static int netlbl_unlabel_staticlist(str rcu_read_lock(); for (iter_bkt = skip_bkt; iter_bkt < rcu_dereference(netlbl_unlhsh)->size; - iter_bkt++, iter_chain = 0, iter_addr4 = 0, iter_addr6 = 0) { + iter_bkt++) { iter_list = &rcu_dereference(netlbl_unlhsh)->tbl[iter_bkt]; list_for_each_entry_rcu(iface, iter_list, list) { if (!iface->valid || @@ -1203,7 +1204,7 @@ static int netlbl_unlabel_staticlist(str continue; netlbl_af4list_foreach_rcu(addr4, &iface->addr4_list) { - if (iter_addr4++ < cb->args[2]) + if (iter_addr4++ < skip_addr4) continue; if (netlbl_unlabel_staticlist_gen( NLBL_UNLABEL_C_STATICLIST, @@ -1216,10 +1217,12 @@ static int netlbl_unlabel_staticlist(str goto unlabel_staticlist_return; } } + iter_addr4 = 0; + skip_addr4 = 0; #if IS_ENABLED(CONFIG_IPV6) netlbl_af6list_foreach_rcu(addr6, &iface->addr6_list) { - if (iter_addr6++ < cb->args[3]) + if (iter_addr6++ < skip_addr6) continue; if (netlbl_unlabel_staticlist_gen( NLBL_UNLABEL_C_STATICLIST, @@ -1232,8 +1235,12 @@ static int netlbl_unlabel_staticlist(str goto unlabel_staticlist_return; } } + iter_addr6 = 0; + skip_addr6 = 0; #endif /* IPv6 */ } + iter_chain = 0; + skip_chain = 0; } unlabel_staticlist_return: