Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp334322pxb; Mon, 16 Aug 2021 06:33:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyl/R96o0PvB/oO1L7oKPwlyMMPRnhUn+fYF+d+gVX8w7NhKQ/bbW3Od91hF6hTnwBpVZ2o X-Received: by 2002:aa7:d40f:: with SMTP id z15mr20102236edq.113.1629120811906; Mon, 16 Aug 2021 06:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629120811; cv=none; d=google.com; s=arc-20160816; b=Z8nF2/r3YN5Jrutt1/5U7gOw+nalha52uRcw1UJoNsAW3z2neznXJjZz68SYULGEEy BbqBC10uuyytea7ACmCDUpSkGIunPF3IRKnEoNrqEFsVWpLPHmdU105R6CF3oZ6bdLf5 ojmkCsHE3kBI7IRxTFcVHn0y+EtHB1vPjUCMzFJrlgzQWArkh5Ta9UsFhUgaQEDMPz47 ApnGF9VHAB8EllmijFanpZgrlBZlP5Y2qGOSOlffdsSbihQJYKFDwt/mOja+DWULv/mS o9Xoh5U8IC4wiYx2zag1Nc3gYOBGtPxXC3itW5R+WuVCkpcjceheJH+3lo48BxuNNcLR hhZw== 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=EaPwrWfL9KiKyywEjSkv0+yPMkk7BRBs/0SLhgJNknI=; b=U7zNbDgo5kls2j5VYHkb+31pWP3pVCedYUzlTQPYVW1XAYcX5RZxbD8N5CcKwvujU9 V/2RzTIkdUlyt8CibIHM3cdMwoxdLFqXGbrBQa2wo1skASPlGKBLD7LTm/IcSmtm+oQe NyVy5fwRLRKNj+P7bg41WWQC64/K7wK3gYhvTMURBvo1blK3UxnbM+C9Ykh74OJqkali hWQoiRN3JzYOK5d/P883K/H7iTgnmuak6p3HK1Wjc0G0SovUrVJwmnsySkhiTior9eNO TCDVOjSN/KpPIvOkALDnWqjnewa5EPlfKAPujMcRwBiA/qUd0B4XQu87z/yz0/OrI05Z hW8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d1VNC0eh; 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 v10si8309724ejq.753.2021.08.16.06.33.07; Mon, 16 Aug 2021 06:33:31 -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=d1VNC0eh; 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 S240721AbhHPN2p (ORCPT + 99 others); Mon, 16 Aug 2021 09:28:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:44416 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237904AbhHPNS3 (ORCPT ); Mon, 16 Aug 2021 09:18:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F05E632FF; Mon, 16 Aug 2021 13:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1629119635; bh=EsJcyuB2jOm7rySq7hOVmzO5ygDEUclTB5GC5IWEHcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d1VNC0eh1xqD7dl1jrfpbWwCJH+LVpkc9qVOGb44buWPvHhHdy/qcs9q0bjCbPebh TFpAaZIrdsXjXAIwYwTIEo7qugn09yeUOrwCj9EzjCp6/Rw/rvzfcZ7895jxbPVAEh s3JXQNWETF24z8nWRZXNSyyWM4+tlITciN/U7MYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.13 103/151] net: dsa: sja1105: fix broken backpressure in .port_fdb_dump Date: Mon, 16 Aug 2021 15:02:13 +0200 Message-Id: <20210816125447.472233474@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210816125444.082226187@linuxfoundation.org> References: <20210816125444.082226187@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: Vladimir Oltean [ Upstream commit 21b52fed928e96d2f75d2f6aa9eac7a4b0b55d22 ] rtnl_fdb_dump() has logic to split a dump of PF_BRIDGE neighbors into multiple netlink skbs if the buffer provided by user space is too small (one buffer will typically handle a few hundred FDB entries). When the current buffer becomes full, nlmsg_put() in dsa_slave_port_fdb_do_dump() returns -EMSGSIZE and DSA saves the index of the last dumped FDB entry, returns to rtnl_fdb_dump() up to that point, and then the dump resumes on the same port with a new skb, and FDB entries up to the saved index are simply skipped. Since dsa_slave_port_fdb_do_dump() is pointed to by the "cb" passed to drivers, then drivers must check for the -EMSGSIZE error code returned by it. Otherwise, when a netlink skb becomes full, DSA will no longer save newly dumped FDB entries to it, but the driver will continue dumping. So FDB entries will be missing from the dump. Fix the broken backpressure by propagating the "cb" return code and allow rtnl_fdb_dump() to restart the FDB dump with a new skb. Fixes: 291d1e72b756 ("net: dsa: sja1105: Add support for FDB and MDB management") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/sja1105/sja1105_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c index 4b05a2424623..0aaf599119cd 100644 --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -1625,7 +1625,9 @@ static int sja1105_fdb_dump(struct dsa_switch *ds, int port, /* We need to hide the dsa_8021q VLANs from the user. */ if (priv->vlan_state == SJA1105_VLAN_UNAWARE) l2_lookup.vlanid = 0; - cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data); + rc = cb(macaddr, l2_lookup.vlanid, l2_lookup.lockeds, data); + if (rc) + return rc; } return 0; } -- 2.30.2