Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1368838pxu; Mon, 23 Nov 2020 20:33:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPZmf0+HelG7eFyChH8LD8xR2I4QTHfnwkvOMnd5+NHZGeWxiVUhH/dLAQOrhf7J9WCPOu X-Received: by 2002:a50:cdc8:: with SMTP id h8mr2332582edj.37.1606192388101; Mon, 23 Nov 2020 20:33:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606192388; cv=none; d=google.com; s=arc-20160816; b=Dm9labQjdamRrGRzZOReczfwyq42jBdtdC0RePJupWoAfnkz1FAa+H9zkcgtgeod+O LPIOXrPKIq3lumJe4dX8f/NSZ/skMSlVCQYrzQmgqW7CXusVe40AkcQdsdidCNeHYsJP MLcFBYZoMF0JIKGvvOKv2RlU98PE23KQnkg8rikaMeTEU0l9Fi9CXkBezi8KBLri4oRI 6SsLr5m2686gtmq5YdFwlWK5QRs/mduQuCEtUiJ5oLTRxp/cfLYWwyXxwDcjLmOw4kx+ Ssz+QXCiTnluJ4PsIcGpWdc+aVBr9iPm93+VLR/TxBvCNgij6u4IS7L4Jdb2xqE+529s eNZw== 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=ouvlA99q6Efm5t5orCZ+m6C5s7FlrRwuveAHAzPnqdoHJKD6PYOscJHTZa6+cfDRV8 yV6x2DhcgEOXIDP07j6ZMzyhIHz5ZrJPcvMfh60q9IhE6mqVTfUFJEgt0TH/EALn02bK nydeLA3uTAi77q5NlAv4W2ajYqTBtT4Nw9zVGdbtbWKBhZ40OGEVRV1pipuwgk0W37yv uZWg13dl1fTp9PUlY1D9Vu85liZuQFs0xLveHl7OlSytnQuvslOlv5Haz6dPrIPtFDE7 FTQjlbCNV8pgLzQ2/NCqtJpyZpaHjd0hZhJMt9poGPQzK34itbbNfEINvL9sMTDaasnd pxCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nlQvh+sN; 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 q14si7669238edb.353.2020.11.23.20.32.45; Mon, 23 Nov 2020 20:33:08 -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=nlQvh+sN; 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 S2389378AbgKWNbx (ORCPT + 99 others); Mon, 23 Nov 2020 08:31:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:36858 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730209AbgKWM0z (ORCPT ); Mon, 23 Nov 2020 07:26:55 -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 07BE120888; Mon, 23 Nov 2020 12:26:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134414; bh=tW+TLAeov768jDsPmbg6pb66torvsqfj+KJgR8LR+HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlQvh+sN37+Up0JabrruoMyH0BHj5md/fQQqbhi4v+6DnEkcAfcBSmbz3onuTLamW KSOyBrZOa+p/fmnwF4y43+cnqdyJ5jc+O6LkGVBDfrC+r+qn9O+y1spn+Q+YePMEsL W51kM04vZFPqDcpb5YV3bksCHjploXmtJfQX/v68= 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.14 11/60] netlabel: fix our progress tracking in netlbl_unlabel_staticlist() Date: Mon, 23 Nov 2020 13:21:53 +0100 Message-Id: <20201123121805.575699865@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121805.028396732@linuxfoundation.org> References: <20201123121805.028396732@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: