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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4D3AC7EE23 for ; Thu, 8 Jun 2023 17:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236304AbjFHR7E (ORCPT ); Thu, 8 Jun 2023 13:59:04 -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: 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 [李琼斯]