stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Nogah Frankel <nogahf@mellanox.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 4.14 055/100] net_sched: red: Avoid illegal values
Date: Sun, 28 Jan 2018 22:26:34 +0000	[thread overview]
Message-ID: <20180128222547.7398-55-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180128222547.7398-1-alexander.levin@microsoft.com>

From: Nogah Frankel <nogahf@mellanox.com>

[ 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 <nogahf@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 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(+)

diff --git a/include/net/red.h b/include/net/red.h
index 5918f78d36a0..9665582c4687 100644
--- a/include/net/red.h
+++ b/include/net/red.h
@@ -168,6 +168,17 @@ static inline void red_set_vars(struct red_vars *v)
 	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)
diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c
index b30a2c70bd48..531250fceb9e 100644
--- a/net/sched/sch_choke.c
+++ b/net/sched/sch_choke.c
@@ -369,6 +369,9 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt)
 
 	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;
 
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index 17c7130454bd..bc30f9186ac6 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -356,6 +356,9 @@ static inline int gred_change_vq(struct Qdisc *sch, int dp,
 	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;
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c
index 93b9d70a9b28..d87c41e82917 100644
--- a/net/sched/sch_red.c
+++ b/net/sched/sch_red.c
@@ -184,6 +184,8 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt)
 	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);
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 74ea863b8240..3fbf20126045 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -637,6 +637,9 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
 	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)
