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 D30B0477995; Tue, 16 Jun 2026 16:35:30 +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=1781627732; cv=none; b=TOVrq1IkcAtwmawAdR7cr5tQP1Y01jOeL/C+vv4rS6+w+7FdGRcnK+mClZSbWn532ykeM3dQcKroIuuFnGIqQ0+KDzvbqWST9+5pErt0Wd9HLxuVXTYinC+O0L62je6Q+Z8QJRvFE2ZPNEx1k8AJovTkco/LqQvJwX4VAftD8ao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781627732; c=relaxed/simple; bh=Fg+WZPymvot35Nu3P//V2iFALnKjJtUEZBz+iQ2Tcuw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J3PiPAjB3O5c0fMuiRcgZBADnqYuPPL30B/NbaVffqUCfd469LNHi/MpkZipA2ZcyIgz+SqP4KMpmb5OnmaK+FyH1XuNPAeP3yNkjYQaMS608jVvPZ5JdoxJL7DRupl5H4YqifP/cbOOoYYOE3f49iTHf7wffYovOHvo0eIdsEg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IAsVk54s; 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="IAsVk54s" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 939291F000E9; Tue, 16 Jun 2026 16:35:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781627730; bh=t/T1gn9TGkY1DUjXNAJXTbD1BbUmdCHKIE8r9ycXm2k=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IAsVk54s48DaIfp2ezaVxU/YcVcIutQRDBUolrWFcw+dmOu1GpbiLZr6gIF82Kv7/ SoVnhGT8m7c57/au6CT9Xo4jrojxN9CHv8/jS/Ax/jViKVYY6gXMdSnYD9UJ59yL5L ojzvuZ53GgTy84XEb7oaag+xF1g/zBh1wCSNigKI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, ZhaoJinming , Paolo Abeni Subject: [PATCH 6.12 183/261] net: bonding: fix NULL pointer dereference in bond_do_ioctl() Date: Tue, 16 Jun 2026 20:30:21 +0530 Message-ID: <20260616145053.549565645@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145044.869532709@linuxfoundation.org> References: <20260616145044.869532709@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 6.12-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 @@ -4673,11 +4673,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);