From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f46.google.com (mail-dl1-f46.google.com [74.125.82.46]) (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 4C1C23A1E7E for ; Fri, 26 Jun 2026 05:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782451094; cv=none; b=fvPK2kP6qqH/40xHPGEQ08fy6uZ70TxAGqiktgCgce1l6YaCYmqSwCiuieeFu58N9h6cwSLt2biRz/wGWJFO4reucBiWypSVcYCyyEaNY0/poXBSz8h1aToC7h9DFKv3pN7NPhl59FP6ltGjdu0vCDokpSYuV0PF1r3phROMV8U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782451094; c=relaxed/simple; bh=oI305MqoOf4OcBFfWfvo2q/rW61nNlADLsX9gv75Y20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JDJaDTxdhcUoTckXLw/I8yx/OZIBQEb6SZJ9i/nw84/FDS7RWSML6dWr3c4GhgSdYaSbPIhakRIk8+9HqB38lg3VTq8nEeGLuFNvULCt1SczZqMyEihvkC2np+gKHCuVP9t3D0LZCH1cS3qTMpG8NroIoWTO20WTe4d/vHRS2J8= 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=rg5epz9C; arc=none smtp.client-ip=74.125.82.46 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="rg5epz9C" Received: by mail-dl1-f46.google.com with SMTP id a92af1059eb24-139a71baa35so1954339c88.0 for ; Thu, 25 Jun 2026 22:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782451092; x=1783055892; 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=D9f5K0F89CIVZXgY481pC2XHEuVEtLfkjz9FoRFy/os=; b=rg5epz9ClOHBKynSxajNKm8CtwuG9za0SM4YheYjsiHpY94kFPBOb7q96mQMl28Tdg yFcln44B5px8dKDFKF9eBhPiwazL6xlzcY/HzZQ+62tEtO+AMDdG7Omv7q5O0EO4Lg8a 3+LATSJC+CLg7eebTwp43fkeeOw5cKX2BxWcq7K4izKzbyz8Lnvtkglw+iOsWaCMfjyi /w/KoFwlYA5dH1MlvOdLKmIBqNZwbla6twUKaHy8pLzYEPQSh7A4GNUwkFLuZYDMI9pd R9vi4gCKpX2Pd5KTHtEq5bdQdwVzeSNoe/4Qg2xvdoDgNPuvrXCXhbDD4aMCfB/uFWbp PHrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782451092; x=1783055892; 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=D9f5K0F89CIVZXgY481pC2XHEuVEtLfkjz9FoRFy/os=; b=MSGWWRXVyAnoZsGlII0J4MlhVLo4tIIJfeMlUOVzcBiwUbAEzaWxcm6soIiGSyQLzj AeTrQsmQi3ImeoDiywdIyFeCLHwePtcZjObLQBqQD1MOjE30WzTvKfyESKTUi2RHlX9B Q28luPewb4F8nI6st6wQQdVZrA+RDsqlSWxM4EwG91GE/mEvuWlq1k3elRs/iPk3NJNV Dbi2qlO0Epka7J7qYY0mseIYe1eX9htLu5ISQ8V2aRVbtSibos1BOdBxHMQEMXBKShWV HlYfMaVzijw1bFdWz4vBaWiwcdd8XR7faHWJhnS+VTwuVZWS7MrqMRerp5+jaVNkZrm1 MB6Q== X-Forwarded-Encrypted: i=1; AHgh+Ro6+sJK08oYCJB/eojUZePsPx3Sm9acviOgULox2XE39FdF/Cm8GS6CcU+Dpi04Igx/95I+Ja0rUGFyAg4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyp/nilMk8yWU6bVfB1OX0AJdgi9LJ1y0av3iPJP3CfGJnBCaEB AY9JdUoHfc3Kj7hx+Xxs5MeY4GWrPN0hyRlc++q7iWW9E8PwIcKy3c6tJDAxSQ== X-Gm-Gg: AfdE7cmm0dYLLUxPHl0PrTxUUH9BxUerZH7J0q5tQYd8Tp58ohIGkmdWPcdBw3YozKt tZCbJ294+WP41PDkJTiJ5i+vqigskBYyaNG8DgblcskU7wzsOlCbWHTsdAxvwgP/HMuiXZ9Wjdw pwad1sOstCeKjoCFuv+f7bXQtJOBME1Zs2vQAIVGQVjmEIhnKuRGYbiJUw5udPKLEsok6HcHplu Oj1znK6bEKjBB+TvV9e1TpF+IopMNutyCkEOtCtF1i4et9vBJxrxhwYMj9E5viL0mSUCXwnMfl9 aacqof3Aro9jWuICdrk9naKP479UG67qws32P+w/giEKo1pbYsa932/VMM+V+T7qO57xqu081h0 9AxaL+tAQgQC4UEHr43N8BORUb4L0jKtjXHbg3t0znOW7CWTX2poMytNjck3mdRXvGegBlTPbWX 0QpSbeZ9QtO7seh8wWNB1gktOIeRxKa+N3l/0vGKwnFhpJjocBfAb8Mu8XJOwq8PIZeAqungW3+ wFp X-Received: by 2002:a05:7300:7fac:b0:304:2176:a871 with SMTP id 5a478bee46e88-30c84a265a1mr5890749eec.0.1782451092285; Thu, 25 Jun 2026 22:18:12 -0700 (PDT) Received: from dtor-ws.sjc.corp.google.com ([2a00:79e0:2ebe:8:a474:bf4a:4966:8d97]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30c7c9e9214sm14804188eec.20.2026.06.25.22.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jun 2026 22:18:11 -0700 (PDT) From: Dmitry Torokhov To: Bryam Vargas , Hans Verkuil Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH 05/10] Input: synaptics-rmi4 - block s_input when F54 queue is busy Date: Thu, 25 Jun 2026 22:17:54 -0700 Message-ID: <20260626051802.4033172-5-dmitry.torokhov@gmail.com> X-Mailer: git-send-email 2.55.0.rc0.799.gd6f94ed593-goog In-Reply-To: <20260626051802.4033172-1-dmitry.torokhov@gmail.com> References: <20260626051802.4033172-1-dmitry.torokhov@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 Changing the input (diagnostic report type) mid-stream changes the report size. Since V4L2 buffers are allocated based on the size at stream start, changing the input while streaming could lead to a heap buffer overflow if the new size is larger than the allocated buffers. Prevent this by blocking VIDIOC_S_INPUT with -EBUSY if the V4L2 queue is busy (streaming). Fixes: 3a762dbd5347 ("[media] Input: synaptics-rmi4 - add support for F54 diagnostics") Cc: stable@vger.kernel.org Assisted-by: Antigravity:gemini-3.5-flash Signed-off-by: Dmitry Torokhov --- drivers/input/rmi4/rmi_f54.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c index aebe74d2032c..e86dfc9ce7d9 100644 --- a/drivers/input/rmi4/rmi_f54.c +++ b/drivers/input/rmi4/rmi_f54.c @@ -445,7 +445,12 @@ static int rmi_f54_set_input(struct f54_data *f54, unsigned int i) static int rmi_f54_vidioc_s_input(struct file *file, void *priv, unsigned int i) { - return rmi_f54_set_input(video_drvdata(file), i); + struct f54_data *f54 = video_drvdata(file); + + if (vb2_is_busy(&f54->queue)) + return -EBUSY; + + return rmi_f54_set_input(f54, i); } static int rmi_f54_vidioc_g_input(struct file *file, void *priv, -- 2.55.0.rc0.799.gd6f94ed593-goog