Received: by 10.223.185.116 with SMTP id b49csp1037922wrg; Fri, 23 Feb 2018 10:47:13 -0800 (PST) X-Google-Smtp-Source: AH8x227l4pq7GsIpTIl1VUoqGfaDFlVg5ZWk/CsDg2ppnJ9Cz1a8/ohloFTT9ZYmW2gwwsURAg4w X-Received: by 10.98.190.3 with SMTP id l3mr2649677pff.155.1519411633401; Fri, 23 Feb 2018 10:47:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411633; cv=none; d=google.com; s=arc-20160816; b=R77bGbPrBuawNqOWZdsrDQCvlEu59cD84DsX4NWxxji1uJN46aLpNM+UM+wbgArz7P jKOOJVxNVzy8OInOEGbGgfm4yaFd0RgLNYOGyeZ0GyAPRiVy1Vde4+u3yP3iWqDG1WQq YjUNIFZ0VfatPwcMGDtSjihAsdacKcp8/bXECE1qZ7eNjQYhGYJ+Nq5M0P9Js74QsZN1 97rtpxLa/AsHJuSbLDkt3MfgmVFMkjw3ucectfheYByFPvoFwMaWDe5uZ9Q1xEBokTWE 3jOYsxAi3P1or0tJoFyIEz6s3KcoGb2dOENISIiUh25H7d7UCH+vjXyacC2tpx5qx9cP yDEg== 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=eko4GCs6JpPcfn181V1PGbQ05pxW6HT1xikJovE+X50=; b=s897VxEqEU1XIq84pwAU6mwqadJPActxILiFCKL22DI6NBq6/yKFP+73TbyW5n5mZD FTdH91rW5plV91FWYCdqGvgHt6EMVh2TBwuVJp/Y+c+aZ9ehvMlGgGnJ2fB8UFdlVrKi dyhmJRjOMO3gFxXIqXV6++yu2PMtmjAvTBnLXHAW/L9+07tAQSPV9p9Ck8qDM4SHtCU4 Il+EF/LdN1pFocvdtXkCVvzs4MCh204OjtmDUzwpkWorowSKmjsE4+EUQtRyfW2PZiqA RpeaL4+GmVjpoMvXxePBBSqHmWEBojl5fE1SzYMfgF7W2w9Su2NM7SCby/ldgb9QeClw blXw== 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 f90-v6si2145632plb.63.2018.02.23.10.46.58; Fri, 23 Feb 2018 10:47:13 -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 S933736AbeBWSpK (ORCPT + 99 others); Fri, 23 Feb 2018 13:45:10 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43222 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933707AbeBWSpH (ORCPT ); Fri, 23 Feb 2018 13:45:07 -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 9317A1244; Fri, 23 Feb 2018 18:45:06 +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.9 066/145] net_sched: red: Avoid illegal values Date: Fri, 23 Feb 2018 19:26:12 +0100 Message-Id: <20180223170733.198862654@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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 @@ -424,6 +424,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 @@ -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)