Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp5408551rwb; Tue, 1 Aug 2023 01:55:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlFE8jxiYbWX4Rt8RbMqiJxUbRVSxgqfWEqG6Frwf5gd2SDMWXlTP5/j+CezjRqY0gibzqvk X-Received: by 2002:a05:6358:3388:b0:134:ec7e:90f1 with SMTP id i8-20020a056358338800b00134ec7e90f1mr2319638rwd.10.1690880135758; Tue, 01 Aug 2023 01:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690880135; cv=none; d=google.com; s=arc-20160816; b=iDmdcQjJRfq00TkyahUb41VUtD3WKH0uP3gGq/Wx0RMDsNun4uDmByiZpOn0aspaXt 5Qr96NgMpfa0RdV63BbUlt1r3OLGt4UMpFNIMKiF3oAnWyVYRbBF5LLIDzeVLvC81YWt 7GZqkR9JkqHnaGxrwBuU2t0Ns36SGwhWn4S3weOx/LinD0C+DPv45KvRLzUMW0OLcvjm WF9PjZ/CWEKRQOfjKm1hSh3rQNdeeIRJSc0jBGSR9N53YzAEvDwOPkwhDDDKCMtiZEIu o2UWWN8CI1Ko/SvQVd5hkheaPe4cMdpdsv82Brp/oz6cn8O1mAXw1mdhgDqmztvJrRzf 13ag== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eTqwVUD/TyAwF1oFexRBLPGVy+1rXnG2mp6M8Bd4JJk=; fh=/Iz2u8CVnT0PJexQ5eaMS87Uw3KuQ2sDgzlbqOjNy8g=; b=oPcE8q0oVyvgXco1MWMEvZC/vm7MeYZGvcUPAc0PnAcGaa01Smufmy6G89WIUgvf1C ZnUnFs7PNXmNNtLmxioYSe1xKFXqrOUBJ36CN1bPsZV0GdFj3Gij/aGqTJtPHAhqcQ0F G5EvBHnNP/PFA3m42BmLpxTpHicJI2xqGlxC9IBtLcpi87yGw2ELwHtgde9LzYSr8Z5q X03BQw90qMDxF0Wr7402a6/t5NeuCym8uDdj7PZW19gf92dZRVc4IhVRbJmpqoeiHCyz pN+ZvMpH3SM3XUu/3ZunNEgIesY8rbimo5E/FEIcio4vacUqSdpslox6tJiA/ZZ12fuW NTUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AZBz4x7Y; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d187-20020a6336c4000000b0051b90567f99si5487882pga.690.2023.08.01.01.55.24; Tue, 01 Aug 2023 01:55:35 -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=@linuxfoundation.org header.s=korg header.b=AZBz4x7Y; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbjHAIYj (ORCPT + 99 others); Tue, 1 Aug 2023 04:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230509AbjHAIYg (ORCPT ); Tue, 1 Aug 2023 04:24:36 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2FDE18D; Tue, 1 Aug 2023 01:24:35 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4FF33614B7; Tue, 1 Aug 2023 08:24:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 342C0C433C8; Tue, 1 Aug 2023 08:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690878274; bh=gkk74t9As49XSJeT+8LUv0zRRxmwMv0p+C8NfbmPl7Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AZBz4x7Y8V6Yp4RfkN8c+sBfGIsAeDXHsN2N7xNltclI6Y37r0oskt+G6j7xErJbj 5NEXOYonN050QVNcZj8D3Wb2b9m6fl1Hr2Kvtpx+MQVpeadYQuV95XVSBBKKM30D1w eg/sBJMZ61btbOLDO2LZz4Uo9f7mcybxSlrd1MlM= Date: Tue, 1 Aug 2023 10:24:32 +0200 From: Greg KH To: Rishabh Bhatnagar Cc: lee@kernel.org, davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Eric Dumazet , Jamal Hadi Salim Subject: Re: [PATCH 4.14] net/sched: cls_u32: Fix reference counter leak leading to overflow Message-ID: <2023080102-certified-unrivaled-a048@gregkh> References: <20230727191554.21333-1-risbhat@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230727191554.21333-1-risbhat@amazon.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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, Jul 27, 2023 at 07:15:54PM +0000, Rishabh Bhatnagar wrote: > From: Lee Jones > > Upstream commit 04c55383fa5689357bcdd2c8036725a55ed632bc. > > 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 > Reviewed-by: Eric Dumazet > Acked-by: Jamal Hadi Salim > Signed-off-by: David S. Miller > Signed-off-by: Rishabh Bhatnagar > --- > net/sched/cls_u32.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) We need a 4.19.y backport before we can apply a 4.14.y version, as you do not want to upgrade and have a regression. thanks, greg k-h