Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp352219rwd; Thu, 8 Jun 2023 01:22:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6YUs4hYMOvidljZTCHz872qpfhIWzb97z7hHG5+y3OWfUsXU6uHa03W4HYeMNTF2oZ+J1G X-Received: by 2002:a05:6a20:6055:b0:101:4e04:cef1 with SMTP id s21-20020a056a20605500b001014e04cef1mr4542691pza.27.1686212538180; Thu, 08 Jun 2023 01:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686212538; cv=none; d=google.com; s=arc-20160816; b=NiPOsjh2qDpgUY7WztWdJQ2Y721nVl4pGkVrP8kceuC7LTaHGX/JwbrWbLBGBNrx0D X94MQTIAE1KDNaehg+OsjS7X0NSDW1ERAmDFPXc3FqcPfaqkkk6xDB719zHfIwtGNp6C qr5af2DLyVIB04f641SWFOuVJkC7u6TBaUkp80hbxLCM5ccZVPwBGhpD7ezpLEonNGCV nCu25ZkWfNdcnEfMFNXSRUJS4LYkssV0G3evDbe9C9VaFohbf53Yogv7z4nJsDn4QmXS oNkYlHS8yCoUBiy/FElxepfq9JQEoy69F/TkCbkKBX+jTHNUOq7q6vVXNtfXTDeSCTqe hYyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=C4IwGO7WlAGPAfxGdMiCxKMQ8qKcwza9OnJP6EsM0l0=; b=A90sZ6VMy3+Wuh03YSDp6nwgvzDxRnwWQQUMIZSyYR2OvphnXbCNMqOPEuVMMOF/ff zY5ghWN7DoTBYX2Lw9WiW5I6EYdSArWn4yaUsD+4WQifYuCuXIRhEoQ784Arv3vj/IB4 XH6CMuAWF5GvckIAEkpar7E/msXG2gnJdtrKdr+4tZKz9cHL2bov3l+0I+UhD8RHB1KM FaWQbN8FQP8PYMF2rJdgisv+cdaGcx387Rb93/RAfQey/uPgTXpwwf8pHEip0mjPuyRS U5rz/ofDjgayX54rEZJBXHVYqM7zWKGO/yL/7BHolGAFB1fyOPSCvCAKR7yqsBhTZa2Q qHOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qseVyII1; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a638848000000b0053fbb190cb9si645049pgd.572.2023.06.08.01.22.05; Thu, 08 Jun 2023 01:22:18 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=qseVyII1; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232940AbjFHHrO (ORCPT + 99 others); Thu, 8 Jun 2023 03:47:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232908AbjFHHrJ (ORCPT ); Thu, 8 Jun 2023 03:47:09 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A949210C for ; Thu, 8 Jun 2023 00:47:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0A9406497B for ; Thu, 8 Jun 2023 07:47:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 638D5C433EF; Thu, 8 Jun 2023 07:47:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686210426; bh=hexUjmGVaD550ltGipYVsnItZsinP867PWCzA8Kpc6I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qseVyII1AFg/7sj+nnd00HB53hHnIme3H5bFgsuhy0G9mGUpfKTF9VdGHOpuYLiZu FFruR/60nIcknTgSmk84zRr7IpJsT1NQDYDJEWeT37fBXmwLVCkJrRretHv3ds11W3 Iivdg9slVae27pRz+OwTpdwWFROTMiOm0VqD1eW7jMnyR0X5e++VbFtmtQyhf2XQd7 jeE9LbK4eT3GefT6iec3QI5sWwAnDpFj6B559+Lv327JEZrKnsLMoJrDOY9tDT8Xg2 0uDocHAqFpceECfllyqbdRa5xHF8FEXns4sWszrtREM7VWNplJNa/luUqJj0+Eciz7 oqcCGmGEvNF/A== Date: Thu, 8 Jun 2023 08:47:01 +0100 From: Lee Jones To: Eric Dumazet Cc: jhs@mojatatu.com, xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, stable@kernel.org Subject: Re: [PATCH v2 1/1] net/sched: cls_u32: Fix reference counter leak leading to overflow Message-ID: <20230608074701.GD1930705@google.com> References: <20230608072903.3404438-1-lee@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Thu, 08 Jun 2023, Eric Dumazet wrote: > On Thu, Jun 8, 2023 at 9:29 AM Lee Jones wrote: > > > > In the event of a failure in tcf_change_indev(), u32_set_parms() will > > immediately return without decrementing the recently incremented > > reference counter. If this happens enough times, the counter will > > rollover and the reference freed, leading to a double free which can be > > used to do 'bad things'. > > > > In order to prevent this, move the point of possible failure above the > > point where the reference counter is incremented. Also save any > > meaningful return values to be applied to the return data at the > > appropriate point in time. > > > > This issue was caught with KASAN. > > > > Fixes: 705c7091262d ("net: sched: cls_u32: no need to call tcf_exts_change for newly allocated struct") > > Suggested-by: Eric Dumazet > > Signed-off-by: Lee Jones > > --- > > Thanks Lee ! No problem. Thanks for your help. > Reviewed-by: Eric Dumazet -- Lee Jones [李琼斯]