-- 
2.11.0

  parent reply	other threads:[~2018-01-28 22:27 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-28 22:25 [PATCH AUTOSEL for 4.14 001/100] usb: build drivers/usb/common/ when USB_SUPPORT is set Sasha Levin
2018-01-28 22:25 ` [PATCH AUTOSEL for 4.14 003/100] ARM: OMAP2+: Fix SRAM virt to phys translation for save_secure_ram_context Sasha Levin
2018-01-28 22:25 ` [PATCH AUTOSEL for 4.14 002/100] serdev: fix receive_buf return value when no callback Sasha Levin
2018-01-28 22:25 ` [PATCH AUTOSEL for 4.14 004/100] ARM: AM33xx: PRM: Remove am33xx_pwrdm_read_prev_pwrst function Sasha Levin
2018-01-28 22:25 ` [PATCH AUTOSEL for 4.14 005/100] ARM: dts: Fix omap4 hang with GPS connected to USB by using wakeupgen Sasha Levin
2018-01-28 22:25 ` [PATCH AUTOSEL for 4.14 007/100] ARM: dts: logicpd-somlv: Fix wl127x pinmux Sasha Levin
2018-01-28 22:25 ` [PATCH AUTOSEL for 4.14 006/100] ARM: dts: logicpd-som-lv: Fix gpmc addresses for NAND and enet Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 008/100] ARM: dts: am4372: Correct the interrupts_properties of McASP Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 009/100] ARM: dts: am437x-cm-t43: Correct the dmas property of spi0 Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 011/100] perf help: Fix a bug during strstart() conversion Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 010/100] perf record: Fix -c/-F options for cpu event aliases Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 012/100] perf annotate: Do not truncate instruction names at 6 chars Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 013/100] perf test shell: Fix check open filename arg using 'perf trace' on s390x Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 014/100] perf: Fix header.size for namespace events Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 016/100] perf bench numa: Fixup discontiguous/sparse numa nodes Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 015/100] perf top: Fix window dimensions change handling Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 017/100] perf test: Fix test 21 for s390x Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 019/100] kvm: arm: don't treat unavailable HYP mode as an error Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 018/100] pinctrl: denverton: Fix UART2 RTS pin mode Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 020/100] trace/xdp: fix compile warning: 'struct bpf_map' declared inside parameter list Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 022/100] media: ov13858: Select V4L2_FWNODE Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 021/100] media: s5k6aa: describe some function parameters Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 023/100] net: mvpp2: allocate zeroed tx descriptors Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 025/100] gpio: davinci: Assign first bank regs for unbanked case Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 024/100] gpio: 74x164: Fix crash during .remove() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 026/100] pinctrl: sunxi: Fix A80 interrupt pin bank Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 027/100] pinctrl: sunxi: Fix A64 UART mux value Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 028/100] IB/hfi1: Initialize bth1 in 16B rc ack builder Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 029/100] meson-gx-socinfo: Fix package id parsing Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 030/100] KVM: arm/arm64: Fix spinlock acquisition in vgic_set_owner Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 031/100] i40iw: Allocate a sdbuf per CQP WQE Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 033/100] i40iw: Correct ARP index mask Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 032/100] i40iw: Do not free sqbuf when event is I40IW_TIMER_TYPE_CLOSE Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 034/100] RDMA/cma: Make sure that PSN is not over max allowed Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 035/100] IB/core: Init subsys if compiled to vmlinuz-core Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 036/100] md/raid5: correct degraded calculation in raid5_error Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 037/100] sctp: only update outstanding_bytes for transmitted queue when doing prsctp_prune Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 038/100] sfp: fix RX_LOS signal handling Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 039/100] phylink: ensure we take the link down when phylink_stop() is called Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 040/100] md/raid1/10: add missed blk plug Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 041/100] iio: proximity: sx9500: Assign interrupt from GpioIo() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 042/100] iio: fix kernel-doc build errors Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 043/100] scripts/kernel-doc: Don't fail with status != 0 if error encountered with -none Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 044/100] bnxt_en: Need to unconditionally shut down RoCE in bnxt_shutdown Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 045/100] ipvlan: Add the skb->mark as flow4's member to lookup route Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 046/100] m68k: add missing SOFTIRQENTRY_TEXT linker section Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 047/100] powerpc/perf: Fix oops when grouping different pmu events Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 048/100] PM / runtime: Fix handling of suppliers with disabled runtime PM Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 049/100] s390/virtio: add BSD license to virtio-ccw Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 050/100] s390/dasd: prevent prefix I/O error Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 051/100] ARM: dts: Fix elm interrupt compiler warning Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 052/100] nfp: fix port stats for mac representors Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 053/100] gianfar: fix a flooded alignment reports because of padding issue Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 054/100] net_sched: red: Avoid devision by zero Sasha Levin
2018-01-28 22:26 ` Sasha Levin [this message]
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 056/100] VSOCK: fix outdated sk_state value in hvs_release() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 057/100] KVM: VMX: fix page leak in hardware_setup() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 058/100] net: qualcomm: rmnet: Fix leak on transmit failure Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 059/100] dccp: CVE-2017-8824: use-after-free in DCCP code Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 060/100] locking/lockdep: Fix possible NULL deref Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 061/100] sched/wait: Fix add_wait_queue() behavioral change Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 062/100] btrfs: Fix quota reservation leak on preallocated files Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 063/100] Btrfs: disable FUA if mounted with nobarrier Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 064/100] btrfs: Fix possible off-by-one in btrfs_search_path_in_tree Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 065/100] brcmfmac: Avoid build error with make W=1 Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 066/100] virtio_net: fix return value check in receive_mergeable() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 067/100] net: ethernet: arc: fix error handling in emac_rockchip_probe Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 069/100] net: dsa: mv88e6xxx: Unregister MDIO bus on error path Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 068/100] net: dsa: mv88e6xxx: Fix interrupt masking on removal Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 070/100] 509: fix printing uninitialized stack memory when OID is empty Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 072/100] scsi: lpfc: Use after free in lpfc_rq_buf_free() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 071/100] gianfar: Disable EEE autoneg by default Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 073/100] scsi: bfa: fix access to bfad_im_port_s Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 074/100] dmaengine: ioat: Fix error handling path Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 075/100] dmaengine: at_hdmac: fix potential NULL pointer dereference in atc_prep_dma_interleaved Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 076/100] xfrm: Fix xfrm_input() to verify state is valid when (encap_type < 0) Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 077/100] xfrm: Fix stack-out-of-bounds read on socket policy lookup Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 078/100] netfilter: nfnetlink_cthelper: Add missing permission checks Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 079/100] netfilter: xt_bpf: add overflow checks Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 081/100] netfilter: xt_osf: Add missing permission checks Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 080/100] clk: fix a panic error caused by accessing NULL pointer Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 082/100] staging: ccree: Uninitialized return in ssi_ahash_import() Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 084/100] spi: sun4i: disable clocks in the remove function Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 083/100] ASoC: rockchip: disable clock on error Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 085/100] IB/mlx4: Fix RSS hash fields restrictions Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 086/100] RDMA/netlink: Fix general protection fault Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 088/100] drm/armada: fix leak of crtc structure Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 087/100] xfrm: Fix stack-out-of-bounds with misconfigured transport mode policies Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 089/100] ASoC: rsnd: ssi: fix race condition in rsnd_ssi_pointer_update Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 090/100] drm/vc4: Release fence after signalling Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 091/100] dmaengine: jz4740: disable/unprepare clk if probe fails Sasha Levin
2018-01-28 22:26 ` [PATCH AUTOSEL for 4.14 092/100] usb: dwc3: gadget: Wait longer for controller to end command processing Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 093/100] usb: dwc3: of-simple: fix missing clk_disable_unprepare Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 095/100] x86/mm/kmmio: Fix mmiotrace for page unaligned addresses Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 097/100] xen: XEN_ACPI_PROCESSOR is Dom0-only Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 096/100] platform/x86: dell-laptop: Fix keyboard max lighting for Dell Latitude E6410 Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 098/100] PCI: rcar: Fix use-after-free in probe error path Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 099/100] powerpc/perf/imc: Fix nest-imc cpuhotplug callback failure Sasha Levin
2018-01-28 22:27 ` [PATCH AUTOSEL for 4.14 100/100] hippi: Fix a Fix a possible sleep-in-atomic bug in rr_close Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180128222547.7398-55-alexander.levin@microsoft.com \
    --to=alexander.levin@microsoft.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nogahf@mellanox.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).