Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp322188rwd; Thu, 8 Jun 2023 00:50:16 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eDu/lM2wf3xCwIhagLjX1X/yrK2fzPJzr2MCPLYv+tJc9h1Rkn70AOunYtg6vZEhgKAyF X-Received: by 2002:a05:6a20:3d1f:b0:10b:8698:2097 with SMTP id y31-20020a056a203d1f00b0010b86982097mr3009966pzi.0.1686210616634; Thu, 08 Jun 2023 00:50:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686210616; cv=none; d=google.com; s=arc-20160816; b=ynkGF5vncY1A6Oas8+9h+wPVB3Rii9fNdVKW23yuBW0GzUEWzofajwxdNBOcUuiTez OvkA5eHcvLukDV0yzdL8ej0mW9ZsmtfAYLaeYKoiFSkOSO8qE2vR1OAetOYaDSaenHAM BBsWuVac/u5xHWybtxJTqw5eik0HHxtbfHBT5gazn3YAc9zBuMJwHS4WBKEE5nPTIEYT qOWVHk9VBtbTAH9qSjm2ZOSwfl3FKEy+whX+PUm/8dLziV/eLEXDL5OEyuYM9GtGW6g1 Xf5fAVjYrSWxAyBeLyqCWAhD3A/+y+5QlDHCdsD5Wh9fSCvGhusrsrWK5pbFwzKUYHBR uCiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=87g/Pi+Xu07Ub0dymM1C1BRfTRU/yKYa/DAr34FHvz8=; b=rzB8s4uP9jPzIORrYbteTGLp8YldxwvnZzrdGaj4sla8qSSoEX5S0bLJCLshxas21Z 15/Sd3N+T278xiZ2zPg/ouEGpH/8gpwykDSEvUkC4andoDmYmeyDhGr1doLsxbTZ2sMi 35He9PEYMd/J0NHMbBKydJ2OZAlf54FbJCB/T5xZBFp1oy4fAyVv8cy7MQXR6S481ydb TqoKrlQ+Z38eLHCrlxOhzI23g3hVU6nkrCapD3V3bkjfdR0POJ9h2ofP7hETI0KE/seo wELVviUZEZlZdujOd2sMO9Ledvlljxc87+WMsB0wEJo0RJi+uESNwHUpOWpEcYBKTrqg 9beQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=oPA+9sJJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m1-20020a170902bb8100b001a6d4eab490si684801pls.63.2023.06.08.00.50.04; Thu, 08 Jun 2023 00:50:16 -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=@google.com header.s=20221208 header.b=oPA+9sJJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235434AbjFHHb2 (ORCPT + 99 others); Thu, 8 Jun 2023 03:31:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235431AbjFHHbX (ORCPT ); Thu, 8 Jun 2023 03:31:23 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506571FFA for ; Thu, 8 Jun 2023 00:31:21 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-3f7f7dfc037so30525e9.0 for ; Thu, 08 Jun 2023 00:31:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1686209480; x=1688801480; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=87g/Pi+Xu07Ub0dymM1C1BRfTRU/yKYa/DAr34FHvz8=; b=oPA+9sJJdMdXsbev9YSi3SiSm2ZIqYn2qd3oymrV4pZ86OY5FZi24DS9+2KcyGRAdK BdYOSFxaSEW0HMMPZPt8EoN47jKiTb1uVWbn5FVXtvgV7HyNEXxcpSUZe/UROcCFS38u K/WPtSeUIfvmjJxH8GNjXN4sRDUg7tP69WWOvtCUNx0QW5WJPG2SWt9+wULwcYGHhjor b2tWR9tMwBsX4hiD0ZoxdtOZlBRouZs88VYpC5yHSQhezUeT05D4rr9JN+awq7BFw/H+ a0wX+RotiLgzVz5R2NIt1Z8lalSzA+WjBwmHv81BgQdXM3VaxDagWD3ay/vgHq5zTKqq auaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686209480; x=1688801480; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=87g/Pi+Xu07Ub0dymM1C1BRfTRU/yKYa/DAr34FHvz8=; b=KEyK5UkC6eZLo5SzJ7o5Lr89829l7VcX9NLkoG1I06/FnkAmHJ0Z9Gn3/43TwLREB6 gEN267d3tGTxTL9yYp/6Qwc8WQWOOfSwlONRcSlzAMtjK6W7AMIEloGmdwbNg6PDrq9e U8FS3K75cY3vUSAoFuw0Pr3O7qqvamoUWmoCraSNlzxxNhSuIW0sTtQERn0kyGphTJcJ Mzgme7bSgOqKuhK1bsASL9tWC9xp9qdLx2GTXCvvql5oRqlABwUXed2b3v7/VOAc1Ohm M6pRxo6okw8tss1v2xcstNguTa/PpcSF5BSoEoCwz+wQyTV7fPnnkeFvoW4jluqRat31 Lv6Q== X-Gm-Message-State: AC+VfDzHxxvhRqXhgX4gKUlr4rh1FoCLIMoIgtG9f3fd2MN5qGoX7ve/ Z3+hR/RteO/rFjgXeU5dJLrVD+wwwLmijt43s7NgXw== X-Received: by 2002:a05:600c:3b2a:b0:3f7:ba55:d038 with SMTP id m42-20020a05600c3b2a00b003f7ba55d038mr116077wms.6.1686209479606; Thu, 08 Jun 2023 00:31:19 -0700 (PDT) MIME-Version: 1.0 References: <20230608072903.3404438-1-lee@kernel.org> In-Reply-To: <20230608072903.3404438-1-lee@kernel.org> From: Eric Dumazet Date: Thu, 8 Jun 2023 09:31:07 +0200 Message-ID: Subject: Re: [PATCH v2 1/1] net/sched: cls_u32: Fix reference counter leak leading to overflow To: Lee Jones 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable 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, Jun 8, 2023 at 9:29=E2=80=AFAM 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_chang= e for newly allocated struct") > Suggested-by: Eric Dumazet > Signed-off-by: Lee Jones > --- Thanks Lee ! Reviewed-by: Eric Dumazet