Received: by 10.223.185.116 with SMTP id b49csp1067609wrg; Fri, 23 Feb 2018 11:19:18 -0800 (PST) X-Google-Smtp-Source: AH8x224YL253qmya0P8c6bDLMK+KPVd8CJKWCx7iXAOW3fCwv/QSMFGapFSMgogA/LMDu3DKfq5z X-Received: by 10.98.242.65 with SMTP id y1mr2694223pfl.232.1519413558470; Fri, 23 Feb 2018 11:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519413558; cv=none; d=google.com; s=arc-20160816; b=aDvoprGo2plumRDZrDdFeTqnkD01etke0XZ6Hwrgb7Zc90uKNN8qY5CgflVRuodTP4 MisYpa3PgdV+DEYPPEveU+hpddcsnTU/AcGiyHbwUCp98K9/2XUYPY1AJI+uIg15JaYO NnYxweLuYkVBCBhTxeorMoGh6tE3wncXkDR/mJlx/mKEuxau7olRxUKwUxDKA2ac/9n+ QKSEVT2tT9dgmM68axSI0EjkM53vehSLDOh26pf/b3araNPmOx7zXeIfHIFca1QiEr7W MVIDwg9DVp1mzjv1TomdfI8EYYqpZDI+kOBtHxp2ttK8wgJaraCeuNVPpHVgVCNWEZmt BBVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mAACgXxvqdxkgUDTcMMFMMv01yQlO+GfY9lV3aVd4oY=; b=k2ggEMJx7B/udlrLfJ5NsPgq8PebyKSWsd3SKvQ9uuOmkNkpVv+bGXoqH3vR9YkxtC r28M3Q+DrvAsqTtwggq6j0ZdNGCC9B36VkDNCECaAK2DHCMLF6GvpETpMiXgWA1+X7F8 NMS1OBP1GYi6eYehOJpeuVp+oYbF99b8bD75DNZXEF9tgZ8T0W0bqEGSMbbFvyh5hgbm PyQvyu4rhABJLI1e1LP9DiVVXGPpGFiE4OIfg42oKYFw1r0g2Hw33l6n0zb0Dj+BF05Y fhFt4mK5qUreVA22wkK4kaACVaaCbj04/NJWRWzzmqk/Aeefma+2gVNQUnyuhZ9qMsnX jnFQ== ARC-Authentication-Results: i=1; mx.google.com; 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 g128si1851465pgc.207.2018.02.23.11.19.03; Fri, 23 Feb 2018 11:19:18 -0800 (PST) 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; 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 S965005AbeBWSys (ORCPT + 99 others); Fri, 23 Feb 2018 13:54:48 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:47914 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935511AbeBWSyq (ORCPT ); Fri, 23 Feb 2018 13:54:46 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 666001225; Fri, 23 Feb 2018 18:54:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nogah Frankel , "David S. Miller" , Sasha Levin Subject: [PATCH 4.14 113/159] net_sched: red: Avoid illegal values Date: Fri, 23 Feb 2018 19:27:01 +0100 Message-Id: <20180223170757.000289010@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nogah Frankel [ Upstream commit 8afa10cbe281b10371fee5a87ab266e48d71a7f9 ] Check the qmin & qmax values doesn't overflow for the given Wlog value. Check that qmin <= qmax. Fixes: a783474591f2 ("[PKT_SCHED]: Generic RED layer") Signed-off-by: Nogah Frankel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- include/net/red.h | 11 +++++++++++ net/sched/sch_choke.c | 3 +++ net/sched/sch_gred.c | 3 +++ net/sched/sch_red.c | 2 ++ net/sched/sch_sfq.c | 3 +++ 5 files changed, 22 insertions(+) --- a/include/net/red.h +++ b/include/net/red.h @@ -168,6 +168,17 @@ static inline void red_set_vars(struct r v->qcount = -1; } +static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog) +{ + if (fls(qth_min) + Wlog > 32) + return false; + if (fls(qth_max) + Wlog > 32) + return false; + if (qth_max < qth_min) + return false; + return true; +} + static inline void red_set_parms(struct red_parms *p, u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, u8 Scell_log, u8 *stab, u32 max_P) --- a/net/sched/sch_choke.c +++ b/net/sched/sch_choke.c @@ -369,6 +369,9 @@ static int choke_change(struct Qdisc *sc ctl = nla_data(tb[TCA_CHOKE_PARMS]); + if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog)) + return -EINVAL; + if (ctl->limit > CHOKE_MAX_QUEUE) return -EINVAL; --- a/net/sched/sch_gred.c +++ b/net/sched/sch_gred.c @@ -356,6 +356,9 @@ static inline int gred_change_vq(struct struct gred_sched *table = qdisc_priv(sch); struct gred_sched_data *q = table->tab[dp]; + if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog)) + return -EINVAL; + if (!q) { table->tab[dp] = q = *prealloc; *prealloc = NULL; --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -184,6 +184,8 @@ static int red_change(struct Qdisc *sch, max_P = tb[TCA_RED_MAX_P] ? nla_get_u32(tb[TCA_RED_MAX_P]) : 0; ctl = nla_data(tb[TCA_RED_PARMS]); + if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog)) + return -EINVAL; if (ctl->limit > 0) { child = fifo_create_dflt(sch, &bfifo_qdisc_ops, ctl->limit); --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -637,6 +637,9 @@ static int sfq_change(struct Qdisc *sch, if (ctl->divisor && (!is_power_of_2(ctl->divisor) || ctl->divisor > 65536)) return -EINVAL; + if (ctl_v1 && !red_check_params(ctl_v1->qth_min, ctl_v1->qth_max, + ctl_v1->Wlog)) + return -EINVAL; if (ctl_v1 && ctl_v1->qth_min) { p = kmalloc(sizeof(*p), GFP_KERNEL); if (!p)