Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2459491imd; Fri, 2 Nov 2018 11:46:35 -0700 (PDT) X-Google-Smtp-Source: AJdET5euy95tViSm+kaH29F8YA1meNklaITfpO36NT5980GFVIa4yImo817z/Jml7++uQPJ0j8/M X-Received: by 2002:a17:902:b943:: with SMTP id h3-v6mr12065528pls.124.1541184395458; Fri, 02 Nov 2018 11:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541184395; cv=none; d=google.com; s=arc-20160816; b=vdy6fi8y6qye7VpHLx78boqEPvoa3U5X4q9qQ6Uujpxyl8NgoxdVV3JZ0VCz8rSTy2 8g6J9y+9fhSXSF99Lb4pvLMr1IeemEv1DOaOAifx3graHlDWslj53C+jSik2v6RuVMIB 18hFt2FxwGtrTQkgx3MoTSBFrIMHJ5Yhsltug5A4HahTZENEOwcxcMVNGxGX07NwiFlT IQ017rlogvMbPZvvG1z9uvXT5UTe7OClwq0oT6h1iiPktLpHu9JIFFmKYrLzCG7u6d39 ECq3OLGtwuKpAfFrvz/Rj9iSjlrK4YdMqhBUT55Bg2Fe5A80wD0lQmB9/9DbI0OM+GDz 2piQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=o2qv/aUkhGX0Q58jvffgFUxU4GFEzfPkkVYcbAHMI8c=; b=K7hHNwY2sDv4cMpKYJwSFA50lmsjwqHYFWV82q7Q+tXCvDWggri34RTSGMrHCrWxZ+ LwORwU5V87Viw1vDLxwoekGdKGLw898K7UuraKrde5lQuuC8Y/ePMGKf1OdbfIQhaTzo w7BnHvAyLdjaWQZqgnITpWND4tiA9inbc6fzsJichLBuENcza7RlynjPWbTM+1ArvX1q HTGx+Lb1030kNtFCkUPqSw/HheT1PxA31OCLNdhkOQi2Sil1hboY1txZrYTo8Eu3rXh0 JGywQVpUJ4tJgBbbrBh/Q0MTH3CYe10SEiZMlnSxkcIPNzWYigGtTuFmQEc1CTuPJebl FVMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gj5cv97Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si30126974pfb.155.2018.11.02.11.46.19; Fri, 02 Nov 2018 11:46:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gj5cv97Q; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730140AbeKCDxU (ORCPT + 99 others); Fri, 2 Nov 2018 23:53:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:48918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728985AbeKCDxT (ORCPT ); Fri, 2 Nov 2018 23:53:19 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.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 1F0EF20847; Fri, 2 Nov 2018 18:45:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541184306; bh=erG/1a0vWBV+4W/H37C9ZJ+idoOveP8AgGP4vgwwcu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Gj5cv97QL/tmDRvUqodts6nU68pmjqif+n14borMAFmUhL/N2BN5VVEgel3Bj6pcs qv0LzMmIdu1ke0fD2JHQj+WGacbnLmth5W69w1sRSTY7+cgC5EV2NPc+T6SH2MfV1m kyrTidRF4K3oWJU7esfTBnxRcrBjODgq5yg2mN8A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Davide Caratti , "David S. Miller" Subject: [PATCH 4.18 130/150] net/sched: cls_api: add missing validation of netlink attributes Date: Fri, 2 Nov 2018 19:34:52 +0100 Message-Id: <20181102182911.832588717@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181102182902.250560510@linuxfoundation.org> References: <20181102182902.250560510@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Davide Caratti [ Upstream commit e331473fee3d500bb0d2582a1fe598df3326d8cd ] Similarly to what has been done in 8b4c3cdd9dd8 ("net: sched: Add policy validation for tc attributes"), fix classifier code to add validation of TCA_CHAIN and TCA_KIND netlink attributes. tested with: # ./tdc.py -c filter v2: Let sch_api and cls_api share nla_policy they have in common, thanks to David Ahern. v3: Avoid EXPORT_SYMBOL(), as validation of those attributes is not done by TC modules, thanks to Cong Wang. While at it, restore the 'Delete / get qdisc' comment to its orginal position, just above tc_get_qdisc() function prototype. Fixes: 5bc1701881e39 ("net: sched: introduce multichain support for filters") Signed-off-by: Davide Caratti Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_api.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c @@ -31,6 +31,8 @@ #include #include +extern const struct nla_policy rtm_tca_policy[TCA_MAX + 1]; + /* The list of all installed classifier types */ static LIST_HEAD(tcf_proto_base); @@ -1083,7 +1085,7 @@ static int tc_new_tfilter(struct sk_buff replay: tp_created = 0; - err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); + err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack); if (err < 0) return err; @@ -1226,7 +1228,7 @@ static int tc_del_tfilter(struct sk_buff if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN)) return -EPERM; - err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); + err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack); if (err < 0) return err; @@ -1334,7 +1336,7 @@ static int tc_get_tfilter(struct sk_buff void *fh = NULL; int err; - err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL, extack); + err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, rtm_tca_policy, extack); if (err < 0) return err; @@ -1488,7 +1490,8 @@ static int tc_dump_tfilter(struct sk_buf if (nlmsg_len(cb->nlh) < sizeof(*tcm)) return skb->len; - err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, NULL, NULL); + err = nlmsg_parse(cb->nlh, sizeof(*tcm), tca, TCA_MAX, rtm_tca_policy, + NULL); if (err) return err;