From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f52.google.com (mail-qv1-f52.google.com [209.85.219.52]) (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 DD43B2989B5 for ; Sun, 17 May 2026 19:03:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779044631; cv=none; b=ptCdpA6TelLK2M0rF1y6dlcGspWbPwZRFgeL1hQ8LdPREYAwsE6d1bG4Da6T5BBAQGUj47SWzyzPiYuA1q9Xnu4Ybshbbx4KfRBN05GgA+gtPOSotKANmWTZpQyHem2azK/Df8hhV75Q3KKmWtWVlkhO0ryKUoWNlE/Wu31x9PE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779044631; c=relaxed/simple; bh=ziqj0At9EXqQ/gmwi/EcqSa9SrdgZw/ZW8685V4X7Ls=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PNNHcnUhnk5z7xtA97rW7J4fYzj33ZOFCnV2jopARrPvRyJtaVkcsvtLfS5NACGIPIs2EkAkRYjS1f7bmH3heMFyxBfOM7Yna6Kwu2IIfsIg5YbVdqm/E369P9/Cs6fiavz7WM8Zxiq/h9gIZO4xjwhUcMkQ62VB5Tla9KdlMhY= 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=Hoc2xT04; arc=none smtp.client-ip=209.85.219.52 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="Hoc2xT04" Received: by mail-qv1-f52.google.com with SMTP id 6a1803df08f44-8b7105dfb35so24969786d6.3 for ; Sun, 17 May 2026 12:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779044629; x=1779649429; 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=YZN/ui+Ml0Pw2OFTnsTV3BRgvcDhfmwrxLMK2S9Sv/Q=; b=Hoc2xT04OLWwji9TGIJNiVdZs7N/PoUCOZT3r+F6aZjH9o4f+DtUSI5Y/MB92ujbc5 NdxBl1uOpuvuCj0+VDgStEqk+kZxYcOE9rh5UQ405gPb99e2M1Fpw3giLfMlDW61fCgo ake5JgFYXxco5oWdoY4BMDnGc/f1yX3y3HH/EPiPHfvKvumzo734V517Aa6QG2Mr1Z2I CxfSpMrg+TurV9ONOzX7YIcfkn9EHR/Mx/SbZsP8jDZOVzoXswZaLmdhTTPz0qI/MbDZ VMP9xtV0ZRhwwiVLk+Rrj0dKseXGtkrUXEcXyTXe6shjBd7RR0v5gvWVEU9WYQQmnk/I ba9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779044629; x=1779649429; 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=YZN/ui+Ml0Pw2OFTnsTV3BRgvcDhfmwrxLMK2S9Sv/Q=; b=axxx1Pe6GBEG9s41PJtgV9oY0wPudJ6ndh9N4sFepy73lxDAZC2uQIXsdiNZ/ZxlvJ LB7HZFl6Q5cBEGuwLzsyQqp76eBccBHOCJsRNE4oECeewHL3euSpeBomXME5b6vYzaxP 6yA/pOur3e+nrep/O4gTmpHcw+bh/arkD8htXNXqhDxcMkjDpH+RS8ofL6zMGvuhFD1w 6jTN38jNRS2RZo2KWFQR/GeoziteM3N8hO2av1yrIA/z2cuRF6ugsrKlKHqeq+stWcg4 0SqWb41bzgGYIlRqrM2RjmXERZk6qIUPKldJxsv+vCX/VvBs4ehTY3OJwgDpM5xvsf6X mrrQ== X-Forwarded-Encrypted: i=1; AFNElJ+gfb1/DjTDenBnJapU5iTpCJtb92goyRm55d21q2051xuFKvEFxOXQpWenS+95eG82uD1LfLm04lL5jw0=@vger.kernel.org X-Gm-Message-State: AOJu0YzUYvFPD8V3p0YlKk8wigbljS3iTuffYVLSrPoUX7kitZCAOew/ jNpbGS5HgNxyhQZiLbU9ZH+p3xXRyIFi0j9nmuFsFBUwDdjen0BYudibUZ4UOqkU X-Gm-Gg: Acq92OG/x9QrOP9vnthL/p3bhGA35kdKNyQDG4Xur3sf/PqvcbvClm9PEDsxVaP5A0z 4fEDLbTyWlJ9PVcmQToUWO4S4cJAL5dfCh/23pf40W1PkIylJkE6wE8zv2GUWObjLxYgGTkvnkt 8bM5OovP2Sxpy2DLoUq66gNwfhPu+7Uy5lzHKeosPdxd+azbpyWmoSFFUIskV9McHOAvGvfv5fC UUj89F98wQf4cWNOQ65CFa3cPensuOsuBx5zGbi8VL+68Kgq+vExoI7x1HEUGUYIHaaUHmY0Uii ViKrfJy0OSuMfwxHodLHy/KwxJ9wfWz9/1rw1dpBLymtpzQybt5Ai8ZWg3nLpRO9DbZqVXIPz1J bljmaNID/R7bdTrRJve3UQcHm5w5mhDhNfRdrA99caW24n1Tas8S+FnOusDDbL6uhJpzZ29J/uG lB1nm/hnedThq+PIohhLVFDZpzC5WiUSHoTbiOTlJdr3acC/Vov5yPhkc8aSUQEflDdAgBew0= X-Received: by 2002:a05:6214:4519:b0:8ac:b1ad:3a24 with SMTP id 6a1803df08f44-8ca0f6bdb6bmr206516336d6.27.1779044628757; Sun, 17 May 2026 12:03:48 -0700 (PDT) Received: from mango-teamkim.. ([129.170.196.20]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8ca361b8b10sm30473686d6.46.2026.05.17.12.03.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 May 2026 12:03:47 -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 v3 1/2] usb: host: max3421: Fix shift-out-of-bounds in max3421_hub_control() Date: Sun, 17 May 2026 15:03:07 -0400 Message-ID: <20260517190308.1876316-1-eeodqql09@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260517000145.1868817-2-eeodqql09@gmail.com> References: <20260517000145.1868817-2-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. 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. 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