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 1C6F01F63F6 for ; Fri, 27 Dec 2024 15:03:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735311831; cv=none; b=c7dx5gNCZwz8R4LRv1F1k42O+abcc8nxr1dm6KPqcunVfU7jaHfU9UtHX8ko19lj4w0NXlSMV0Xlxh1XjMzwuQ0cegDtVVQLhRYV0L4KeXrpW1eMkARk8YkmaFbJmenBzDehrHOSvjDdNI3k2C8jkclG7OWBfSL5DYjjmDnObs8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735311831; c=relaxed/simple; bh=Be9dQvWzJHTguHILKgHsr/QqJ2ualHuXb21nZVO0Dp8=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=f/zwKTBYVxUG2ysxavhyD4n53pI021w63JRNnoGOXiOwXkLeKqFQ1zl7/+qL1OeCQfUS6UfwbYwlrwXwg/2Ll6X9KuILWIxb20P7qHj5Q/TQmXOLWFRX0RJthRInsslPopeRrh1ECJntOhZHhm2dgKbtG4OGncrfCB/tYxkAguA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QRW3n2oV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QRW3n2oV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80C67C4CED0; Fri, 27 Dec 2024 15:03:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1735311831; bh=Be9dQvWzJHTguHILKgHsr/QqJ2ualHuXb21nZVO0Dp8=; h=From:To:Cc:Subject:Date:Reply-to:From; b=QRW3n2oVrkU8ua+hG77vrPoVcE15K8SY93+q92dbTMMWvIkPvx3itNJX8yBLIGThK AYLeBzS1PSMY9O0hJmTEpPxY4WOU0ixt1k22DxKZ7l74f6CFjgZgcWYvoSIG55uJ9Z hst4+pLQCzF7Sc2nqNMjFV68styGLtTwBOs6fkWI= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-56640: net/smc: fix LGR and link use-after-free issue Date: Fri, 27 Dec 2024 16:02:41 +0100 Message-ID: <2024122736-CVE-2024-56640-ef22@gregkh> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4123; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Be9dQvWzJHTguHILKgHsr/QqJ2ualHuXb21nZVO0Dp8=; b=owGbwMvMwCRo6H6F97bub03G02pJDOl5B3t2rt5Sdz7+vPaM10u+TN1nYJIjIF3GuOnfw7jbZ m3zJyu974hlYRBkYpAVU2T5so3n6P6KQ4pehranYeawMoEMYeDiFICJPDzBMD9GZ9sWf8Wt150n Bfx5uTf3UezfQy8Z5pfKnXDPVZy/hi2uedPHb5GzgptZFwEA X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: net/smc: fix LGR and link use-after-free issue We encountered a LGR/link use-after-free issue, which manifested as the LGR/link refcnt reaching 0 early and entering the clear process, making resource access unsafe. refcount_t: addition on 0; use-after-free. WARNING: CPU: 14 PID: 107447 at lib/refcount.c:25 refcount_warn_saturate+0x9c/0x140 Workqueue: events smc_lgr_terminate_work [smc] Call trace: refcount_warn_saturate+0x9c/0x140 __smc_lgr_terminate.part.45+0x2a8/0x370 [smc] smc_lgr_terminate_work+0x28/0x30 [smc] process_one_work+0x1b8/0x420 worker_thread+0x158/0x510 kthread+0x114/0x118 or refcount_t: underflow; use-after-free. WARNING: CPU: 6 PID: 93140 at lib/refcount.c:28 refcount_warn_saturate+0xf0/0x140 Workqueue: smc_hs_wq smc_listen_work [smc] Call trace: refcount_warn_saturate+0xf0/0x140 smcr_link_put+0x1cc/0x1d8 [smc] smc_conn_free+0x110/0x1b0 [smc] smc_conn_abort+0x50/0x60 [smc] smc_listen_find_device+0x75c/0x790 [smc] smc_listen_work+0x368/0x8a0 [smc] process_one_work+0x1b8/0x420 worker_thread+0x158/0x510 kthread+0x114/0x118 It is caused by repeated release of LGR/link refcnt. One suspect is that smc_conn_free() is called repeatedly because some smc_conn_free() from server listening path are not protected by sock lock. e.g. Calls under socklock | smc_listen_work ------------------------------------------------------- lock_sock(sk) | smc_conn_abort smc_conn_free | \- smc_conn_free \- smcr_link_put | \- smcr_link_put (duplicated) release_sock(sk) So here add sock lock protection in smc_listen_work() path, making it exclusive with other connection operations. The Linux kernel CVE team has assigned CVE-2024-56640 to this issue. Affected and fixed versions =========================== Issue introduced in 4.18 with commit 3b2dec2603d5b06ad3af71c1164ca0b92df3d2a8 and fixed in 5.15.174 with commit f502a88fdd415647a1f2dc45fac71b9c522a052b Issue introduced in 4.18 with commit 3b2dec2603d5b06ad3af71c1164ca0b92df3d2a8 and fixed in 6.1.120 with commit 0cf598548a6c36d90681d53c6b77d52363f2f295 Issue introduced in 4.18 with commit 3b2dec2603d5b06ad3af71c1164ca0b92df3d2a8 and fixed in 6.6.66 with commit 673d606683ac70bc074ca6676b938bff18635226 Issue introduced in 4.18 with commit 3b2dec2603d5b06ad3af71c1164ca0b92df3d2a8 and fixed in 6.12.5 with commit 6f0ae06a234a78ae137064f2c89135ac078a00eb Issue introduced in 4.18 with commit 3b2dec2603d5b06ad3af71c1164ca0b92df3d2a8 and fixed in 6.13-rc2 with commit 2c7f14ed9c19ec0f149479d1c2842ec1f9bf76d7 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-56640 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: net/smc/af_smc.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/f502a88fdd415647a1f2dc45fac71b9c522a052b https://git.kernel.org/stable/c/0cf598548a6c36d90681d53c6b77d52363f2f295 https://git.kernel.org/stable/c/673d606683ac70bc074ca6676b938bff18635226 https://git.kernel.org/stable/c/6f0ae06a234a78ae137064f2c89135ac078a00eb https://git.kernel.org/stable/c/2c7f14ed9c19ec0f149479d1c2842ec1f9bf76d7