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 7802E224E6 for ; Fri, 23 Feb 2024 14:48:26 +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=1708699706; cv=none; b=djk7+nVM89IjRNvaVJAS4kRjWZLkqVg010urnqOPvwziWym8oA3muWJ8vXHOZqafVh045iOMgMOKDUXcB8VxLKpf3tIrKeEmlAMuX6uVqa8OYgxrfzvkeNDi5YQ6EczkGiPYWkYT5uXKPwHmfD+q7MHjOXHH3ADMjVND+fg4a8E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708699706; c=relaxed/simple; bh=4HXF5N9HsAUftj9WJ6esbxE2n0i81RhGJCouLwhOlJM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=NiUdhHCbdzPJKG7I3zWi+OflJnG+XUJ4iiJKI799f+o4h3FjyVa+j7Ml4t5F4fABS51Civ7pJnOH3v+E/CM3Kuf4EO8xSPV4D58hKzXRHYg4sReeSPhOdDdZZY4E98CsEIPphJySNEoQLif2aIZnYF7euzqTMgA1kBnLbJuin4Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=CxMir0Uc; 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="CxMir0Uc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E1B9C433C7; Fri, 23 Feb 2024 14:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708699706; bh=4HXF5N9HsAUftj9WJ6esbxE2n0i81RhGJCouLwhOlJM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=CxMir0UcTRMC3JaP5jTJgN5UT2ugFHIpEHcAW5H7WEYF0y2pA5li+qYHo1NoAET9t rmhnUO/vESG9OznRDe0KJ+ufSUKgR82owIfsY7SjMjsxzz/7hLZ/ZTdJox9rwoIxuh r+jcI+GtL2trpOmeVKY2PBRQ0YlLZhA2kxVWhEZc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26596: net: dsa: fix netdev_priv() dereference before check on non-DSA netdevice events Date: Fri, 23 Feb 2024 15:47:37 +0100 Message-ID: <2024022337-CVE-2024-26596-57cb@gregkh> X-Mailer: git-send-email 2.43.2 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=3506; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=4HXF5N9HsAUftj9WJ6esbxE2n0i81RhGJCouLwhOlJM=; b=owGbwMvMwCRo6H6F97bub03G02pJDKk3NnCuyv7e+Oj3KWfz92fb91cc/d36PfBHv6DLEu7Qs 1NeP/3P0BHLwiDIxCArpsjyZRvP0f0VhxS9DG1Pw8xhZQIZwsDFKQATiVzGMD+8/OQBySVz5ufv zHLj6zGaLGgweQfD/EwdO71Gk8cM7BsP1U+TsfE9YmyuBQA= 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: dsa: fix netdev_priv() dereference before check on non-DSA netdevice events After the blamed commit, we started doing this dereference for every NETDEV_CHANGEUPPER and NETDEV_PRECHANGEUPPER event in the system. static inline struct dsa_port *dsa_user_to_port(const struct net_device *dev) { struct dsa_user_priv *p = netdev_priv(dev); return p->dp; } Which is obviously bogus, because not all net_devices have a netdev_priv() of type struct dsa_user_priv. But struct dsa_user_priv is fairly small, and p->dp means dereferencing 8 bytes starting with offset 16. Most drivers allocate that much private memory anyway, making our access not fault, and we discard the bogus data quickly afterwards, so this wasn't caught. But the dummy interface is somewhat special in that it calls alloc_netdev() with a priv size of 0. So every netdev_priv() dereference is invalid, and we get this when we emit a NETDEV_PRECHANGEUPPER event with a VLAN as its new upper: $ ip link add dummy1 type dummy $ ip link add link dummy1 name dummy1.100 type vlan id 100 [ 43.309174] ================================================================== [ 43.316456] BUG: KASAN: slab-out-of-bounds in dsa_user_prechangeupper+0x30/0xe8 [ 43.323835] Read of size 8 at addr ffff3f86481d2990 by task ip/374 [ 43.330058] [ 43.342436] Call trace: [ 43.366542] dsa_user_prechangeupper+0x30/0xe8 [ 43.371024] dsa_user_netdevice_event+0xb38/0xee8 [ 43.375768] notifier_call_chain+0xa4/0x210 [ 43.379985] raw_notifier_call_chain+0x24/0x38 [ 43.384464] __netdev_upper_dev_link+0x3ec/0x5d8 [ 43.389120] netdev_upper_dev_link+0x70/0xa8 [ 43.393424] register_vlan_dev+0x1bc/0x310 [ 43.397554] vlan_newlink+0x210/0x248 [ 43.401247] rtnl_newlink+0x9fc/0xe30 [ 43.404942] rtnetlink_rcv_msg+0x378/0x580 Avoid the kernel oops by dereferencing after the type check, as customary. The Linux kernel CVE team has assigned CVE-2024-26596 to this issue. Affected and fixed versions =========================== Issue introduced in 6.1 with commit 4c3f80d22b2e and fixed in 6.7.2 with commit dbd909c20c11 Issue introduced in 6.1 with commit 4c3f80d22b2e and fixed in 6.8-rc1 with commit 844f104790bd Please see https://www.kernel.org or 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-26596 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/dsa/user.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/dbd909c20c11f0d29c0054d41e0d1f668a60e8c8 https://git.kernel.org/stable/c/844f104790bd69c2e4dbb9ee3eba46fde1fcea7b