Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3408148rwa; Tue, 23 Aug 2022 04:23:59 -0700 (PDT) X-Google-Smtp-Source: AA6agR6UHLAjiFr92fZ4U90HssSh/vL9My406JXipuMdtr90V6rLfofG5XLx5AAKIBNpIEV01mLQ X-Received: by 2002:a05:6a00:1d23:b0:536:d3cb:2547 with SMTP id a35-20020a056a001d2300b00536d3cb2547mr5727981pfx.30.1661253839582; Tue, 23 Aug 2022 04:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253839; cv=none; d=google.com; s=arc-20160816; b=kP7eu6YE4gIUBJKGXu7dT/juG1DyjQOMGnviBPdpZXItGxfGI+Kid/SBkOnkhug1SK 5y6UmcqEaAyCyBbPQKIS+J+DtnVM1GakNThRBvT3jfgKbkDBUaufF6BfTYqysZFdIsnh WIAyu3QgVBcPcFlktAmbAU5s6iiWvnsWYX8vn8TQO/UfyiZDLv1jCPoUGnk9yv+7oaLp bKWUC0ObwTz+1X1AptV9i7Y9hl632MayOLgvJOnGaf+36AFklP4OduBpzAUQ0C6JqZHw T+aAoW7udHCMqxA8ytFb8yLEBf0ty7VJ89sIMaHJyak/wnK9aBUCz/kmEeUMrFVmi0zE gTYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pMoa41KtVwpsL1pTkWrosOiP5btaaKamhS3AdFvMFmI=; b=v2nstV44YSUNCvL1ElQB8Dqi4ylgCxNv485hTt89XE3BXcnEUFy3iEh8jo0YICBw4Q EANWycUvBv1iqzb7v7fweo3BlpFtLpzN5PRU6Ku2rtfjMDcq4enXpMgi/ut7ukjTjGSa DCO2MSyKY6KNlHS48/2VOmMPPygBNV973dmQv7/QGWzSIBw4sfiuhOxJEifZlFd5iIUj m7ZJvWZtolH2R8fXuWV2rrxb/NqWd3rLHnBtqpZjP37aTCkz3qPvDUIZ3nBtbXliubBu lIfrsIeiYR+uHkiRVHfbpRzRGNcjbUwl9I/zCn02/hWiDt4DbGgoJ5PmNjFsHep/1iRv tvFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="H/Tk5gZM"; 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 m1-20020a655641000000b00428feddd582si15749761pgs.853.2022.08.23.04.23.45; Tue, 23 Aug 2022 04:23:59 -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="H/Tk5gZM"; 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 S1356836AbiHWKwV (ORCPT + 99 others); Tue, 23 Aug 2022 06:52:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355775AbiHWKoS (ORCPT ); Tue, 23 Aug 2022 06:44:18 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A49B7AB044; Tue, 23 Aug 2022 02:10:29 -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 81870608D5; Tue, 23 Aug 2022 09:10:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88C53C433C1; Tue, 23 Aug 2022 09:10:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245827; bh=PQwFh3y1zqnoCjaqteSP56ZnA2D0ZUNmXY2D9oi4lEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/Tk5gZMTqvEqXGPHIc0S44svBVwcf52ATTIM3a8Vx0co5bCYkA2ScXTI2Zxwfq1g ME1Ybx7VsSRPwd8sjNDxOTSNMcjeQ6sdhKHnp/IErsri9nw2c/9F9INmFTc7J7n+uq qkJQZmiT8EwwNweOcR+kHAMY7YDcFKVbEVhFf1M0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhenpeng Lin , Thadeu Lima de Souza Cascardo , Kamal Mostafa , Jamal Hadi Salim , Jakub Kicinski Subject: [PATCH 4.19 201/287] net_sched: cls_route: remove from list when handle is 0 Date: Tue, 23 Aug 2022 10:26:10 +0200 Message-Id: <20220823080107.633720163@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 From: Thadeu Lima de Souza Cascardo commit 9ad36309e2719a884f946678e0296be10f0bb4c1 upstream. When a route filter is replaced and the old filter has a 0 handle, the old one won't be removed from the hashtable, while it will still be freed. The test was there since before commit 1109c00547fc ("net: sched: RCU cls_route"), when a new filter was not allocated when there was an old one. The old filter was reused and the reinserting would only be necessary if an old filter was replaced. That was still wrong for the same case where the old handle was 0. Remove the old filter from the list independently from its handle value. This fixes CVE-2022-2588, also reported as ZDI-CAN-17440. Reported-by: Zhenpeng Lin Signed-off-by: Thadeu Lima de Souza Cascardo Reviewed-by: Kamal Mostafa Cc: Acked-by: Jamal Hadi Salim Link: https://lore.kernel.org/r/20220809170518.164662-1-cascardo@canonical.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -528,7 +528,7 @@ static int route4_change(struct net *net rcu_assign_pointer(f->next, f1); rcu_assign_pointer(*fp, f); - if (fold && fold->handle && f->handle != fold->handle) { + if (fold) { th = to_hash(fold->handle); h = from_hash(fold->handle >> 16); b = rtnl_dereference(head->table[th]);