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 D1CE215AE7 for ; Wed, 20 Sep 2023 12:20:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55F7AC433CB; Wed, 20 Sep 2023 12:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1695212451; bh=cDzl8m902wu+cSBhdwZpAeBIzVnwLnpULpV4z4iMrvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmDmRz41yfDwHgaBbK9W72dDL/fQyXF+otDBdhIG2T1TAJLexP0xaX+XxQCTllY7c Rkj1cdKRy8x1ihminyvlMyYRn7s5YlFpg5m2pAKA12Ya39NOX44qZ84AqSdp99iZ3d ef4BO0W5oJLU6xspK3aUkr9TJIFca25q0+WInuFk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, valis , Bing-Jhong Billy Jheng , Jamal Hadi Salim , Victor Nogueira , Pedro Tammela , M A Ramdhan , Jakub Kicinski , Luiz Capitulino Subject: [PATCH 4.19 272/273] net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free Date: Wed, 20 Sep 2023 13:31:52 +0200 Message-ID: <20230920112854.610226971@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230920112846.440597133@linuxfoundation.org> References: <20230920112846.440597133@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: valis commit 76e42ae831991c828cffa8c37736ebfb831ad5ec upstream. When fw_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: e35a8ee5993b ("net: sched: fw use RCU") Reported-by: valis Reported-by: Bing-Jhong Billy Jheng 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-3-jhs@mojatatu.com Signed-off-by: Jakub Kicinski [ Fixed small conflict as 'fnew->ifindex' assignment is not protected by CONFIG_NET_CLS_IND on upstream since a51486266c3 ] Signed-off-by: Luiz Capitulino Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_fw.c | 1 - 1 file changed, 1 deletion(-) --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -277,7 +277,6 @@ static int fw_change(struct net *net, st return -ENOBUFS; fnew->id = f->id; - fnew->res = f->res; #ifdef CONFIG_NET_CLS_IND fnew->ifindex = f->ifindex; #endif /* CONFIG_NET_CLS_IND */