Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 549F649D58F; Thu, 17 Sep 2026 18:53:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671199; cv=none; b=JD1cXB4GmEXh6Jhp3QccGDFM8iaAsOlRLx69ujxrkRLlVILaOoQr3Z3OTKcrnAwMKrK11l6YweSHJpyZ5oP/wbXj7DgF2Dhx6E5Z1Jb0gxAXSkLliaNoxgO1AaJQ0f/XHbitRpk7bbDcGeiMCcdP50IvFpbiFbH97pTXS4P5gS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789671199; c=relaxed/simple; bh=ROeOiBi04EgGZNaM0nuVoN3Y3Qi0X51DgQ1biCINZAQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GRaJoR/8QrAa/h9m7trE/9zY/oJDISq3Z7WGcCuyIMilT53S60QC7eqQgOv17R7rvjAYO9R43wPTmXWMt9onNFl8L8YXzBY+Sdoe6vbPsQqh20tj5Vq5xusITGIHKOT1jOrggInKiQzf353M5ab0MJsWskSklapjXQVjDrEaja8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=taQpoRiU; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="taQpoRiU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB10A1F000FF; Thu, 17 Sep 2026 18:53:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789671198; bh=oT+wNZ2sBV1CwBbtvdbWw7ZK+cWZSY6c/SdEbeGKb4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=taQpoRiUTWSMx3ITjvV73Kd8fbOhKqEa7z3nC0K77ZSHUt7lZA0rjFAHM0DNrNjPU +BoHLl/7dDnjW9qbkxnJsPiH1ttDH2w69iPar8Lnb8POfDksKr1ou4jF14fODu+gBv yQ7oHksIL/4ownSTwWGc8a9Zu+RKs7DHY6uVPJEQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michael Bommarito , Benjamin Gaignard , Hans Verkuil Subject: [PATCH 6.12 0881/1102] media: v4l2-ctrls: validate AV1 tile counts Date: Thu, 17 Sep 2026 16:13:44 +0100 Message-ID: <20260917151602.685875489@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151539.408551884@linuxfoundation.org> References: <20260917151539.408551884@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Bommarito commit 439058ced617fbb3febc017b9e93bb7387f309e0 upstream. The stateless AV1 decoders use tile_info.tile_cols and tile_rows as loop bounds and as indices into the mi_*_starts[] and *_in_sbs_minus_1[] arrays, as the divisor for context_update_tile_id, and their product bounds the per-tile descriptor buffers, but std_validate_compound() does not bound these u8 fields. Reject a V4L2_CTRL_TYPE_AV1_FRAME whose tile_cols or tile_rows exceeds V4L2_AV1_MAX_TILE_COLS / _ROWS, or whose product exceeds V4L2_AV1_MAX_TILE_COUNT. A zero tile count is left to the consuming driver so the zero-initialised control that existing userspace submits is still accepted. Fixes: 9de30f579980 ("media: Add AV1 uAPI") Assisted-by: Claude:claude-opus-4-8 Cc: stable@vger.kernel.org Signed-off-by: Michael Bommarito Reviewed-by: Benjamin Gaignard Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ctrls-core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/drivers/media/v4l2-core/v4l2-ctrls-core.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-core.c @@ -708,10 +708,30 @@ static int validate_av1_film_grain(struc return 0; } +static int validate_av1_tile_info(struct v4l2_av1_tile_info *t) +{ + /* + * tile_cols and tile_rows index the per-tile descriptor arrays and + * bound the tile loops in the stateless AV1 drivers; the product + * bounds the total tile descriptor count. + */ + if (t->tile_cols > V4L2_AV1_MAX_TILE_COLS || + t->tile_rows > V4L2_AV1_MAX_TILE_ROWS) + return -EINVAL; + + if ((u32)t->tile_cols * t->tile_rows > V4L2_AV1_MAX_TILE_COUNT) + return -EINVAL; + + return 0; +} + static int validate_av1_frame(struct v4l2_ctrl_av1_frame *f) { int ret = 0; + ret = validate_av1_tile_info(&f->tile_info); + if (ret) + return ret; ret = validate_av1_quantization(&f->quantization); if (ret) return ret;