From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 512301F5847 for ; Tue, 5 May 2026 20:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011503; cv=none; b=cJNdYBJtiyO67k44NfZZ8YWaH7+VuQPQ2bESiKFKCCiv9AIR5+YqJzwOxxyoZNXDAswFarqJcDaR9vTcj7GQtk3jXK3dmxIUSF99nf0a2OILB+jM+ywTt+7XTTj7nfTcEfbRKTRIJwTX+OHC3BUObOArNvWVAU/e5CPhnmnCpe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778011503; c=relaxed/simple; bh=HHvtoY5jW5dAPrHiQl1OyWaN9qY30BBJDVffTAyTbwE=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cl/kbcocqaH7hwmohgkvvxSf5hFgvbNNV2zLP3mum95Ev/OsJdV8QpbqdcWroqcn9i4Jr0OH08/AC5zuw+jL99As6zlQPAVvYd+6b/ruOiBXYTnOi5pbg9ulCiC6cWpHM2Osk4idA6g9XRVZ+0Wv62CcBZfHFPOA45MU6Q5wEEQ= 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=N0zz8Kky; arc=none smtp.client-ip=209.85.128.44 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="N0zz8Kky" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-48896199cbaso49556555e9.1 for ; Tue, 05 May 2026 13:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778011497; x=1778616297; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=aj6rzIVcAlG5m5OPFy2pyvos/5GpWy0+8buHD+CQTvo=; b=N0zz8KkyUhqqizIB7bFJqGwOuncCXWba/gmwqWCVDpQcs5IX9TNs0CXaJkWKS4daeT o4CNiRvQU9yDAcucbGCvlHXww9SVKKTx9hnei0LNMmpzEadAv/emNKPfmsy8YwrFlBNw 35I0gB75gb+blR9vDXnNMsV3iFq7VpjCRAcXJl8UF5uAE/dkEjPFyXEbhXBPeBaKvBZU 2w5ms5Mbdheg/hvTJONsAmuSZfshm/Lx7nJyCjK8IKv+UCJpeIJNcOFPh9mWp+AvCWxT 3zZpwVAV0iyTs/ySFRtknuj5A6Tpb/dJFrxEcRFpmpQNQDpgGUr/eK6C3ONA9e9lZ2M1 fyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778011497; x=1778616297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=aj6rzIVcAlG5m5OPFy2pyvos/5GpWy0+8buHD+CQTvo=; b=EAHwcqMkezY6psw2MBk+h5XdqFwKT1DGV0m6gh3Uf2VqqGg0qBP+wlmmsVspr5A+tH KOm0g+aW8OplYaqOtLwU4SJ8WXtDkOZYbqoew1F0plUjoGBbDSjb0QLGlLUaH8XdLl3J 13+2ulJ3Z+wNmh0pob0IsCkj3EhTNsp0eaQTRgamXgT8pty9fjCcoH7UgmAG0SBdpr3g 2E5fD1JrG0TUC7Dv1CithyV1ETn+SYelJ03x19k4C5ni6HHE6dq/tU/rVGkv0tPYcr5O yEIYnLc30edpFpOSP++ygVZpINSVhIyvEePbuirvNHoaZE/6ICX4LZi9hxhzNKgGYTZE 0ZDA== X-Forwarded-Encrypted: i=1; AFNElJ+tbukYxEoNek7fs6/y4FEw6ODb4zn95KhoPV1ohCv0LkHvdgKEo71swic4rq7CJAlDiLxobNS5FHcYX7c=@vger.kernel.org X-Gm-Message-State: AOJu0Yz7x66shTqw5uC25sCl4xo2f1YdqY2Q5ywv+HlGeaqj6wlmrl9B BSHiUeptiZOVLtoqhO0Mm675mt35VVfuIPO8tvhxUOqgSxdotffrs5a9 X-Gm-Gg: AeBDiesTj+3oxtz4l5cjSrknx7Zvv1w2qHDabyoBTheuhl4F5SZMFVzwFpUJaIaQ7Gp H3pf+p+JKPcCiax1v14QkYTggGZvCvFWYvG5GBZkMjJ7wA51CuCzdyxhcbgsFBdtCLYgkMv2fRH CNZEUyC+mmyDSLDjuk/lvjaFkfPQmup9XsQTyASZbWTRN+PQ18pvM5Sa7A/XTGmm7J3LfFKejJh kSYyXmurP5G2S3cbxlmd8RlxfAxxZU7f1e/V2i8gNZuHt/HE8lMbh3aOmCgAQUNLNwN69hAXQ4j sVDHhanrArmlRtA4J+hhiKfeHitGyKK+hSZlFZmUAe+oF76iYah8+kxpc5jRKE8jU1S0NwKS67b RU+YlL7zy6pV9fcsW03YWOb/RENE+SfUrBzoQkxnQnNRz3qThZdSXGyDRJ58fSLrRA/e4DAjbCZ S8lglJHwhclp6Yi7mXaQvn+pnFHObDKX/sjB3C0XA3v+YtGg== X-Received: by 2002:a05:600c:8485:b0:489:1f3e:5f6f with SMTP id 5b1f17b1804b1-48e51f327f0mr10779025e9.12.1778011497382; Tue, 05 May 2026 13:04:57 -0700 (PDT) Received: from foxbook (bgt227.neoplus.adsl.tpnet.pl. [83.28.83.227]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e5288f6absm1049955e9.9.2026.05.05.13.04.56 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 05 May 2026 13:04:57 -0700 (PDT) Date: Tue, 5 May 2026 22:04:52 +0200 From: Michal Pecio To: Alan Stern Cc: Heitor Alves de Siqueira , Greg Kroah-Hartman , Dave Penkler , Johan Hovold , kernel-dev@igalia.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+abbfd103085885cf16a2@syzkaller.appspotmail.com, stable@kernel.org Subject: Re: [PATCH v3 1/2] usb: usbtmc: check URB actual_length for interrupt-IN notifications Message-ID: <20260505220452.214dec73.michal.pecio@gmail.com> In-Reply-To: References: <20260505-usbtmc-iin-size-v3-0-a36113f62db7@igalia.com> <20260505-usbtmc-iin-size-v3-1-a36113f62db7@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Tue, 5 May 2026 15:17:59 -0400, Alan Stern wrote: > > Fix by checking if actual_data contains enough bytes for the headers, > > otherwise resubmit URB to the interrupt endpoint. > > Would it be simpler to solve this by setting the two header bytes to 0 > before submitting the URB? Then if the device did not send enough data, > the header values would be 0, which should prevent any reads from being > out-of-bounds or getting stale data. This amounts to saying that: 1. for 0 byte packets, the default notification type is zero 2. for 1 byte packets, the parameter byte defaults to zero which would result in: 1. a warning (similar to this patch) 2. who knows what, why even worry about such things? ;) If anything, I think the new warning isn't truly necessary and it is misleading, if vendor specific notifications with zero-length bNotify2 field are legal. It would suffice to check actual_length before accepting the particular 2-byte long notification types, and leave shorter packets unhandled, causing the default warning. Another missing bit of pedantry is that these types should only be interpreted this way on bInterfaceProtocol == 1 devices. But as long as there are no other protocols defined (are there?), no valid device is allowed to use them for anything else. Regards, Michal