Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp509287pxb; Thu, 9 Sep 2021 06:08:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZc0UPalxmYibUxZotsFwyHxHYPEzSXrxihrd8m2pU6XPTAl0EX3bbeoSmsXmHNn9q6l8H X-Received: by 2002:a05:6638:2690:: with SMTP id o16mr2841754jat.65.1631192891505; Thu, 09 Sep 2021 06:08:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631192891; cv=none; d=google.com; s=arc-20160816; b=HV+FW9MHgDwmBU2zTWiXkZftLwVZPy7CmPrneaDs4A1WyQa7PdubyILATdAfSBGrRP paJcLXjojpbolkU4jMM2WGfef13beZkZ3RLEaMzaqu1r34VXBQtWyR7Zj4zdnhbdiDoW MfqLFQFSp5f9m9CRHFkToIk0JaifhrxMcpIAx96Wo3Mb0P06nyuYaYBEQfpigKwl5Amn K9f+EfnvFdC7/ohgmWmqFc/pnxDadIzauw/puFlEb6qZSEAJBeO+DqYKA5jv1nDjzLFW uQoE+EQyThIWrnJfcne5oPzJ8JEVSkXVCDWxqQfO8XaKfGpDhmtdaqSH+FyfGOKrvvqN cBkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1DAsgREVIYKEdRIjW/b+SqFVpPuOzGU8Ueo5KZ0C94o=; b=LZBUKObF8BjANG9J/YATEdyl+U77dHEgb1yYXPQbr1N/qPRUAXyMVYAds9rL2E7Dhc tPGyTutTFmpOQhVa4p8NUhj+Njvu/SEqr/kJSqAGioMAimvgDqk3tyKnyaLEWx9O0NtK 7n+5hm/STvyqYGp4IKVXFDcphmQJ8zrNwUgerV5fwU806aU6BXhm4WGJbDJLNsL+RnF9 PSHswKkYEmHTsdFkWGOU61PMNUtJ2M6zwaSENEeLwrkKGqZwXxLEDJkct9Wo4iWzjpym RT4fi24XHA58En0brRbaUiNCLketYoySovMz7ONvOM6q8+E9c0fx0ELREoNXvwUlyLys FC/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LSob5iHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c1si1754052ilo.83.2021.09.09.06.07.50; Thu, 09 Sep 2021 06:08:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LSob5iHs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357784AbhIINEq (ORCPT + 99 others); Thu, 9 Sep 2021 09:04:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:42574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354802AbhIIMvm (ORCPT ); Thu, 9 Sep 2021 08:51:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 81D2463228; Thu, 9 Sep 2021 11:57:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631188644; bh=wnKwA/60iuYLeWzRlkpXSybYhrzrUEEMFGcIe5dL5PY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LSob5iHsKPHeRuihd/h0Ovlq0BfARrG5l0iFwsAylJGGh847h8fYxfKlNUAQgCeI+ xXnjaqAV8Fuz4OSfER1KpkMyn6LJ52GkltIQiJ/CmoY+/LA1K9hYROxMxkaNm8Zvz8 y9NL7O91VOGsVZLgitVVUV/EaBg1MlJOFBHRoboB0sLuVjxLepmlKTZk1CjV9gommP IbddpKM+ah6w63UpuupA3mPuBJjCLqA/g0ZA2SBi2mZalv0N/Ahr9JiX36VtPdISUI GP11M7nQGVNpbaS8EOcl6PKlJtvd8tifbNofniv6o0hVRXYdgm4/BcJzwZaZJoL0L1 mAA/f2gibeI4w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Haimin Zhang , syzbot+2b3e5fb6c7ef285a94f6@syzkaller.appspotmail.com, "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 108/109] fix array-index-out-of-bounds in taprio_change Date: Thu, 9 Sep 2021 07:55:05 -0400 Message-Id: <20210909115507.147917-108-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909115507.147917-1-sashal@kernel.org> References: <20210909115507.147917-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haimin Zhang [ Upstream commit efe487fce3061d94222c6501d7be3aa549b3dc78 ] syzbot report an array-index-out-of-bounds in taprio_change index 16 is out of range for type '__u16 [16]' that's because mqprio->num_tc is lager than TC_MAX_QUEUE,so we check the return value of netdev_set_num_tc. Reported-by: syzbot+2b3e5fb6c7ef285a94f6@syzkaller.appspotmail.com Signed-off-by: Haimin Zhang Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/sch_taprio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index a4de4853c79d..da9ed0613eb7 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -1503,7 +1503,9 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, taprio_set_picos_per_byte(dev, q); if (mqprio) { - netdev_set_num_tc(dev, mqprio->num_tc); + err = netdev_set_num_tc(dev, mqprio->num_tc); + if (err) + goto free_sched; for (i = 0; i < mqprio->num_tc; i++) netdev_set_tc_queue(dev, i, mqprio->count[i], -- 2.30.2