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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 BA432C433B4 for ; Sat, 8 May 2021 17:25:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86233611BD for ; Sat, 8 May 2021 17:25:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229586AbhEHR0x (ORCPT ); Sat, 8 May 2021 13:26:53 -0400 Received: from vps0.lunn.ch ([185.16.172.187]:59420 "EHLO vps0.lunn.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbhEHR0w (ORCPT ); Sat, 8 May 2021 13:26:52 -0400 Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1lfQhs-003Ho6-Pe; Sat, 08 May 2021 19:25:36 +0200 Date: Sat, 8 May 2021 19:25:36 +0200 From: Andrew Lunn To: Dan Carpenter Cc: Florian Fainelli , Vivien Didelot , Vladimir Oltean , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH net] net: dsa: fix a crash if ->get_sset_count() fails Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.org On Sat, May 08, 2021 at 04:30:35PM +0300, Dan Carpenter wrote: > If ds->ops->get_sset_count() fails then it "count" is a negative error > code such as -EOPNOTSUPP. Because "i" is an unsigned int, the negative > error code is type promoted to a very high value and the loop will > corrupt memory until the system crashes. > > Fix this by checking for error codes and changing the type of "i" to > just int. > > Fixes: badf3ada60ab ("net: dsa: Provide CPU port statistics to master netdev") > Signed-off-by: Dan Carpenter Reviewed-by: Andrew Lunn Andrew