From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 4C9AE30BB8D for ; Mon, 18 May 2026 22:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779144553; cv=none; b=S2Rc9Ze/K/k5YhuabIa81Ull9W1BrMJm+mvLdgO1vF5g9g3h9cXnn9mUp3w+omWF4JdIJAo9WKGvIS51xnWCrt/kYpUYoLvODpGN0vywcDD+7FobttOr+Dw3kedK3hx0Y1UPNFRiLdxWn2/Lv/0DApMOhPiBRi9ipLte0f1fHg8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779144553; c=relaxed/simple; bh=mMlrQ6bBizH57MI7nK3fM4UonsfmfD+vEi22s2zV0e4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PvhZR2TYIWCn+GJG2EU8+/T/hjULjDvJnCH6XL8NqnnxQLJazpGS7GhZ9e1+IulLcfqWM85qDGBy/ewM9K2lkxBNxy0QONHGbQfRrcA4j4GOI08mtMS7YICTJXg9PKssHYhDYDiufcSI1vx6EBHBZypZ9BAw3FRYF20/eJ78bJo= 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=n+Im+Qnt; arc=none smtp.client-ip=209.85.222.180 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="n+Im+Qnt" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-90d1f03238bso378511185a.1 for ; Mon, 18 May 2026 15:49:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779144551; x=1779749351; 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; bh=X2EjJjfxLoRLJmQYcLNUgbMCLVnhmrc0i6pQ7FGOvJY=; b=n+Im+QntvjLb1Lc9xM4XUee6BR57eFly5WM+0lvPN11p1csMfABFZaVx7mRTWLClT5 eRDKTy/0F/w5j3QiG84MCN710N/xxtEMlJPEgSzh0L9QhcAeAQos5KvvBCLgOw+dr+cl HLK25ACXIy0OnhVecunss6TCFaYO1YltcBtKnUiijtm946zOT8d79vh/rdVjGlv7TPA6 S0hDmZcsLGx1hcDjoKKxHDrbUqvPP2aDNUI4wd5MxXLcq8VTT7PIZyKLdBGGNkjF8lte CZSDU5yFjC6hJHHvoVdQgMdvV+kzwlsp6QYq3Cycp5qLg7e29j/t7dm8+ZZkHXsZLoVq vjYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779144551; x=1779749351; 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; bh=X2EjJjfxLoRLJmQYcLNUgbMCLVnhmrc0i6pQ7FGOvJY=; b=qM4wyRKSmf7xHwKt/tRu9t8IlSgXSj+VeF888FougRAul0LGe5/dKg3jhOLUYk1ziW mJGDgq5GIVA/31Zb848+9vl/82xsQQoLFrskOtrHfM4hrcrRlcudwPjTPrwRSo7nOTzT 55jthyrM3LjWt6mX6YPOaoHDmLKzUuYB7FePY/RBG38H8ppWU1Pwy7eWvZxCBzYz3NQ0 YOUvr4Bamy+3/lzCX/uKngKxkzAs3Heq2mq2own3j70IwC/y2JFQEutcDteJRjXx19TC 8EqwfTjOhjnmVP4o2faNQKxdCCJjmZkXJqmL436Ai4Y8O1rqJZpQgopmSiI0Z6RnDTHn rgdw== X-Forwarded-Encrypted: i=1; AFNElJ8A8/OMayReXgFv1acGtd9I2/Ftq30OD0OIFr4KmIvX2FNOwnncNb1ZUNHRNmY+pDkphT6EcgNEOxyJjZg=@vger.kernel.org X-Gm-Message-State: AOJu0YyZU1BHY24E/Wwsmkik9Fr1KInKemNh7UD3UzSNM+Yxs6LBRBWX QdzAZA4iwLns9yeDU/nbNb7JY205kgmvVTYscEbEPfYZGS6ET5nfYiQa X-Gm-Gg: Acq92OG9EY4tspXnoZuTy/q0mfZo4CWHqKP6fDNFJbnPHLckzZ4ff+oAHUaFuVtfjKN wsRNwm+RgdmDTj9N6RBlH6LG8Nd74qFrceyeZAxaU6OeJjlDra0+ganviEGXyHi55spRb1jbUCS ytkaDPNcZ1whMwkZqrJ/wqvbQzS8qm6pVaCih8tVBN4MCz0gD4+IYlTKi9BNFDib4WFwu1m8e4X tL0YEq2pZcRt3ai1WWiBGA5kU94zchD00GkoEI2LEURHH/d/OBopiUaxS8cEHN9s9ZSFyMuGmxV +BoblNCYrg5fJFiSt7Aw9/wbvsVrJXmKWiQWv4wIH3vK+FgmIuyl5a3Pg384JcMxuyF73PkmSiH o6I2JqAQOxucs/LS0jcinC3Uc+TVhN7dKbD4VIF/MO95pZKiGpsHEuZEuRp0bRm6EVm/tn+yBI7 /SfEsVLiIlp3I9sdBx5RrqzX2L9sBd5yTmF3DPjjfeTvAL0zMnv0Qg/irlsbBaHg== X-Received: by 2002:a05:622a:4c8:b0:50f:b61c:ec4c with SMTP id d75a77b69052e-516596ed735mr217243941cf.7.1779144551199; Mon, 18 May 2026 15:49:11 -0700 (PDT) Received: from mango-teamkim.. ([129.170.196.167]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-51645687d30sm154720631cf.4.2026.05.18.15.49.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:49:09 -0700 (PDT) From: pip-izony To: Greg Kroah-Hartman Cc: Seungjin Bae , Kyungtae Kim , Alan Stern , Kees Cook , Dan Carpenter , David Mosberger , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/2] usb: host: max3421: Fix shift-out-of-bounds in max3421_hub_control() Date: Mon, 18 May 2026 18:49:00 -0400 Message-ID: <20260518224901.1887013-1-eeodqql09@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260517190308.1876316-1-eeodqql09@gmail.com> References: <20260517190308.1876316-1-eeodqql09@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 From: Seungjin Bae The `max3421_hub_control()` function handles USB hub class requests to the virtual root hub. In the `default` branches of both the `ClearPortFeature` and `SetPortFeature` switch statements, it modifies `max3421_hcd->port_status` by left shifting 1 by the request's `value` parameter. However, it does not validate whether this shift will exceed the width of `port_status`. So if a malicious userspace task with access to the root hub via /dev/bus/usb/.../001 issues a USBDEVFS_CONTROL ioctl with `wValue` greater than or equal to 32, the left shift operation invokes shift-out-of-bounds undefined behavior. This results in arbitrary bit corruption of `port_status`, including the normally-immutable change bits, which can bypass internal state checks and confuse the hub status. Fix this by rejecting requests whose `value` exceeds the shift width before performing the shift. This issue was found using a KLEE-based symbolic execution tool for kernel drivers that I'm currently developing. Fixes: 2d53139f3162 ("Add support for using a MAX3421E chip as a host driver.") Signed-off-by: Seungjin Bae --- v1 -> v2: Restored a paragraph in the commit message that was truncated. v2 -> v3: No functional changes; reorganized as part of a 2-patch series. v3 -> v4: Document the tool used to find this issue. drivers/usb/host/max3421-hcd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/usb/host/max3421-hcd.c b/drivers/usb/host/max3421-hcd.c index 0e17c988d36a..3d6b351dcb1a 100644 --- a/drivers/usb/host/max3421-hcd.c +++ b/drivers/usb/host/max3421-hcd.c @@ -1694,6 +1694,8 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index, !pdata->vbus_active_level); fallthrough; default: + if (value >= 32) + goto error; max3421_hcd->port_status &= ~(1 << value); } break; @@ -1747,6 +1749,8 @@ max3421_hub_control(struct usb_hcd *hcd, u16 type_req, u16 value, u16 index, max3421_reset_port(hcd); fallthrough; default: + if (value >= 32) + goto error; if ((max3421_hcd->port_status & USB_PORT_STAT_POWER) != 0) max3421_hcd->port_status |= (1 << value); -- 2.43.0