From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9896FC28CC7 for ; Mon, 3 Jun 2019 09:17:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71F87271D3 for ; Mon, 3 Jun 2019 09:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559553462; bh=hj/6jOVdQeEcp98w2HRhEApzSrTWJykIdH1r+KYOYr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=fdnhd5b5nIPlRmNdP/rsx3aDk/87YL8xU5psSIzrlM2kv4FQB2AL0GxZ0nbdJ7dZZ GTjSqv00F+G5wtTvq6cBNkhF6hTNHohoNOHKej+GWf+B9iNClnnOzKh7p0b/f1OAls TMjNoL3fzXT+HI6pIM3RO6303o5ImmnaQfpKUBuo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728266AbfFCJK7 (ORCPT ); Mon, 3 Jun 2019 05:10:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:55640 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728255AbfFCJK5 (ORCPT ); Mon, 3 Jun 2019 05:10:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 BFF7827E43; Mon, 3 Jun 2019 09:10:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559553056; bh=hj/6jOVdQeEcp98w2HRhEApzSrTWJykIdH1r+KYOYr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E9JKT+ddIQZYmRGV9ImElvsk7ZG/Qk+aOfXbUE9zMnEsX3NaiTGbuEbaOUqgd9H3L L4GBVQir0ixMYjq2OShCqxnemB5qMlPprg02YL5OunwCOxESmSzSOWiznDJ86HR1NU 9IGKxY94lPkh22T2if5STFsBl/kk71aRihMTlcD4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlad Buslov , Jamal Hadi Salim , "David S. Miller" Subject: [PATCH 4.19 15/32] net: sched: dont use tc_action->order during action dump Date: Mon, 3 Jun 2019 11:08:09 +0200 Message-Id: <20190603090313.391055196@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190603090308.472021390@linuxfoundation.org> References: <20190603090308.472021390@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Vlad Buslov [ Upstream commit 4097e9d250fb17958c1d9b94538386edd3f20144 ] Function tcf_action_dump() relies on tc_action->order field when starting nested nla to send action data to userspace. This approach breaks in several cases: - When multiple filters point to same shared action, tc_action->order field is overwritten each time it is attached to filter. This causes filter dump to output action with incorrect attribute for all filters that have the action in different position (different order) from the last set tc_action->order value. - When action data is displayed using tc action API (RTM_GETACTION), action order is overwritten by tca_action_gd() according to its position in resulting array of nl attributes, which will break filter dump for all filters attached to that shared action that expect it to have different order value. Don't rely on tc_action->order when dumping actions. Set nla according to action position in resulting array of actions instead. Signed-off-by: Vlad Buslov Acked-by: Jamal Hadi Salim Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/act_api.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -744,7 +744,7 @@ int tcf_action_dump(struct sk_buff *skb, for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) { a = actions[i]; - nest = nla_nest_start(skb, a->order); + nest = nla_nest_start(skb, i + 1); if (nest == NULL) goto nla_put_failure; err = tcf_action_dump_1(skb, a, bind, ref); @@ -1257,7 +1257,6 @@ tca_action_gd(struct net *net, struct nl ret = PTR_ERR(act); goto err; } - act->order = i; attr_size += tcf_action_fill_size(act); actions[i - 1] = act; }