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 EB64EC0015E for ; Wed, 9 Aug 2023 10:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232772AbjHIKze (ORCPT ); Wed, 9 Aug 2023 06:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232754AbjHIKzM (ORCPT ); Wed, 9 Aug 2023 06:55:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EC12359F for ; Wed, 9 Aug 2023 03:53:51 -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 5F70F63125 for ; Wed, 9 Aug 2023 10:53:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B2FEC433C9; Wed, 9 Aug 2023 10:53:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691578404; bh=juH9ctId16XYf5gpF5PmDGH6XwvebujxUwswtrc4IEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kx3WrvJVwiqDngS6+yX3vgcw+HC75BArmG6GK8kk+mh+oeHAox43e9qshfvVu4pUE kmYq2VzhDLtNjKlbPiFZy4KKIdrvpUBiBg2oUmC+JPg1B88PGvFUfYVDhMhmL8COo4 DGIu5AVL804fQJ4xjB9rVQJaUPB4jlXEXx0mTPqI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, valis , M A Ramdhan , Jamal Hadi Salim , Victor Nogueira , Pedro Tammela , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 048/127] net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free Date: Wed, 9 Aug 2023 12:40:35 +0200 Message-ID: <20230809103638.272885876@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809103636.615294317@linuxfoundation.org> References: <20230809103636.615294317@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: valis [ Upstream commit 3044b16e7c6fe5d24b1cdbcf1bd0a9d92d1ebd81 ] When u32_change() is called on an existing filter, the whole tcf_result struct is always copied into the new instance of the filter. This causes a problem when updating a filter bound to a class, as tcf_unbind_filter() is always called on the old instance in the success path, decreasing filter_cnt of the still referenced class and allowing it to be deleted, leading to a use-after-free. Fix this by no longer copying the tcf_result struct from the old filter. Fixes: de5df63228fc ("net: sched: cls_u32 changes to knode must appear atomic to readers") Reported-by: valis Reported-by: M A Ramdhan Signed-off-by: valis Signed-off-by: Jamal Hadi Salim Reviewed-by: Victor Nogueira Reviewed-by: Pedro Tammela Reviewed-by: M A Ramdhan Link: https://lore.kernel.org/r/20230729123202.72406-2-jhs@mojatatu.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/sched/cls_u32.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 0e3bb1d65be1c..ba93e2a6bdbb4 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -824,7 +824,6 @@ static struct tc_u_knode *u32_init_knode(struct net *net, struct tcf_proto *tp, new->ifindex = n->ifindex; new->fshift = n->fshift; - new->res = n->res; new->flags = n->flags; RCU_INIT_POINTER(new->ht_down, ht); -- 2.40.1