Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3898563rwb; Mon, 21 Nov 2022 00:38:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5kX2KzE/aFQylbkDls3+/peeGCL585GuI049KBDIARXWIL1DQbIc8FWqqrnd/1ojIFRgwd X-Received: by 2002:a05:6a00:1407:b0:537:15fc:f336 with SMTP id l7-20020a056a00140700b0053715fcf336mr7919107pfu.60.1669019886079; Mon, 21 Nov 2022 00:38:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669019886; cv=none; d=google.com; s=arc-20160816; b=gjJtnDoSIzH/T2xVJwG9hvJ5EoXdfw4C/XDsg2ac09LIFV701DC7FtD/wwAPsyDKvw mmgjrixks9hK8M7a1f7AV0/SXujjCIru85dND8oU1LET0agEstZ29TAa5KrZh5Et99pc V0AB5AnlexSsbbaGdhpL8uwkI040WdlgIVYGsX+yX8fOFMQIQQabZ5eclvAQLDgjxaRh TevKFA/SQ4qeCuz4qJac7+nEkKh8x4k9YnEs7jNaajLEmecBkC1SMpCOfJb1UTmzW42Y XcyXQq9t/few9X/fJtuinotmjK3k0srJVSSqpGh5ESyVQ/C3Z40ZCohStnyD0rV5OjpL +JpQ== 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=Vs2l23NxmyfDzTeykhjw4XnqjbPvSyKWp0TKAT504Gs=; b=0R78PRWKJEMsI8gny1Penu9sbBj12Sj3UhZ3rBfT5sOmiZ831Xx2JACTZNTXXI+O/Y F5eAzPxTrbDv7MryuRtZaLTo+tbAxjrfRVplbntKniGQgiHtTxlgfHSyIcmM8ABEZkqL IVK4OpLn+rzCi1Pc283hjKoLcclNhxKkmyD8Ww9KKNyz00R5jTqFUEBx/5ZKEBgbRGa3 qscgyIz/etvyRLeg/dGvgNBuUqBiE9OOR6KC35GslCCxm4JUpBubOgjqwOhKV68veVZP BhSnDphnq+vIwWNK3YPlo9KmtEe2xDWlhXSBylppQwrPEzoexYsP008uVrLnxsG4VnUN pjjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qZ5TqP+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h127-20020a636c85000000b00476e8270b1csi10578462pgc.675.2022.11.21.00.37.54; Mon, 21 Nov 2022 00:38:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qZ5TqP+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229774AbiKUH5T (ORCPT + 91 others); Mon, 21 Nov 2022 02:57:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbiKUH5S (ORCPT ); Mon, 21 Nov 2022 02:57:18 -0500 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C48BC04; Sun, 20 Nov 2022 23:57:17 -0800 (PST) Received: by mail-lf1-x135.google.com with SMTP id j4so17670274lfk.0; Sun, 20 Nov 2022 23:57:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Vs2l23NxmyfDzTeykhjw4XnqjbPvSyKWp0TKAT504Gs=; b=qZ5TqP+tU7NjssMr6vD8VJ70uIGXA+SK4QPz6fglRMTHclkDx/hz9TcruN6hw9XTMk JuDdr5vV0v8XrXshakEitOkB1K6RHeaTBIW8uLhJBYjJKS+w3nF8WjxgmpciZIrcK2mY EloizFriSWMWsMxGPDDXwtsqtUJWdhPJAWgzwkkUQ9sWpYS2zAFBLVLjPntiIfHmWkzP TMeuFaRBQn7q9M69nb6JF/hMrFzHs5mgtLQbScUVKQf9DgjmMHmbT6rFsPfS86MMMJhQ w64IGNmISHNJ9A9zzBV1v/z8YG7o1cnFIddNGfhMGdOZxxFWY/af1ti5gTHGynLLQtWe C2LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Vs2l23NxmyfDzTeykhjw4XnqjbPvSyKWp0TKAT504Gs=; b=0BMn/r6N/ZuFFi8Tg13IwmrUoJ7RvwYHgt3S8HYJ8rhgofXRmu340nNcy0Pysh9vBE +hCral1ClY1yzjiKTZHaynAy/1BV6i0FXvEJXwagdbsUvkoYLIen0RQxcXrzqPbu+MmS 4OJ+SF9yoh+CmzADvwpTI0Jll/Z41UFYBmL49MSdDOh2g8Yhofk1O4GabouN7QIlFMFB bBBJaqhFv4gsIP5ee43Na/rHLRKW7jSDuGKUrv3TMpG9nmilAHn+RcX6XoUQ91RLWcDR nr2Q50Kv9r9qZv0XoOgxUf+XTzKX2CTlJPrceHuI14uVSruPyjhhuTmwLCZuLvXGcdah o0sA== X-Gm-Message-State: ANoB5pmn2usfSCjVcJ5JaIZ001zeMyWk0wcAknID7Zg4m6RVlplGI89e YlL3dWhytPeyndGRYEadVh/gr2nLiFn9yIiQ9Idt3w== X-Received: by 2002:a05:6512:280e:b0:4a2:5154:ead9 with SMTP id cf14-20020a056512280e00b004a25154ead9mr5836045lfb.32.1669017435541; Sun, 20 Nov 2022 23:57:15 -0800 (PST) Received: from mkor.rasu.local ([212.22.67.162]) by smtp.gmail.com with ESMTPSA id y18-20020a05651c107200b0027741daec09sm1292904ljm.107.2022.11.20.23.57.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Nov 2022 23:57:15 -0800 (PST) From: Maxim Korotkov To: "David S. Miller" Cc: Maxim Korotkov , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Guangbin Huang , Andrew Lunn , Tom Rix , Marco Bonelli , Edward Cree , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] ethtool: avoiding integer overflow in ethtool_phys_id() Date: Mon, 21 Nov 2022 10:56:18 +0300 Message-Id: <20221121075618.15877-1-korotkov.maxim.s@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 The value of an arithmetic expression "n * id.data" is subject to possible overflow due to a failure to cast operands to a larger data type before performing arithmetic. Added cast of first operand to u64 for avoiding overflow. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 2adc6edcaec0 ("ethtool: fix error handling in ethtool_phys_id") Signed-off-by: Maxim Korotkov --- net/ethtool/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 6a7308de192d..cf87e53c2e74 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -2007,7 +2007,7 @@ static int ethtool_phys_id(struct net_device *dev, void __user *useraddr) } else { /* Driver expects to be called at twice the frequency in rc */ int n = rc * 2, interval = HZ / n; - u64 count = n * id.data, i = 0; + u64 count = (u64)n * id.data, i = 0; do { rtnl_lock(); -- 2.17.1