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 8D2343624B2; Wed, 8 Apr 2026 18:48:04 +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=1775674084; cv=none; b=ImtkXEobCn1ugacf4OpNVkLHNapq8Zx1DdHWtAqmRkJd9lJiaJ2ulvIH4c07F+KS4D53C17Kw7OkamP1LYe5rtQF1G/DRE+EgZ+6iJICyC3SffxEDCOuiNwPmpbWs3xOpBK2pjmZtv2ayTZGa3jqfTUiMbrQr+z3B5gUq2xxvhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775674084; c=relaxed/simple; bh=M2Onc25iO+4/rV73H0QVcGdmvUkcDFF2oTyS+4cbAzk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kRsq1jpcxjbBCb2/BijDNS5ZDHxwiCaStAMZ1CMsjGnpveyPC6atSc8PoQg8nh2htva0ws+aAaQ+V2NYxHtsOVvIlSAoXIBF8DsAQ+DVNjmt995uux8W2BFp1Mb97MjsL7kG1D+AZAgXCX4NuCs54KvQkJN0Cs3ioL84lOQsCzM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uKzte96o; 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="uKzte96o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 226E2C19425; Wed, 8 Apr 2026 18:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775674084; bh=M2Onc25iO+4/rV73H0QVcGdmvUkcDFF2oTyS+4cbAzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uKzte96ow+lhiL5DCItIIK3vrjFoOFFPlV+G8scBzltUmqxU21Z0Oalo/eVboM7D4 hT1e7AlluKcz6RfnsxAIgMi/mjlqLC3zPSRSmhZVMRLIpXL1orE4rlIzRNSuV/mEZI 1A6MgoNa/ggJBI0A1iyniAl7ymOOdZR7GKEyU3/A= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Val Packett , stable , Kuen-Han Tsai Subject: [PATCH 6.12 202/242] usb: gadget: u_ether: Fix NULL pointer deref in eth_get_drvinfo Date: Wed, 8 Apr 2026 20:04:02 +0200 Message-ID: <20260408175934.641809909@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175927.064985309@linuxfoundation.org> References: <20260408175927.064985309@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org 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: Kuen-Han Tsai commit e002e92e88e12457373ed096b18716d97e7bbb20 upstream. Commit ec35c1969650 ("usb: gadget: f_ncm: Fix net_device lifecycle with device_move") reparents the gadget device to /sys/devices/virtual during unbind, clearing the gadget pointer. If the userspace tool queries on the surviving interface during this detached window, this leads to a NULL pointer dereference. Unable to handle kernel NULL pointer dereference Call trace: eth_get_drvinfo+0x50/0x90 ethtool_get_drvinfo+0x5c/0x1f0 __dev_ethtool+0xaec/0x1fe0 dev_ethtool+0x134/0x2e0 dev_ioctl+0x338/0x560 Add a NULL check for dev->gadget in eth_get_drvinfo(). When detached, skip copying the fw_version and bus_info strings, which is natively handled by ethtool_get_drvinfo for empty strings. Suggested-by: Val Packett Reported-by: Val Packett Closes: https://lore.kernel.org/linux-usb/10890524-cf83-4a71-b879-93e2b2cc1fcc@packett.cool/ Fixes: ec35c1969650 ("usb: gadget: f_ncm: Fix net_device lifecycle with device_move") Cc: stable Signed-off-by: Kuen-Han Tsai Link: https://patch.msgid.link/20260316-eth-null-deref-v1-1-07005f33be85@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/function/u_ether.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/usb/gadget/function/u_ether.c +++ b/drivers/usb/gadget/function/u_ether.c @@ -112,8 +112,10 @@ static void eth_get_drvinfo(struct net_d strscpy(p->driver, "g_ether", sizeof(p->driver)); strscpy(p->version, UETH__VERSION, sizeof(p->version)); - strscpy(p->fw_version, dev->gadget->name, sizeof(p->fw_version)); - strscpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof(p->bus_info)); + if (dev->gadget) { + strscpy(p->fw_version, dev->gadget->name, sizeof(p->fw_version)); + strscpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof(p->bus_info)); + } } /* REVISIT can also support: