Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3547457rdg; Tue, 17 Oct 2023 20:29:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiqWMU4tJJD6qLgBFE3A/dfYEfCDsxmMjK1TopR3PsdIHCZ77kC8RNAk3/feCI8iy38RjM X-Received: by 2002:a17:903:41ce:b0:1ca:4d35:b2ec with SMTP id u14-20020a17090341ce00b001ca4d35b2ecmr5048656ple.15.1697599785505; Tue, 17 Oct 2023 20:29:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697599785; cv=none; d=google.com; s=arc-20160816; b=ypLxBtG14XAPXvGApHTubAKKEmO6XuXEgvABiUr1mIKDVoBHTkZLpcNh+bSML54e6T kF1iSRX+9P8OOT7jVnSFMImGWd4H1XHu0p8Scx+QIL/8T6+XqyJDBFtk2NdefTBJqQJH c6Gh1iPU9dM5BmyDJss5+F740RXqkbcSWp0fv/bJyXQXFJHFKl54zuUJDc3U9shQe0lE JIBd9Il8HjausxpTXus9PA/KymEiSI1AFx+J9IUpta00EBnTn/IwVznYV4zy2QIbZtrs KFR9LKoXNWlbZ8teAvjNrpBnPFdPRjESuJVCQXef65Hdk8++rWezxKKWKpDcmu0Ai9Vu sPoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=rB3yO5CFPR/z27+3SDqITeR/OP1w6vghIiwQqFJIjm4=; fh=hWIvzt2IQ8XhPOfG26Wm5vlhbiUTyEC5QsvFRx0vzxw=; b=hVQnkUah+hY5PqRe29LqQ+1MqImrtlqsMNJ2b/dTRcKjqU4hNO/OHKdIyl1C4WGAga 5XZ4enFCKdQpSIk97VRB2c3ALYV7yk61Rmtfq8D+JH1gXLBaXC/GLewMoKfsD1hNxRG8 F2/lA2v5rPuJveLmYKThZz0mxjZ6ZtBgc5x8BMNKKDig3QKSYR1n9dSkfOjXM1J1AXBW CPTn02jNvsH30/XfDGKlkks2URgHfuRDoEQWzJ86+ehTadJBU3fvkoCMwon1VeNq68si J9NoPb2vSq1bRjZNzwS/FnyhD71p7LmbfhtskoPxTggpPYSG0h6c9TJP5dDOYjU07073 xn5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G0+9ydww; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ba8-20020a170902720800b001bdafae4b7dsi1046668plb.43.2023.10.17.20.29.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 20:29:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=G0+9ydww; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 369CB80DF255; Tue, 17 Oct 2023 20:29:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229454AbjJRD3m (ORCPT + 99 others); Tue, 17 Oct 2023 23:29:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjJRD3m (ORCPT ); Tue, 17 Oct 2023 23:29:42 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC66FA; Tue, 17 Oct 2023 20:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697599780; x=1729135780; h=from:to:cc:subject:date:message-id; bh=phDj3684tOP+B+d0MXIvzoUnOpESFYXdBSU3w4+mZTY=; b=G0+9ydww8G/DnoWz214Myyx537j0v5vB3I78BHAE09KFFd6Ki1QIrT/N 1zBfRqLv3H8VhqkPaIjDf5EcR+ykpjbI4pxGh1F6gK/DQYEMlkMM1RjOs oTNQbRCVIje32mdE/qbEgwhSuxsVvhAzBF3Iy5CHJVekEynBvhiolw0iH WiVI/j+u4AtJf+GajLrMrUHSyv1xAk6lzGqkGGv21x42giGdYlHcs3tL9 qzjs+CQ6DpRYYVM+h04WBhouxlJPxIDb8BZ/EF6B9RVmkGLHJochucOE9 Ky9MH8LuUCHaRx/zkhNa/jaEfRdEsaK7I/GbLfoyi1cVFwHcLEkDlOZDk g==; X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="370990644" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="370990644" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Oct 2023 20:29:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10866"; a="847066898" X-IronPort-AV: E=Sophos;i="6.03,234,1694761200"; d="scan'208";a="847066898" Received: from ssid-ilbpg3.png.intel.com ([10.88.227.111]) by FMSMGA003.fm.intel.com with ESMTP; 17 Oct 2023 20:29:37 -0700 From: Lai Peter Jun Ann To: Vinicius Costa Gomes , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Lai Peter Jun Ann Subject: [PATCH net-next v2 1/1] taprio: Add boundary check for sched-entry values Date: Wed, 18 Oct 2023 11:28:27 +0800 Message-Id: <1697599707-3546-1-git-send-email-jun.ann.lai@intel.com> X-Mailer: git-send-email 1.9.1 X-Spam-Status: No, score=0.9 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 17 Oct 2023 20:29:44 -0700 (PDT) Adds boundary checks for the gatemask provided against the number of traffic class defined for each sched-entry. Without this check, the user would not know that the gatemask provided is invalid and the driver has already truncated the gatemask provided to match the number of traffic class defined. Signed-off-by: Muhammad Husaini Zulkifli Signed-off-by: Michael Sit Wei Hong Signed-off-by: Lai Peter Jun Ann --- net/sched/sch_taprio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c index 1cb5e41..44b9e21 100644 --- a/net/sched/sch_taprio.c +++ b/net/sched/sch_taprio.c @@ -102,6 +102,7 @@ struct taprio_sched { u32 max_sdu[TC_MAX_QUEUE]; /* save info from the user */ u32 fp[TC_QOPT_MAX_QUEUE]; /* only for dump and offloading */ u32 txtime_delay; + u8 num_tc; }; struct __tc_taprio_qopt_offload { @@ -1063,6 +1064,11 @@ static int fill_sched_entry(struct taprio_sched *q, struct nlattr **tb, return -EINVAL; } + if (entry->gate_mask >= q->num_tc) { + NL_SET_ERR_MSG(extack, "Traffic Class defined less than gatemask"); + return -EINVAL; + } + entry->interval = interval; return 0; @@ -1913,6 +1919,8 @@ static int taprio_change(struct Qdisc *sch, struct nlattr *opt, for (i = 0; i <= TC_BITMASK; i++) netdev_set_prio_tc_map(dev, i, mqprio->prio_tc_map[i]); + + q->num_tc = mqprio->num_tc; } err = parse_taprio_schedule(q, tb, new_admin, extack); -- 1.9.1