From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8658E3BCD15 for ; Tue, 11 Aug 2026 16:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464374; cv=none; b=UIOaL5ElhyHloXVQD5FLpNi5/alVm3F/7Z95E/yevbdsawpvs3P/TM2xtEQbUnmZSSAHq/bHW8I+1db8jOuE6lbVcwWjtHuRLsKXnn37sgVygcmEaIBt4DbJVdwLcAlEab4Cqs/Tv3zYRcThA42vd8D1RrEm4PPPGXcXx18PkGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786464374; c=relaxed/simple; bh=blXC5e0KZHk1YHv30PmiEX0Q+MgEcCUalFjtGqEB5yU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GUWAiFoMcYg5L+xgVGj1L/LxL3w/JF5ezXrYDHNCROQOLzDT2zARg1MDBSf9uJc3se6vknnt52mimQbDxhM59mJYaaS/G2LB64HJ3nAg5sd+muCKKQ37K9GVK0swQnwQ0ZwSJGhQ7nf6opJj5BNLLgXf8cfZdhjUsTrJMahQ1xQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EV+Qe4rc; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EV+Qe4rc" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-cbe827e3cb4so3573183a12.3 for ; Tue, 11 Aug 2026 09:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786464372; x=1787069172; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=08+JVCoykFuITQSLu1Wi3ijopmQ1qTW/3NyiDfbt4iM=; b=EV+Qe4rcILY/ggRUkMkfZB53UvLGTBn09zml6P3gMpB2uGCydARTlobuZc4yTvYGmf csCFcokjFnneBg7+/pf7Nm7Jw8TZgAP3KL162lBl2tHrEKq8NbgoUbnSKkPZ1ejMvAeq VfaD9UwgU0tYLgGaZ25L4w0sKIdKFCGDPIfEdB54+Hq+PWuhBMtAM9S1ToHDUfQ8kCNm Tcfeky6/bEgH8n6GkG8w7xAor993TpcSoygLowts8KH/2NS/ePXyA7c+Fn88kT36hy6F PBpvStv2/3PkETHMh5hZ0TpVgJtKgx+3fyCoaVWxFJOl5MgOMVRl5FXKLTlaKFgX09Mm IGdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786464372; x=1787069172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=08+JVCoykFuITQSLu1Wi3ijopmQ1qTW/3NyiDfbt4iM=; b=DF+c+if7GKmBJ5N1sroBKrN8Kz6VwYZJlh8v5jjtLcvGQnWn2dC6HpwIDO9zYsALNH ML1t2hE/RCUs4LyTnPqLDgBh1lT/PIzPgiaR5nvWFQomko7cgtVg+T3JaJBLbD43UOsn gWFSIJ/bpig8Bd4BPS+9QWyUkkI2LuzFjR5hI10ZYdMfTx5nyRoNitTFiCd8Zj0G8IcI Hfclh2RypZ+9CXIiqCddv6sdWDuxRhTQFMGORiDxLKrSnzatBCjGRF/yf2Jsi9siS3tA 2IPBp+IG+I4f4BlVUm2LQ8n/c4V08YsCxbbHzhklL4YTPu28gfUDaLzY9NbCljtyz+7+ kcvQ== X-Forwarded-Encrypted: i=1; AHgh+Rq7mnu2xrW8e674N2DBtV9JXTUM6DaQoy7SvbVYfVnk0xPWaUM4lIWzS9xwioa51jW7PNHui4Q7tfI4WSg=@vger.kernel.org X-Gm-Message-State: AOJu0Yz637Q7SIpnsMcxY2AJhuhPksPiUkg450dusnK4IEscuT1bE62D j/BfSK+y0NOxJL5ZGhp9xEJcqQTrYSxU6W0siv8kfP190n8jFfwf1A85 X-Gm-Gg: AR+sD11cU1CcxPDRxA3OZHNx1KWaSto2tytWz64ZgRWMXuo0S/ANwY5FKEXjpnTjdXV mum647JqLkYIqLiaHuaxFlPEaSUlZCDd1lzkSTWksD/ai+ziLKMlr3xLBGUTKnKtShFidFzDwU2 B1jufDAK6f6nCRv2Jebcy1+377G6MVU2jKzjCxEb4vDlc1CWOQXCbyMf1plBO0rNa3PQVTZD8i9 UCb0jw4oICpOAy9MG9k82Vnv0Z/kz6Ojzfo+7B0ZMH3cASU5KQ715NIPT3ysrqtoA0nts6f7w06 FbH1guvXz5MtJm4qQT8HkYxNbPyDD4yxHSlU1A1WMIhKkLrW9ups4XAXZzbN3qJBTsUNbIqge4J ReFLuI9xRqETGz+QYiPsmTI1h3Fm3AASCJZWgcu9N4hd1wR+yUdKTwTdP0SjRcXFYfcrDS02e80 lk6+LepY/iFHuoUspiIg6X9MNNoxb9ZWhfF8Ju2bNSJseEPocOoDc/3BRMcs53cw2UyQ== X-Received: by 2002:a05:6a21:920d:b0:3bf:ba48:ca88 with SMTP id adf61e73a8af0-3cc2b8df241mr6461260637.15.1786464371694; Tue, 11 Aug 2026 09:06:11 -0700 (PDT) Received: from Default ([2409:40f4:1011:30f7:310c:32cf:5ea7:7043]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-31cf3624c08sm916149eec.5.2026.08.11.09.06.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Aug 2026 09:06:10 -0700 (PDT) From: Jeffin Philip To: valentina.manea.m@gmail.com, shuah@kernel.org, gregkh@linuxfoundation.org Cc: i@zenithal.me, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+af76b01c9a0f0ab60fb0@syzkaller.appspotmail.com, Jeffin Philip Subject: [PATCH v3 1/2] usbip: usbip_host: fix null pointer dereference in rebind_store Date: Tue, 11 Aug 2026 21:35:40 +0530 Message-ID: <20260811160541.29461-2-jeffinphilip14@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260811160541.29461-1-jeffinphilip14@gmail.com> References: <20260811160541.29461-1-jeffinphilip14@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rebind_store drops locks to execute do_rebind which sleeps during which time udev may become NULL due to physical disconnect. Since this cannot be prevented and spinlocks cannot be obtained in do_rebind, we turn towards the function that performs the same action, drivers_probe, safely. Remove rebind_store and print a warning to the user to use drivers_probe instead as a safer alternative. Reported-by: syzbot+af76b01c9a0f0ab60fb0@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=af76b01c9a0f0ab60fb0 Fixes: 4bfb141bc013 ("usbip: usbip_host: fix to hold parent lock for device_attach() calls") Cc: stable@vger.kernel.org Signed-off-by: Jeffin Philip --- Changes in v3: - Addressed the race condition proposed by Greg KH in v2 discussion. Changes in v2: - Addressed concerns raised by the Greg KH in v1 discussion - Added usb_get_dev() to get a reference to udev preventing it from becoming null after the null check. Drop the reference after using it in do_rebind() v1: - Initial patch with a udev null check that returns -ENODEV if udev is null. --- drivers/usb/usbip/stub_main.c | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c index 79110a69d697..013f1563b1e9 100644 --- a/drivers/usb/usbip/stub_main.c +++ b/drivers/usb/usbip/stub_main.c @@ -242,32 +242,7 @@ static void stub_device_rebind(void) static ssize_t rebind_store(struct device_driver *dev, const char *buf, size_t count) { - int ret; - int len; - struct bus_id_priv *bid; - - /* buf length should be less that BUSID_SIZE */ - len = strnlen(buf, BUSID_SIZE); - - if (!(len < BUSID_SIZE)) - return -EINVAL; - - bid = get_busid_priv(buf); - if (!bid) - return -ENODEV; - - /* mark the device for deletion so probe ignores it during rescan */ - bid->status = STUB_BUSID_OTHER; - /* release the busid lock */ - put_busid_priv(bid); - - ret = do_rebind((char *) buf, bid); - if (ret < 0) - return ret; - - /* delete device from busid_table */ - del_match_busid((char *) buf); - + pr_warn("rebind node is deprecated, consider using drivers_probe instead\n"); return count; } -- 2.55.0