From patchwork Wed Aug 16 22:13:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1822050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=b5dw2LOh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RR2Tr1HPlz20G4 for ; Thu, 17 Aug 2023 08:13:50 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qWOlo-0001Uf-SL; Wed, 16 Aug 2023 22:13:40 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qWOll-0001Tb-Os for kernel-team@lists.ubuntu.com; Wed, 16 Aug 2023 22:13:37 +0000 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9BDA83F03D for ; Wed, 16 Aug 2023 22:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692224017; bh=qRjHcnYIJYMkPAnyx/LVsGtOwG0S6xx9j5iS0oIxzjY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b5dw2LOhNDAg+iD1z7ZRyctEXZqrC1P3ZoEiG6XbXKZKNrwy0Ux6Gw5NE86ddcg2G qwvKJCFSdv52PIO111q53274HvH09oskuGdak7Hw9IXHnPy5YkQP5H0pvT9pQHOrV5 Be66QZYdppjKcY+8hWmiwBcnGpUsxRXKURaMAfrAnDAoeOwkwks98UQwFk4vqTE1Nu 9DoTpe1Jd5+2HXR94NNoFS9LDpwT74dbMmnzcwgj5Yt7mWX8nDKNSz3rzvv+VQVheY asnbu1Bpdq0cV/sUBJI7wmIlCc7C+6L+Z7a98Rg3SlgVH1dyLpWOTDz2h129I/9/uJ OEvlk65vtbahQ== Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-4100bd13cb5so98171001cf.0 for ; Wed, 16 Aug 2023 15:13:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692224016; x=1692828816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qRjHcnYIJYMkPAnyx/LVsGtOwG0S6xx9j5iS0oIxzjY=; b=B5xXGbeaDHOAbH1zhSfs7dKqxOiPCobo2CFIjr7S0DbkfTU7DoQDjS25+RGMZmi3hP EFuzPQbUVfKPwLx+aATo1Y/QobtDZYjkILNOJuX/oc5uPXM1Z67cX9bbcXrLiao8SWLG n0AfUckiCBCk/LqXDdtsBkfUmRz0CbM1z6WEEW2eHktBWCOE6KogsiRIH0M5j5fWeNTB 4/JxmFE8zzZy3rCHJ91y2dfl0GznxLKk0bjIgNy2y5/gu+l4K7Z+hphGcD5EkJ7jr/HA Tt3uu56nyNMXoXHRhWF43g2vAYTufkfri+THdtgZlPsre0ZNkTfBbTVdrL5VeHRiPWhS bBug== X-Gm-Message-State: AOJu0YwVdMeZyfb4HPzgSygkkXebWDoRFI0RjZKTzFgws/IGOzI1Be4x Dnf3yhC+sI+q1mF3Q31OhitZg97YYpSbV3fGlsUddsrdVidNdSY5k2CDLITJYS70TcmVBtRHtwc R15ngZ0cuS0A6qaWUxJhSqN7gjFCYTcr/VELXlQIkVsOMKd7J9Q== X-Received: by 2002:a05:622a:34c:b0:406:9531:f894 with SMTP id r12-20020a05622a034c00b004069531f894mr3873071qtw.54.1692224016401; Wed, 16 Aug 2023 15:13:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPSGEuVMrHXrwCZqby82vIxe4QnWrRtXWZ7ph8Da0uBCATmM2LCpg6UiOHEwTOHUOLLvIwIg== X-Received: by 2002:a05:622a:34c:b0:406:9531:f894 with SMTP id r12-20020a05622a034c00b004069531f894mr3873053qtw.54.1692224016100; Wed, 16 Aug 2023 15:13:36 -0700 (PDT) Received: from cache-ubuntu.hsd1.nj.comcast.net ([2601:86:200:98b0:f97b:a3de:4e96:951c]) by smtp.gmail.com with ESMTPSA id jj6-20020a05622a740600b0040c72cae9f9sm4701352qtb.93.2023.08.16.15.13.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 15:13:35 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy-OEM-6.0/OEM-6.1][PATCH 1/3] net/sched: cls_u32: No longer copy tcf_result on update to avoid use-after-free Date: Wed, 16 Aug 2023 18:13:28 -0400 Message-Id: <20230816221330.39367-2-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816221330.39367-1-yuxuan.luo@canonical.com> References: <20230816221330.39367-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: valis 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 (cherry picked from commit 3044b16e7c6fe5d24b1cdbcf1bd0a9d92d1ebd81) CVE-2023-4128 Signed-off-by: Yuxuan Luo --- 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 d15d50de79802..d830ff3da9b8d 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -815,7 +815,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); From patchwork Wed Aug 16 22:13:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1822052 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=PoEVU5z+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RR2Tr1G0xz1ygN for ; Thu, 17 Aug 2023 08:13:50 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qWOls-0001WI-FR; Wed, 16 Aug 2023 22:13:44 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qWOlm-0001U6-W6 for kernel-team@lists.ubuntu.com; Wed, 16 Aug 2023 22:13:38 +0000 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id D0EB23F03D for ; Wed, 16 Aug 2023 22:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692224018; bh=0xWoz4HBydy1yla66y/Pi6BJ1srqyHAKBqCMB1D+pfc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PoEVU5z++Ff3Lot8CQ1JMik9jsg2FpyyX8Hh23iIQJWJq836cVasEkhwGRsHCG+k0 YvoAIfjrfi14bwFtewf/yT6WItmGxs01U/W3GcZj0qUhUl20Jp7DVMbGVb0/9owAEx p9M/+LaVIemRv3VUNvm3732rJ6F8tH7vKfaVCQyC9x2cb20ioGhXUBeGF0aayPTPRi zI4uc43hE7ZgDoRZ0WZUcc78HPOcez/c8oGREPkDkJS8gfrHFIHDApiwDqAEbhcjKy wHE48sBK8jNprY/BlAenBv/vUipw/0P5idJaEx7jOrx1BrLyV5tvRQ7JyUCXasBhGN itpJsVM2eEdWw== Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-408d32b89e8so67040901cf.1 for ; Wed, 16 Aug 2023 15:13:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692224017; x=1692828817; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0xWoz4HBydy1yla66y/Pi6BJ1srqyHAKBqCMB1D+pfc=; b=GwTqziV8a1pMOH5YUYU0x/2Kh+qYkYCOOOmg6SfsbVsbVipW1qca+0/gOG5sQEiD6O Wovjyoi/1zCrWvn979Hi2tuRgFOyqFbLBR9KmtkUN/s9FUGKhVvPeFo9uOSfMLMEJP6b PiWxaIIMXLAyTQ8wTLdKl5qJHH74wm2ZqKcjZl2+SWpu/efXyIXQ89xZntg2iqNzeWvP ixw+EEMtlRwcLXYsU8Q3rvD25NvTYm7+DWlIsZw2wlE9EfyNV9AMbh2zeLPjnTC1hek0 0v8Ulcqrk9HMwhK9nGgUWecZZS1FnQxQwRBfnCpvLKIZTH0chF7XvT2IdjzIiFx6biH+ vWxg== X-Gm-Message-State: AOJu0YzJ2ZduUt/pG5KqmG8ODs/uWLMxbDyI96HGgrucmpyS5NuCC8n0 PprQOPpxSQC1y3bIYpTWILCb4vpU947BcHlf88ikpVpm8rzWzUVmsjZyXWWyBRz1MecLolyo7K4 zUm/AJcsb5bweNSS3px9hb+S4LNjp9o6pq0qATmKXInQrHbobAA== X-Received: by 2002:a05:622a:11d0:b0:40f:f04f:df23 with SMTP id n16-20020a05622a11d000b0040ff04fdf23mr3702884qtk.63.1692224017565; Wed, 16 Aug 2023 15:13:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDAjdbC3iJcki7Vu5blcnXFC1j1Lsv5/7Y/4euPfbd+ztu+RPqSKqqtLvrYBmnSH+hPe1Zkw== X-Received: by 2002:a05:622a:11d0:b0:40f:f04f:df23 with SMTP id n16-20020a05622a11d000b0040ff04fdf23mr3702868qtk.63.1692224017223; Wed, 16 Aug 2023 15:13:37 -0700 (PDT) Received: from cache-ubuntu.hsd1.nj.comcast.net ([2601:86:200:98b0:f97b:a3de:4e96:951c]) by smtp.gmail.com with ESMTPSA id jj6-20020a05622a740600b0040c72cae9f9sm4701352qtb.93.2023.08.16.15.13.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 15:13:36 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy-OEM-6.0/OEM-6.1][PATCH 2/3] net/sched: cls_fw: No longer copy tcf_result on update to avoid use-after-free Date: Wed, 16 Aug 2023 18:13:29 -0400 Message-Id: <20230816221330.39367-3-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816221330.39367-1-yuxuan.luo@canonical.com> References: <20230816221330.39367-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: valis 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 (cherry picked from commit 76e42ae831991c828cffa8c37736ebfb831ad5ec) CVE-2023-4128 Signed-off-by: Yuxuan Luo --- net/sched/cls_fw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/sched/cls_fw.c b/net/sched/cls_fw.c index 8641f80593179..c49d6af0e0480 100644 --- a/net/sched/cls_fw.c +++ b/net/sched/cls_fw.c @@ -267,7 +267,6 @@ static int fw_change(struct net *net, struct sk_buff *in_skb, return -ENOBUFS; fnew->id = f->id; - fnew->res = f->res; fnew->ifindex = f->ifindex; fnew->tp = f->tp; From patchwork Wed Aug 16 22:13:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1822051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=QGEkAdmq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RR2Tr19ywz1yfk for ; Thu, 17 Aug 2023 08:13:50 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1qWOlq-0001V5-2u; Wed, 16 Aug 2023 22:13:42 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1qWOlo-0001US-4b for kernel-team@lists.ubuntu.com; Wed, 16 Aug 2023 22:13:40 +0000 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E736E3F314 for ; Wed, 16 Aug 2023 22:13:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1692224019; bh=zu6lyW62ytnW2KsHwiAULk24sGge1dZYsCpSfa/ocac=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QGEkAdmqj8qhklgks+TCZTHzoEjdcB/s1KHSDCyaogeGV7kTNeQqpPeKXkql+fdjB KvbEU45sHUOFwQ9lLMTvMKqur1sfhwJpAsogI6d3RklYR6DhHQCTBXWPmMX4r10n7/ MgBexuM6/Hv6yfD8P8zwwxz5OdZFEhuRTDC9veP1ffU3zQ9mRlFnpS6v2th7XDmQRe D5TU3VaogzpCbQ0iqLq+7M7ckV6ZH4ESJ3QQM3ra20QfLIM1cI54RyLMWgOzxfxPrZ a5T13q+x39t5A53eiozQT52I/KReSo5ORZb6zX2ZNCVnTl0iqLf0QoRF0TY6JIF0Ei N9Z0/W8QnoWgg== Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4103b75e1baso75367091cf.1 for ; Wed, 16 Aug 2023 15:13:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692224018; x=1692828818; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zu6lyW62ytnW2KsHwiAULk24sGge1dZYsCpSfa/ocac=; b=PcQUEOvu28P8+eqopAaMwEcf1c5Ulk+bZGPVMyDWntfcOS5vP2wuq4Li4svoGY6T+8 PLHD4ax30IGN89I4u5J9usIbCe83AkDJPfX3/fdWWCwiFOiMGhG+sgqNK61hXFeZKvIN WT62qg16E+2qeHnDgS3VpJwm5r6+OqpjUVnq8EGhVlyTb15vj/w7T/BIiDzzQIFmGEEO 52C2wuFQOXTMTpcmR7KNTHs6G99puZmDQAF59ZM82/jrfs6J0oGfwz2YTQx/VeBfCDVY 4sBPQCjyCXcs6BUz9jKf107Ge10Cm8oIxANF4c/5aSg411YB6+Vdiibr7BiFa4sDA+4I uUBw== X-Gm-Message-State: AOJu0Yy0YXKWZGl9H6n6oUKfG6xGSxsZuB6Sw87oBQC21dDkm7Lpeu8H tq+bcPlcghadS9i2ihxXg/JLNjhJRFlIxfGkzh5e0beViYgkmucSdE3hZoyxNcTv1vUEAup5TyH 7C2ICL2Fg3QslBmvKrPcM4IX8SNcSAKLH/THKfE1VV+vOHjaPsA== X-Received: by 2002:a05:622a:393:b0:403:edb0:65c5 with SMTP id j19-20020a05622a039300b00403edb065c5mr3908092qtx.68.1692224018690; Wed, 16 Aug 2023 15:13:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhLf1QwwwDRBpk1g5Cnon0lCOaeWng4AZVKsIq2EfRh1utFyr3qtKQxH1xjZJhuhY8YyBn6g== X-Received: by 2002:a05:622a:393:b0:403:edb0:65c5 with SMTP id j19-20020a05622a039300b00403edb065c5mr3908079qtx.68.1692224018427; Wed, 16 Aug 2023 15:13:38 -0700 (PDT) Received: from cache-ubuntu.hsd1.nj.comcast.net ([2601:86:200:98b0:f97b:a3de:4e96:951c]) by smtp.gmail.com with ESMTPSA id jj6-20020a05622a740600b0040c72cae9f9sm4701352qtb.93.2023.08.16.15.13.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Aug 2023 15:13:37 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [SRU][Jammy-OEM-6.0/OEM-6.1][PATCH 3/3] net/sched: cls_route: No longer copy tcf_result on update to avoid use-after-free Date: Wed, 16 Aug 2023 18:13:30 -0400 Message-Id: <20230816221330.39367-4-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230816221330.39367-1-yuxuan.luo@canonical.com> References: <20230816221330.39367-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: valis When route4_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: 1109c00547fc ("net: sched: RCU cls_route") 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-4-jhs@mojatatu.com Signed-off-by: Jakub Kicinski (cherry picked from commit b80b829e9e2c1b3f7aae34855e04d8f6ecaf13c8) CVE-2023-4128 Signed-off-by: Yuxuan Luo --- net/sched/cls_route.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index d0c53724d3e86..1e20bbd687f1d 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c @@ -513,7 +513,6 @@ static int route4_change(struct net *net, struct sk_buff *in_skb, if (fold) { f->id = fold->id; f->iif = fold->iif; - f->res = fold->res; f->handle = fold->handle; f->tp = fold->tp;