Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp348509ybe; Thu, 5 Sep 2019 23:55:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1TigdfSX1UzGdvsXo6rWrU4qRRgNtSEhyOJdJadsv3wsolnkfHJtIpOJ2MQO85bwJFXa8 X-Received: by 2002:a17:90a:6788:: with SMTP id o8mr8166426pjj.19.1567752929430; Thu, 05 Sep 2019 23:55:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567752929; cv=none; d=google.com; s=arc-20160816; b=VWU7nNEAcdknD3YLyTwzLGmXOS2lFxxiYzkeDH7MQioi5H5n9+U9Hg1mrLxbYhqSsU /3SWy0necs+mrhGfmQoQIBTStall4JNZXmOHkZPH8RarqP+eq9mUnJldkCcxnfd3Pltu guVtzh/VzRq4aEeIE9UlXyynLcJ1/fb/Xub11uR8wGqcrkG0g00KdWkXFq+YlruPcViV e7XZmUn64MROK7PJ5j0lIFIfpcVX3scze4lU6eqvr27u/JfnvnOLmTPPvhIceBDaSwLE S/JA+y+SG89fI9sxJ0aVMxbReONFpwsbarFzdz8cgoOtlF4E45wUVvYuZbA7vYmWGPRf Yb/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kB2jjwTxmG739/c0X2n3JU0/QMvBG/XQ10gbX2t4+Y0=; b=XrMPuQJPLhuabw64TJJUjR7KUpbVluCVqhruo9+G7o/8JflgytoPXH2/BxAlI2cWZZ FcE/tzc76H9wzujljZ0F6X/DxzKb/WkzALlB7D8G/CNz/0MdM0tsTegXAaDgFYQcePic A+2bFF0GbiLfT07yZ0LkIGI1KBsrz+D/uY1sqHfdP5K0reduzUquQxjhnWHNIGvG1vEb /5atOdUIK32VGbZzSs8cvnGlIa36U38dloy63n5OrTia0nE+qXfjyK2v9HtTD63TVrn9 18fp9CXe1a9fbxfzYX8fPQAB3WWxiMx5Eq79LM04qir6orYkUyDlDswZbnNtR+JRkeND v95Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fQ8fdCt8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si4113508pjw.31.2019.09.05.23.54.59; Thu, 05 Sep 2019 23:55:29 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fQ8fdCt8; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390511AbfIEUr0 (ORCPT + 99 others); Thu, 5 Sep 2019 16:47:26 -0400 Received: from mail-ed1-f68.google.com ([209.85.208.68]:41901 "EHLO mail-ed1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731142AbfIEUrZ (ORCPT ); Thu, 5 Sep 2019 16:47:25 -0400 Received: by mail-ed1-f68.google.com with SMTP id z9so4177585edq.8; Thu, 05 Sep 2019 13:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kB2jjwTxmG739/c0X2n3JU0/QMvBG/XQ10gbX2t4+Y0=; b=fQ8fdCt8EW4/NlLWLwQGlzuxB9Cb0xJQpoiNZFpeo7vpr1WiyuFy52ABSmJLhHRX2m o9A+tnlGklM4eqRSQN3Hcb2lkRhxkBtQPUMfjcM99jrctka6tLjodmyCyZdUlCoLwTxo gTa8VSJXt2JUBYOCOabyyPzREEmlZnlhgrFx7fdZ1wrdRBOhehNmhoGOK+mLw3L3DR/4 NIt6wa8pDEhChnM94cXIVZi4YTooBKMAYHRxs9hAmIiEp04Mtqnz6jIUJXfPmBHh1xWt xfR1K+JHkpuqvea3pXidDqDZ1GUZDJU5AzyzNPSTDSPNwxkg2hu4rb3mixSO1JlCGBDx 9oMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kB2jjwTxmG739/c0X2n3JU0/QMvBG/XQ10gbX2t4+Y0=; b=d7bgdxU+0xz0AVvDGy1dF+q9V4UJoJjgID7Lm30w6Zz1t6ngIVWenPxLNUDYhWnBe4 RekFifLywRi80Z2nv8cUxpC5vAjvltvQmPZW+a3sYDI69p9u1UyYFcIQJNd3qO16ECGr bkd8DXK62YP9PWeA9CDOdyfZlnv8P2t28fTZxHT4ZtrLPw8hCtxQtVBWued3/ah5m4r8 Cnv+W7KgIukm/jriFmbEr4PIa3Vu+Zr5E/LIMFBm6ujbGmAtFZNT2g7g3y4avW3X1bta vA7m12ltcGQJkulNQcq8m40Rubx9HlweFmf5oamIc3K9Kv+xj3+nds4XGiAZwPXnOCeB Tc1g== X-Gm-Message-State: APjAAAXXl5BC5/A044kwHNNI4Ty6sZdXoaVuckVBfd/uHYiFCXxt2kF+ ma89UjcKXHpJXH5BkdzvtOHS3mpThdSm6myPwI5WKE9h X-Received: by 2002:a17:906:4056:: with SMTP id y22mr4662235ejj.230.1567716444102; Thu, 05 Sep 2019 13:47:24 -0700 (PDT) MIME-Version: 1.0 References: <20190903010817.GA13595@embeddedor> <8736hd9ilm.fsf@intel.com> In-Reply-To: <8736hd9ilm.fsf@intel.com> From: Vladimir Oltean Date: Thu, 5 Sep 2019 23:47:13 +0300 Message-ID: Subject: Re: [PATCH] net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte To: Vinicius Costa Gomes Cc: Eric Dumazet , "Gustavo A. R. Silva" , Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , netdev , lkml 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 Hi Vinicius, On Wed, 4 Sep 2019 at 00:26, Vinicius Costa Gomes wrote: > > Hi, > > Vladimir Oltean writes: > > > Right. And while we're at it, there's still the potential > > division-by-zero problem which I still don't know how to solve without > > implementing a full-blown __ethtool_get_link_ksettings parser that > > checks against all the possible outputs it can have under the "no > > carrier" condition - see "[RFC PATCH 1/1] phylink: Set speed to > > SPEED_UNKNOWN when there is no PHY connected" for details. > > And there's also a third fix to be made: the netdev_dbg should be made > > to print "speed" instead of "ecmd.base.speed". > > For the ksettings part I am thinking on adding something like this to > ethtool.c. Do you think anything is missing (apart from the > documentation)? > > -> > > diff --git a/include/linux/ethtool.h b/include/linux/ethtool.h > index 95991e43..d37c80b 100644 > --- a/include/linux/ethtool.h > +++ b/include/linux/ethtool.h > @@ -177,6 +177,9 @@ void ethtool_convert_legacy_u32_to_link_mode(unsigned long *dst, > bool ethtool_convert_link_mode_to_legacy_u32(u32 *legacy_u32, > const unsigned long *src); > > +u32 ethtool_link_ksettings_to_speed(const struct ethtool_link_ksettings *settings, > + u32 default_speed); > + > /** > * struct ethtool_ops - optional netdev operations > * @get_drvinfo: Report driver/device information. Should only set the > diff --git a/net/core/ethtool.c b/net/core/ethtool.c > index 6288e69..80e3db3 100644 > --- a/net/core/ethtool.c > +++ b/net/core/ethtool.c > @@ -539,6 +539,18 @@ struct ethtool_link_usettings { > } link_modes; > }; > > +u32 ethtool_link_ksettings_to_speed(const struct ethtool_link_ksettings *settings, > + u32 default_speed) > +{ > + if (settings->base.speed == SPEED_UNKNOWN) > + return default_speed; > + > + if (settings->base.speed == 0) > + return default_speed; > + > + return settings->base.speed; > +} > + > /* Internal kernel helper to query a device ethtool_link_settings. */ > int __ethtool_get_link_ksettings(struct net_device *dev, > struct ethtool_link_ksettings *link_ksettings) Looks ok to me, but I have no saying over ethtool API. Actually I don't even know whom to ask - the output of ./scripts/get_maintainer.pl net/core/ethtool.c is a bit overwhelming. To avoid conflicts, there needs to be somebody out of us who takes Eric's simplification, with Gustavo's Reported-by tag, and the 2 ethtool & taprio patches to avoid division by zero, and the printing fix, and maybe do the same in cbs. Will you be the one? Should I? Thanks, -Vladimir