Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1049149rwd; Thu, 8 Jun 2023 11:15:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6BCyYWQQZRpEpJyxw3H/g6VsUWRSr7EP3MjEQsoa3ovAbiXSJLuwApJSYnhAoyAzROXF69 X-Received: by 2002:a17:90a:190d:b0:258:9995:91cb with SMTP id 13-20020a17090a190d00b00258999591cbmr7525172pjg.49.1686248112859; Thu, 08 Jun 2023 11:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686248112; cv=none; d=google.com; s=arc-20160816; b=KA1DmLXT/dvq6kr6/zLkPFkKeDm421GNYmvKGmUSwC4jSXn0ORviIek7rT8uihzOwO SV6VeBtQ08Uc3SgNfhc4PA4Le8EanGWuAf73NMCJjOnwegXqN26W9Mf7Rw3rtXy7qyxD H8WxaQ3sDrZIxWN9G/57rALMlymdRYC8kQRj+/CeW8Fq7uCkOb1TQHAoLqGB8zk+a1PL aMJV2VmognvufHKUP8RGI+u0u/3/KZUZ1jloX+otGbIMgUjmqGAhucNGstJzXHkrKeYS P1TDS8v7UBWSv4t2/i7dq/GphyZm3iXPVHSD2Djx3NrB3tldCnk/vr5rtn7GxJqKb4fp XN+Q== 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=CpWHtTGH0dhtEGgFKt7AsjzC7Cnd8Qcvth9jifDAkIg=; b=t448oy9b1u6WFMBxycTTiXosc8/AcWCr2aUhba6bvbeHNnkI5+tj5DUnTcwEY0BIkl AO185KHjhtAdAchMpwlZSGleRYYpxnlL/DueJkIl8aseWu4xEnMSjhIxKZNHzGc1dOuF 0NpNZrWWf84cLEXnmwhPEuv2pgTN8jBhMpIotzJzCQv96wXL1FoDksx3zhKCW4Ew5yl2 YzbEyHovRfpXjjj8Qel07S/gN3n9Gdb3wa4iSHZ98Vn+l2wZFTttZDmJSa5QfmdqqBtB MGGIe0K/eVzNGK34UlXLcvq9WsS5guirgbq9cB+56TaEHS19prJ+vhD3IT+CvfWBFhYI wEUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YGadLPHW; 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 e6-20020a170902cf4600b001adb600d5e9si1283978plg.640.2023.06.08.11.14.59; Thu, 08 Jun 2023 11:15:12 -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=YGadLPHW; 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 S234989AbjFHR7D (ORCPT + 99 others); Thu, 8 Jun 2023 13:59:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235116AbjFHR7B (ORCPT ); Thu, 8 Jun 2023 13:59:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C747C2D6B for ; Thu, 8 Jun 2023 10:58:49 -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 2464065010 for ; Thu, 8 Jun 2023 17:58:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80501C433D2; Thu, 8 Jun 2023 17:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686247128; bh=H9vqqvqGv5gqr9XhvSYtAft9XyQ3waxGL9wQkTYdZSM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YGadLPHWvUuYpZJzVtNKteHBmHXberFWobCwJzXC9V+hm7og0zVsBB3NougAt4YgA W8e9YTf0FM5IAJWYglyDBjnFXWcVkxUuQ9u4tLtS9XuVQ03MPfSsQgbLvoOz5e8Z+b 4N4WUDAJQKaJ5zh1Es8bXVv2Ao9RjALoM7YUT1BWLo1xAwKL0jnYOtJNziaXaSwZxx 45XwgjGenK1LwtoX85Gl7AvQ1ZXI+bAMAcHpvSCtIGC1Aqf9cKnaMyaKVWJ6C38V2c efczC+CmQNTL3Si87fcPWj9r79IhmYct0m2su4t0bdgjH1/zA/TAA2HFDEmboRu03r tVoOuoCCy+oWw== Date: Thu, 8 Jun 2023 18:58:43 +0100 From: Lee Jones To: Jamal Hadi Salim Cc: Eric Dumazet , 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: <20230608175843.GA3635807@google.com> References: <20230608072903.3404438-1-lee@kernel.org> <20230608074701.GD1930705@google.com> 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, Jamal Hadi Salim wrote: > On Thu, Jun 8, 2023 at 3:47 AM Lee Jones wrote: > > > > 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 > > Acked-by: Jamal Hadi Salim Thanks Jamal. -- Lee Jones [李琼斯]