From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f51.google.com (mail-dl1-f51.google.com [74.125.82.51]) (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 5832F31AF3B for ; Fri, 26 Jun 2026 05:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782451178; cv=none; b=Wplome0WYXweQBORma8BICKq0zFF33/rSNTybvYS9/KtIA9FXJv6QvDhyEkEXyTOn/flGUIEpPNuFMwZ1cm4BvDdwnGRAgguMuNT4nQ6Cgka9hDQOj/l1DYCUycIwSDECrVYYV7ovbn6MjHuws4Jj9QdJwPOdm9PuwoAD2lhINU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782451178; c=relaxed/simple; bh=fjX+6PKZbEGQe4zBIUeSRPpDgQhExGE8q44AIsr7eSs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QlEOHIgNxINNbxIMmsxdX6LYUirjujnUTHFvlOZtLSzPGkcB3qG7G4txtyh69n1UwR+s2kN0muBn8zN+YhR+DMSLMGlVHiTxfeOBIwA3bsdnwDm/IQwLHzoOmMZQiKhUogjUDmlLFL8DcE8mIuQmc5B0ZaIGGerRicjI3ItUlg8= 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=h+ZhetWp; arc=none smtp.client-ip=74.125.82.51 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="h+ZhetWp" Received: by mail-dl1-f51.google.com with SMTP id a92af1059eb24-137335bc3caso1184896c88.0 for ; Thu, 25 Jun 2026 22:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782451176; x=1783055976; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SdScOQCXOlxsY/yjU2HQjsDMpCPXtWr4gDrycqlxMnk=; b=h+ZhetWpDl1TZYRsC45UdMlrEUQc3k8qKCwsFx10pHY30lL+ZPUUbq+9dBIhsgAz+i mNPOedSY8ekqjC6EDP/AvJ5c73Qb4Dez5Bax8G2nC+o+QWJjocJIIKG6MyU229GxaczI Cv9IRWrq4ND7Nsk4r2saX2kSQviJd2qEX39V/2SKtlgJY8NXqnS1BluBbwmaei7jySBn ReOiKuaDuQ4XmtGRdubOxeF6XFXHHp+gZNW55co42ukzJvjOT5TeeqKjqBXcpKfVGfpD 43o5A0KlefVoD6ehJE3jbJNmrUXOIPk2EXw6VMBDKkGWopCIcUqO4lJo4lSnvV5gcNUY PcDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782451176; x=1783055976; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SdScOQCXOlxsY/yjU2HQjsDMpCPXtWr4gDrycqlxMnk=; b=Y0/KtvUjpE94NwFh1z99UMyAs9UKIFMMFAucbrplX0hcIM7lGzJZh8dSgtIRtfEimo AzgOVlXhTymiCvD/gmDbEkRoo8ZthrljXXzrmS00h7DJKDA5JyJZAgn+YRN4B+qmzym+ hBphNm5rSpCLCbFzzv55pVAXZPNFaqJTcFB+8GXEza+6sDiKJ1vsLNvIKeizwhM9oJPt Xts8QxtA7nKuLi464Rn35Hq0tvDFCZ1Mur7s/eeT2590f2buXt1kk2dYr4LDW4LNZSVU rk+6kJB3x1N6qlTmWK06BljtZV7igm8vOvf8Z/09Ft6mx0Tx/MgCY9FUBZdrz2DHpTy1 2qxA== X-Forwarded-Encrypted: i=1; AHgh+Rr7LUShFyMaE3z8SI9coFJ2XsblxNi8N4AD4F6QLYCrenarivqM+/Dh56j2oHZDXbsPmwQ+fD9Gc8chWhc=@vger.kernel.org X-Gm-Message-State: AOJu0YxmisdT5pCLjL0kXnZX9eaItwP+9X9M0FVkw//dOmjq6hAm9F/H X+PU6mB8v+y1XxdyQ2FYnh70ew/2fijPrdeZLXpjDn0Hp1DGIRFCAmTZ9pqrPw== X-Gm-Gg: AfdE7cnFoY93QbqUoQVVVyuU+vA6cMIVJn/I04cesmEzGMpxHkhsDsslCN1nRck60jJ lXKtGDk8KAhrkd8STDyrGlFbHgCh8nh09EU3Aq3l9VU1IPvayOuLgaAC2nh3SJYcFvS8BlZTWU5 TRR99Im9jPVgxJlRS/VW+mEpfmAiWbKDe3kHOKr7rKi2IoKxq18tRS5nvfd/OpATIm2pFFcjKN/ MsGMb+6MgOrBCx6XbTnoRA+A1bLwK+y94Oq+aNIEZh2d50YyVybAS8k93CrJxMBputV3I7i2Ko9 sBfLT9ljeWP5J3x7yPR/wK1o1Bzr6K576NZUl9Cs3Ri7bTHYbv0sG7v2tdzqbM0Ac7oGF5bZzW1 fpcdFl8M7++fxDxQGkQaTLJpObq7TFX0IbgOdn/kz2DZqz0AvekNwMmsGESsi5AWJeaK3QsCssu iNyKsfDTL0b01EH4NnaXij0h/o3zYa09xgpQH/r7yOEZAJepuiOZIgsg== X-Received: by 2002:a05:7300:2322:b0:30b:f6cd:fdca with SMTP id 5a478bee46e88-30c84f408d0mr6617805eec.17.1782451176472; Thu, 25 Jun 2026 22:19:36 -0700 (PDT) Received: from google.com ([2a00:79e0:2ebe:8:a474:bf4a:4966:8d97]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c7c4ca240sm14343168eec.4.2026.06.25.22.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2026 22:19:34 -0700 (PDT) Date: Thu, 25 Jun 2026 22:19:32 -0700 From: Dmitry Torokhov To: hexlabsecurity@proton.me Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , Benjamin Tissoires Subject: Re: [PATCH] Input: synaptics-rmi4 - bound the F54 report size to the allocated buffer Message-ID: References: <20260613-b4-disp-6721686c-v1-1-4d5bb84ee520@proton.me> 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-Disposition: inline In-Reply-To: <20260613-b4-disp-6721686c-v1-1-4d5bb84ee520@proton.me> Hi Bryam, On Sat, Jun 13, 2026 at 11:01:16PM -0500, Bryam Vargas via B4 Relay wrote: > From: Bryam Vargas > > rmi_f54_work() reads a diagnostics report from the device into > f54->report_data, sizing the transfer with rmi_f54_get_report_size(): > > report_size = rmi_f54_get_report_size(f54); > ... > for (i = 0; i < report_size; i += F54_REPORT_DATA_SIZE) { > int size = min(F54_REPORT_DATA_SIZE, report_size - i); > ... > rmi_read_block(.., f54->report_data + i, size); > } > > report_data is allocated once at probe from F54's own electrode counts > (array3_size(f54->num_tx_electrodes, f54->num_rx_electrodes, sizeof(u16))), > but rmi_f54_get_report_size() computes the size from > drv_data->num_*_electrodes when those are set, i.e. from the F55 > function's electrode counts. Both counts come straight from device > queries (F54 and F55 each report up to 255 electrodes) and nothing > constrains the F55 counts to the F54 ones. > > A malicious or malfunctioning RMI4 device that reports larger F55 > electrode counts than its F54 counts makes report_size exceed the > allocation, so the read loop writes past report_data (and the V4L2 > dequeue memcpy() then reads past it). On conforming hardware the F55 > configured electrodes are a subset of the F54 physical electrodes, so > report_size never exceeds the buffer and well-behaved devices are > unaffected. > > Record the allocation size and reject a report that does not fit, > mirroring the existing zero-size check. > > Fixes: c762cc68b6a1 ("Input: synaptics-rmi4 - propagate correct number of rx and tx electrodes to F54") > Cc: stable@vger.kernel.org > Signed-off-by: Bryam Vargas Thanks for the patch. It makes sense, but there are more changes needed in F54. I incorporated it in the series I just posted, would appreviate if you could review it. Thanks. -- Dmitry