Received: by 10.223.185.116 with SMTP id b49csp1138950wrg; Fri, 23 Feb 2018 12:37:27 -0800 (PST) X-Google-Smtp-Source: AH8x226vIJg7Nfmh2D3MGGeJc4d7Kcf456Gl5ipjqly6qftCU7IjFntYz70FlXtsnN5UdNhrAZPJ X-Received: by 2002:a17:902:bc02:: with SMTP id n2-v6mr2855042pls.52.1519418247860; Fri, 23 Feb 2018 12:37:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418247; cv=none; d=google.com; s=arc-20160816; b=X4/QoyrbR5UhGz1uGeAtipPIi6jO9K6FSI4gzLnHcTAxcl41KJW8fpdbZckGOSHZ7b QAy7IF2xOGZK7xQFM2xx54eAT96M17ZdlcfHo3Xnus2Mra1g8+KhG7LO/j1Kg9VK+AIu Z34emGlMqwwr8eSd0vtnwSCwsbAX3i1ma4rdGzlFFUkp/Obq/AfBoZj2y8S74NXkj8w0 FwJLiL6w6TgqRUhtzOqtAwnv4gRSrvenM1BPhj5DAGe/SrZRSkiCzgAjzc6zdgPmosjp qIceMiDBkKJoLm4Sj3OeE2aahY+ctPEHeEkShH3sbrzbKNZiJ4iFpMh3HiLLIrMaAN4q xYcg== 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=RSgNi3t4XwEZWrGUrSagR2+4rAp8NmwP8atHRZ5ooH8=; b=FrgCIT7qRNZBck/tZWwZQhptzwuuWrT4ivRwQklzXz/jFJV9VboF6QwF9nObzJBZMT FhBu5eynBa178va6RPzQSQBhosfMAQL+FQ8oMkkUwd5jxdziYajguoSRUvRpj1h72Zca gQ2ASiza1Do9Lx5lD/h1B3Ibhfs+Gk+npnEXTFiErTv+vGxvxsTNPmUvyFPy3MqovbzC Rz+RNHk8lipnfoUGLZhHQpWZu9KOnNtwsBLawnPVr41nFrabYCyizqImZhtp9CsuopVJ 34SV6T1ZhCr8SQxXQjyFDtzO/JDyZZwm5nqs9l7ikhvgJFDsBcip/pO7nIhofVAjMnzW 14LA== 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 r6si2311867pfl.304.2018.02.23.12.37.11; Fri, 23 Feb 2018 12:37:27 -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 S1753866AbeBWUg2 (ORCPT + 99 others); Fri, 23 Feb 2018 15:36:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37048 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753600AbeBWSem (ORCPT ); Fri, 23 Feb 2018 13:34:42 -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 E334D124C; Fri, 23 Feb 2018 18:34:41 +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.4 047/193] net_sched: red: Avoid illegal values Date: Fri, 23 Feb 2018 19:24:40 +0100 Message-Id: <20180223170333.345774015@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-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 @@ -167,6 +167,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 @@ -438,6 +438,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 @@ -389,6 +389,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 @@ -199,6 +199,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 @@ -633,6 +633,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)