From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A652C44BC94; Tue, 16 Jun 2026 15:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624189; cv=none; b=AjAdnm1w9ckqIHCwQcYF819zb++j82b3mafNjn9FYl1Dl8VaSJGUuWR4b0nx9FcOmpFkjfL58l7KMrs+KMbHTU5z4ILgzYMMGyLdaKHnbgMmJS1/89SxITaxGIZCoWnKKBPxU0BSN/j34wLZrPYzPHQ/HJfCLimCoPdlYuL+ydI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624189; c=relaxed/simple; bh=4L2Ddj8ahQfV383xng7AWjOwfoO0wrVCRM0u+vxqJ9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BfdwOsTX+IViPvcjX6I835SXLpxLv3Ks5h8vn6ZamdEN9ryUhKGqKEzWiynjOJ12Yy/L6akelXX64rb0Bm15r8KP2C6CjDwRI8stTFKwJC5pNhuqiq3JPO4O7APzGeXGFPUobg3B00AZZEvsZFuUGg1RghRk4jEexjIY3TmgEdg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bZf1OkJQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="bZf1OkJQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60B981F000E9; Tue, 16 Jun 2026 15:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781624188; bh=z3zG0kiWKZ26c/7M4gTfsFbzn8YaysA32OO+zEGtXac=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bZf1OkJQbUsoubos/yo6tLv8QnT6ePQITlHkL3KZyhXxQ59jEy4nkLRrsuTngwbWW uGj+AOFPMktUuNeCHYY+97oREHy3JatogSY9CmKcfCZ0LUiXwfkGgiaDb5xD4SBQ2C wCD/6OnGCDQIpKVuUbERBzmGErcc7gfvKG8ZBQwU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ZhaoJinming , Paolo Abeni Subject: [PATCH 7.0 289/378] net: bonding: fix NULL pointer dereference in bond_do_ioctl() Date: Tue, 16 Jun 2026 20:28:40 +0530 Message-ID: <20260616145125.292309133@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145109.744539446@linuxfoundation.org> References: <20260616145109.744539446@linuxfoundation.org> User-Agent: quilt/0.69 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 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: ZhaoJinming commit a764b0e8317a863006e05732e1aefe821b9d8c2d upstream. In bond_do_ioctl(), slave_dev is obtained via __dev_get_by_name() which can return NULL if the requested interface name does not exist. However, the subsequent slave_dbg() call is placed before the NULL check: slave_dev = __dev_get_by_name(net, ifr->ifr_slave); slave_dbg(bond_dev, slave_dev, "slave_dev=%p:\n", slave_dev); //here if (!slave_dev) return -ENODEV; The slave_dbg() macro expands to netdev_dbg(bond_dev, "(slave %s): " fmt, (slave_dev)->name, ...) which unconditionally dereferences slave_dev->name before the NULL check is performed. This results in a NULL pointer dereference kernel oops when a user calls bonding ioctl (e.g. SIOCBONDENSLAVE, SIOCBONDRELEASE, etc.) with a non-existent slave interface name. This is reachable from userspace via the bonding ioctl interface with CAP_NET_ADMIN capability, making it a potential local denial-of-service vector. Fix by moving the slave_dbg() call after the NULL check. Fixes: e2a7420df2e0 ("bonding/main: convert to using slave printk macros") Cc: stable@vger.kernel.org # v5.2+ Signed-off-by: ZhaoJinming Link: https://patch.msgid.link/20260601085649.4029067-1-zhaojinming@uniontech.com Signed-off-by: Paolo Abeni Signed-off-by: Greg Kroah-Hartman --- drivers/net/bonding/bond_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -4623,11 +4623,11 @@ static int bond_do_ioctl(struct net_devi slave_dev = __dev_get_by_name(net, ifr->ifr_slave); - slave_dbg(bond_dev, slave_dev, "slave_dev=%p:\n", slave_dev); - if (!slave_dev) return -ENODEV; + slave_dbg(bond_dev, slave_dev, "slave_dev=%p:\n", slave_dev); + switch (cmd) { case SIOCBONDENSLAVE: res = bond_enslave(bond_dev, slave_dev, NULL);