Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3972055rdg; Wed, 18 Oct 2023 10:57:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQ+dsP/Nku4SHV2rKHuZKu0fLSX/k8nIOrsBM5UpvjMnOnaC41KNrEwsDsUWEhTO1fDvZS X-Received: by 2002:a05:6359:1a47:b0:166:c0e6:e7c2 with SMTP id ru7-20020a0563591a4700b00166c0e6e7c2mr6006271rwb.22.1697651858245; Wed, 18 Oct 2023 10:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697651858; cv=none; d=google.com; s=arc-20160816; b=zrZWUvRqFin2vVvH+9mIl/yUbBA5vgqAE8s9OmzfsG4qaMD2yTM7QozeDDR1VobTV2 Inv+1mU2fENFoJE42kPwnP1L0N0dcsnk0an8UA6jsI+sLvD0oP9DZ/AEU/jwlbZdBEpt mhNZ1x63LEpvKc73fROCTVR6J9t8kWmkCZKH01Pxfn0a8rYIJ25yefK1sn1oFcGR8qaO f+cv3FwOOPAE6vBYX6t+HV5z68TllEkxtqXjcGvMaEJ5Hwa4+VWW/OUo36xIcvaLVuUF txdtu7qVf4CcT68aQltDEp+NMKKDgGeaH3bOoKdAw2BZek8VA/ztgRuMVxM1RRCYrFA/ dfYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=j0ePCYNkPHfa3H9jsrngby8guSC1IWe7RaxvVj9+FaY=; fh=KZ+pCifU59JLmH2+5+oDQK4OYO0hY+0BQ+EWfLCcgGU=; b=cLDs7TYV+nbc7ZkAGV2xmb9Q+79bZYkJcirkS0wYOURCkK7pfFZofULFyltbpm3i86 DE3qrDIY8c3ECWLD/IS6XOKqnsncVX88u2C6y3xkV9AFAPgpKukH4rU3vHwDtoRjh+vz 4A8COvzKkXOlGm836beqEnMVRaPsxq6q+4b8Qnpj3Tysc8oxvgXF7NGRGe1ZYoeQMZMe uySV3BbCBh9UYStMVvFfmsgFRMmWeRuG8rsCYSx+9VQCx1HAag6ju7osa/WiMiNQd8h+ u9CnCL0p4gHnRwFvZ0fTuVNseds5+ip4Lvt++ili+QpZuVhBx6h31eSL8iD7dTgclq0H 41FA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@engleder-embedded.com header.s=dkim11 header.b=MsbIat7T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=engleder-embedded.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id b6-20020a63d306000000b0059bdf5a4ecfsi2447059pgg.247.2023.10.18.10.57.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 10:57:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=fail header.i=@engleder-embedded.com header.s=dkim11 header.b=MsbIat7T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=engleder-embedded.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id E18C6822CB2F; Wed, 18 Oct 2023 10:57:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231992AbjJRR5R (ORCPT + 99 others); Wed, 18 Oct 2023 13:57:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjJRR5C (ORCPT ); Wed, 18 Oct 2023 13:57:02 -0400 Received: from mx05lb.world4you.com (mx05lb.world4you.com [81.19.149.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498BA12E; Wed, 18 Oct 2023 10:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=engleder-embedded.com; s=dkim11; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=j0ePCYNkPHfa3H9jsrngby8guSC1IWe7RaxvVj9+FaY=; b=MsbIat7TOKssl45DTO3nM5wmxE y4eZYVNBvf4HdsA/3JbF4kBevsI3uOGqi7wrPp0pRp/d6ryREYJXDTdJdWzIaQxu18ck1G82Mar+c LZQXGdbeMAvIekOsX4xhUaF8UJiSQ9x28NaWzp80FlmEWWQMFsWE/aJQClvEnikF7I3Q=; Received: from [88.117.60.21] (helo=[10.0.0.160]) by mx05lb.world4you.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qtAmk-00007M-2X; Wed, 18 Oct 2023 19:56:46 +0200 Message-ID: <27912b49-eb1a-4100-a260-03299e8efdd4@engleder-embedded.com> Date: Wed, 18 Oct 2023 19:56:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net-next v2 1/1] taprio: Add boundary check for sched-entry values To: Lai Peter Jun Ann , 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 References: <1697599707-3546-1-git-send-email-jun.ann.lai@intel.com> Content-Language: en-US From: Gerhard Engleder In-Reply-To: <1697599707-3546-1-git-send-email-jun.ann.lai@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AV-Do-Run: Yes X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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 (lipwig.vger.email [0.0.0.0]); Wed, 18 Oct 2023 10:57:36 -0700 (PDT) On 18.10.23 05:28, Lai Peter Jun Ann wrote: > 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) { As far as I know within gate_mask every bit represents a traffic class. So for 3 traffic classes at gate_mask of 0x7 is valid but this check fails with 0x7 >= 3. > + 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);