From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF4319930 for ; Thu, 8 Jun 2023 17:58:48 +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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 [李琼斯]