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 6AC47155C82 for ; Wed, 16 Apr 2025 14:17:59 +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=1744813079; cv=none; b=RA1cBHdR4LBnsqixtB3HG6MzG/wNNWIcOEkZzXPAySIMGXBgR7qyoYVvUko3wPY8XigVxlWSt446gvuPEgqAA/8c9qsWUoyAmteNxZM4BZyDU+14uSGKyyBwUG900W+KkGNpCHxZIyqmvTwGJFQElzzk8/mVwPR26ySUcJAO4C0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744813079; c=relaxed/simple; bh=96hMRFWVJb9aOfOVMnbf4qjSzfU5deVvv4Tlfck0TSo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mXX3FrKbYmOJx+CK5wKVzO+a65WO/0fQ2WkBh1nLAn82/rQAi5Rj92KAHAIywuTkgAK81E6UGkE7XgnnHbHYne9oQ/RpOa5JG56Y8ybzoaRas3reoc1WjR9QYhJIpN1DW2FYDnWG+eKGSCYIingZVNZAmEmkPa6KabEebGLBdGc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qTb2M5qP; 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="qTb2M5qP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF34C4CEE2; Wed, 16 Apr 2025 14:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744813079; bh=96hMRFWVJb9aOfOVMnbf4qjSzfU5deVvv4Tlfck0TSo=; h=From:To:Cc:Subject:Date:Reply-to:From; b=qTb2M5qPelefX6pZBuz1eRjuODMuHAFVBcEEKzXlMx2tKNgHev5wCpgFZC08KSv3y //4BWYgcp6bzis0l08+JpuJbPH4+5lH009fqBDOQc+xdCtM2Nu01VzjC5BPHkup1qa w0xALKuoPWeUarJdawJF7XLHsHBDdpvptobQTNdA= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-22111: net: Remove RTNL dance for SIOCBRADDIF and SIOCBRDELIF. Date: Wed, 16 Apr 2025 16:13:22 +0200 Message-ID: <2025041624-CVE-2025-22111-8bec@gregkh> X-Mailer: git-send-email 2.49.0 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=5521; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=96hMRFWVJb9aOfOVMnbf4qjSzfU5deVvv4Tlfck0TSo=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn/d514eu7r1GJdn6XZZz8JXyn+2XdYiyN131PH0IM+1 yf9mLVoZUcsC4MgE4OsmCLLl208R/dXHFL0MrQ9DTOHlQlkCAMXpwBMJDiTYcHZuPTlu2+9Zt9+ +OZkHavtzLarYpUZ5lnnX5HqsldKWD1fyrdYLlUp7PCHCwA= 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: Remove RTNL dance for SIOCBRADDIF and SIOCBRDELIF. SIOCBRDELIF is passed to dev_ioctl() first and later forwarded to br_ioctl_call(), which causes unnecessary RTNL dance and the splat below [0] under RTNL pressure. Let's say Thread A is trying to detach a device from a bridge and Thread B is trying to remove the bridge. In dev_ioctl(), Thread A bumps the bridge device's refcnt by netdev_hold() and releases RTNL because the following br_ioctl_call() also re-acquires RTNL. In the race window, Thread B could acquire RTNL and try to remove the bridge device. Then, rtnl_unlock() by Thread B will release RTNL and wait for netdev_put() by Thread A. Thread A, however, must hold RTNL after the unlock in dev_ifsioc(), which may take long under RTNL pressure, resulting in the splat by Thread B. Thread A (SIOCBRDELIF) Thread B (SIOCBRDELBR) ---------------------- ---------------------- sock_ioctl sock_ioctl `- sock_do_ioctl `- br_ioctl_call `- dev_ioctl `- br_ioctl_stub |- rtnl_lock | |- dev_ifsioc ' ' |- dev = __dev_get_by_name(...) |- netdev_hold(dev, ...) . / |- rtnl_unlock ------. | | |- br_ioctl_call `---> |- rtnl_lock Race | | `- br_ioctl_stub |- br_del_bridge Window | | | |- dev = __dev_get_by_name(...) | | | May take long | `- br_dev_delete(dev, ...) | | | under RTNL pressure | `- unregister_netdevice_queue(dev, ...) | | | | `- rtnl_unlock \ | |- rtnl_lock <-' `- netdev_run_todo | |- ... `- netdev_run_todo | `- rtnl_unlock |- __rtnl_unlock | |- netdev_wait_allrefs_any |- netdev_put(dev, ...) <----------------' Wait refcnt decrement and log splat below To avoid blocking SIOCBRDELBR unnecessarily, let's not call dev_ioctl() for SIOCBRADDIF and SIOCBRDELIF. In the dev_ioctl() path, we do the following: 1. Copy struct ifreq by get_user_ifreq in sock_do_ioctl() 2. Check CAP_NET_ADMIN in dev_ioctl() 3. Call dev_load() in dev_ioctl() 4. Fetch the master dev from ifr.ifr_name in dev_ifsioc() 3. can be done by request_module() in br_ioctl_call(), so we move 1., 2., and 4. to br_ioctl_stub(). Note that 2. is also checked later in add_del_if(), but it's better performed before RTNL. SIOCBRADDIF and SIOCBRDELIF have been processed in dev_ioctl() since the pre-git era, and there seems to be no specific reason to process them there. [0]: unregister_netdevice: waiting for wpan3 to become free. Usage count = 2 ref_tracker: wpan3@ffff8880662d8608 has 1/1 users at __netdev_tracker_alloc include/linux/netdevice.h:4282 [inline] netdev_hold include/linux/netdevice.h:4311 [inline] dev_ifsioc+0xc6a/0x1160 net/core/dev_ioctl.c:624 dev_ioctl+0x255/0x10c0 net/core/dev_ioctl.c:826 sock_do_ioctl+0x1ca/0x260 net/socket.c:1213 sock_ioctl+0x23a/0x6c0 net/socket.c:1318 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:906 [inline] __se_sys_ioctl fs/ioctl.c:892 [inline] __x64_sys_ioctl+0x1a4/0x210 fs/ioctl.c:892 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xcb/0x250 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f The Linux kernel CVE team has assigned CVE-2025-22111 to this issue. Affected and fixed versions =========================== Issue introduced in 5.15 with commit 893b195875340cb44b54c9db99e708145f1210e8 and fixed in 6.14.2 with commit 00fe0ac64efd1f5373b3dd9f1f84b19235371e39 Issue introduced in 5.15 with commit 893b195875340cb44b54c9db99e708145f1210e8 and fixed in 6.15-rc1 with commit ed3ba9b6e280e14cc3148c1b226ba453f02fa76c 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-2025-22111 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: include/linux/if_bridge.h net/bridge/br_ioctl.c net/bridge/br_private.h net/core/dev_ioctl.c net/socket.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/00fe0ac64efd1f5373b3dd9f1f84b19235371e39 https://git.kernel.org/stable/c/ed3ba9b6e280e14cc3148c1b226ba453f02fa76c