From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B6C2C32792 for ; Mon, 30 Sep 2019 16:38:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 44CFB2168B for ; Mon, 30 Sep 2019 16:38:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732344AbfI3QiW (ORCPT ); Mon, 30 Sep 2019 12:38:22 -0400 Received: from mga07.intel.com ([134.134.136.100]:13138 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731459AbfI3QiW (ORCPT ); Mon, 30 Sep 2019 12:38:22 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2019 09:38:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,567,1559545200"; d="scan'208";a="392134005" Received: from vcostago-desk1.jf.intel.com (HELO vcostago-desk1) ([10.54.70.82]) by fmsmga006.fm.intel.com with ESMTP; 30 Sep 2019 09:38:21 -0700 From: Vinicius Costa Gomes To: Vladimir Oltean , davem@davemloft.net Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, netdev@vger.kernel.org, Vladimir Oltean Subject: Re: [PATCH net] net: sched: taprio: Avoid division by zero on invalid link speed In-Reply-To: <20190928233722.15054-1-olteanv@gmail.com> References: <20190928233722.15054-1-olteanv@gmail.com> Date: Mon, 30 Sep 2019 09:39:02 -0700 Message-ID: <871rvx91sp.fsf@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Vladimir Oltean writes: > The check in taprio_set_picos_per_byte is currently not robust enough > and will trigger this division by zero, due to e.g. PHYLINK not setting > kset->base.speed when there is no PHY connected: > > [ 27.109992] Division by zero in kernel. > [ 27.113842] CPU: 1 PID: 198 Comm: tc Not tainted 5.3.0-rc5-01246-gc4006b8c2637-dirty #212 > [ 27.121974] Hardware name: Freescale LS1021A > [ 27.126234] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) > [ 27.133938] [] (show_stack) from [] (dump_stack+0xb0/0xc4) > [ 27.141124] [] (dump_stack) from [] (Ldiv0_64+0x8/0x18) > [ 27.148052] [] (Ldiv0_64) from [] (div64_u64+0xcc/0xf0) > [ 27.154978] [] (div64_u64) from [] (div64_s64+0x4c/0x68) > [ 27.161993] [] (div64_s64) from [] (taprio_set_picos_per_byte+0xe8/0xf4) > [ 27.170388] [] (taprio_set_picos_per_byte) from [] (taprio_change+0x668/0xcec) > [ 27.179302] [] (taprio_change) from [] (qdisc_create+0x1fc/0x4f4) > [ 27.187091] [] (qdisc_create) from [] (tc_modify_qdisc+0x1ac/0x6f8) > [ 27.195055] [] (tc_modify_qdisc) from [] (rtnetlink_rcv_msg+0x268/0x2dc) > [ 27.203449] [] (rtnetlink_rcv_msg) from [] (netlink_rcv_skb+0xe0/0x114) > [ 27.211756] [] (netlink_rcv_skb) from [] (netlink_unicast+0x1b4/0x22c) > [ 27.219977] [] (netlink_unicast) from [] (netlink_sendmsg+0x284/0x340) > [ 27.228198] [] (netlink_sendmsg) from [] (sock_sendmsg+0x14/0x24) > [ 27.235988] [] (sock_sendmsg) from [] (___sys_sendmsg+0x214/0x228) > [ 27.243863] [] (___sys_sendmsg) from [] (__sys_sendmsg+0x50/0x8c) > [ 27.251652] [] (__sys_sendmsg) from [] (ret_fast_syscall+0x0/0x54) > [ 27.259524] Exception stack(0xe8045fa8 to 0xe8045ff0) > [ 27.264546] 5fa0: b6f608c8 000000f8 00000003 bed7e2f0 00000000 00000000 > [ 27.272681] 5fc0: b6f608c8 000000f8 004ce54c 00000128 5d3ce8c7 00000000 00000026 00505c9c > [ 27.280812] 5fe0: 00000070 bed7e298 004ddd64 b6dd1e64 > > Russell King points out that the ethtool API says zero is a valid return > value of __ethtool_get_link_ksettings: > > * If it is enabled then they are read-only; if the link > * is up they represent the negotiated link mode; if the link is down, > * the speed is 0, %SPEED_UNKNOWN or the highest enabled speed and > * @duplex is %DUPLEX_UNKNOWN or the best enabled duplex mode. > > So, it seems that taprio is not following the API... I'd suggest either > fixing taprio, or getting agreement to change the ethtool API. > > The chosen path was to fix taprio. > > Fixes: 7b9eba7ba0c1 ("net/sched: taprio: fix picos_per_byte miscalculation") > Signed-off-by: Vladimir Oltean > --- Acked-by: Vinicius Costa Gomes