From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) (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 9F94A33B6ED for ; Fri, 9 Jan 2026 10:59:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767956388; cv=none; b=JGMY78y1WougbpLeokZBu9b10ErbVZIqVKTBZYsvI34qDx4+ITXdpC3ePHntAuFGEo3LcekO50udMfSYibHCcWRfgO0pgQSeIpyP1pQ9VUh8EsE23VulMMyfP95jhbXAkyGgxK3Q2HxzoR8YaMMgedrsrnhKplnWJD7r1zH5dq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767956388; c=relaxed/simple; bh=aRGZ9qzbchOvsbf2Q4Kz7fpOm3YpF5AuousM35WA2qE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jxYlIWCGQYBoFPUWxR4BH/Dxh1IEK5iNEsAJv1SrcULGeWYHn9JQ6VYGRGJL43juJnqDA8zlf4UT/61Z0J1yzf0u7sllTHSNv1H3eizYzSZ+I4JyWcGp3jYuU3eEemTXhb6FCs9rqwR2Oe3tzd6JfyLX6gNxMEYHmPcBzp0N3UI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--gnoack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=hrZZHUD/; arc=none smtp.client-ip=209.85.221.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--gnoack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="hrZZHUD/" Received: by mail-wr1-f73.google.com with SMTP id ffacd0b85a97d-4325b182e3cso1966684f8f.2 for ; Fri, 09 Jan 2026 02:59:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1767956385; x=1768561185; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:from:to:cc:subject:date:message-id:reply-to; bh=/BeYkiy+yrJYsuxPNsd+qFQLKTrLZTJuUBJuKTSPotM=; b=hrZZHUD/mRo/76m2wjFXl3x9fHMpB2sBmmZcjU/RGUSqzSu43W2j90Jpkgfi0jRLKo 9PVMlm1oSjekeeyRqmUXLgpfXSZyKRjKHBuAfLE90OkuDzheAOLt83bW0f8vEmoL4TgO YqCzPAQRcsMMMAt+L3QUw7dTNpJCA64HX2Ofi54QO88QOfy6wvLVOVGPW77e3So22PWJ hRjtH7WZpb/UtDg+ByeDBW+TeOAbh8iQzgv6Y0t2EQEwibWPupo/fr61MooF1u81E+JV YwDhJ1yMsZk0L9fouP7Ei95StPvGb3Y0Vz7JBI7ojdnUPTyju0vF4gRGid8twBZxxD7V YGKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767956385; x=1768561185; h=content-transfer-encoding:cc:to:from:subject:message-id :mime-version:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=/BeYkiy+yrJYsuxPNsd+qFQLKTrLZTJuUBJuKTSPotM=; b=Udjjo86LNTYfTaC5vTrZjW5CoUUgmahGyV4UIc4YF005h6aL/T2fEpLJcfakpEnt4K M/26BrD3rr7EzQ+d3PUL1otPnmlBMAs6XNBRGV1oU35a/uSYwt5PcSK36XZ7ixKrON+A JNb6z5NZifXdhclF3u0cdMZnub6O1e+O2qop1rYI8VzHIVCxaZb7lNAaqpbX59thQ9BZ ir6veeyMr5WPY1P3+oCies3KtiuVW1LbTcgvlrDKPkvagndEfvJDqzUdYo+Bfiw7K56a tXQxY88SAbh2946GhAV5m925BpTnXbdfIOZMJ2OBQaN+j5OG4RR5AfRtIbU/+OtMhTjC ixRg== X-Forwarded-Encrypted: i=1; AJvYcCUctew9G7CcQM+EW8lqjAYumPwyNwc6gbGsswAApmpj5cR5xL6feTwJk8Jy29VyKbE24VdmIaQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxRlvM8mFRsSq1NsaEupfbxKfc0iVr/WU0uwCoxO8912LYAKw6c Ay6wX8HXopy6xpwAMOVTQ7hOwW6O6fa5hAaRvU4qSjFnSi5j1BEzmvh04ddDp7SWVnk4QPTcmcn G51wMJg== X-Google-Smtp-Source: AGHT+IEU/LfzdhagkXfQaGZDe5g5h6ujSqoTY9VNtMtwT5eRJQAkPQzFbBLfVz9mtXaqRNuODe+khiaU+4c= X-Received: from wrbch8.prod.google.com ([2002:a5d:5d08:0:b0:429:de3f:827d]) (user=gnoack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:40cd:b0:432:84ee:186f with SMTP id ffacd0b85a97d-432c379dc44mr11574766f8f.33.1767956384941; Fri, 09 Jan 2026 02:59:44 -0800 (PST) Date: Fri, 9 Jan 2026 11:59:12 +0100 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260109105912.3141960-2-gnoack@google.com> Subject: [PATCH] HID: logitech-hidpp: Check maxfield in hidpp_get_report_length() From: "=?UTF-8?q?G=C3=BCnther=20Noack?=" To: "=?UTF-8?q?Filipe=20La=C3=ADns?=" , Bastien Nocera , Jiri Kosina , Benjamin Tissoires Cc: "=?UTF-8?q?G=C3=BCnther=20Noack?=" , stable@vger.kernel.org, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Do not crash when a report has no fields. Fake USB gadgets can send their own HID report descriptors and can define r= eport structures without valid fields. This can be used to crash the kernel over= USB. Cc: stable@vger.kernel.org Signed-off-by: G=C3=BCnther Noack --- drivers/hid/hid-logitech-hidpp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hi= dpp.c index 9ced0e4d46ae..919ba9f50292 100644 --- a/drivers/hid/hid-logitech-hidpp.c +++ b/drivers/hid/hid-logitech-hidpp.c @@ -4316,6 +4316,9 @@ static int hidpp_get_report_length(struct hid_device = *hdev, int id) if (!report) return 0; =20 + if (!report->maxfield) + return 0; + return report->field[0]->report_count + 1; } =20 --=20 2.52.0.457.g6b5491de43-goog