Received: by 2002:a05:6a10:3150:0:0:0:0 with SMTP id m16csp2136396pxc; Wed, 30 Mar 2022 20:28:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAhqJPeh/WbAnq9BFW6aUagVwJBUdNYaep8DTdd78DltVaTTVrN9mK0prCkVF/dyk6ROZp X-Received: by 2002:a17:90b:4b89:b0:1c8:105a:2262 with SMTP id lr9-20020a17090b4b8900b001c8105a2262mr3630088pjb.225.1648697330252; Wed, 30 Mar 2022 20:28:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648697330; cv=none; d=google.com; s=arc-20160816; b=BDpHj+0BpRjodhdthnVJj4VwOMtizqCBV5A1m0Ss67BTTb6HLNyZNF/co2ZW0m/SAa /tZ19eyGXmWlrHFqK7c5dYN98zf6yXYRs/n8x65ZZj2So607ejQl/ibhK9bZQYCkfnqL IuSjGC0u3u9U4YH8I+QKEphmECSe4pVyln2b84hM5kxVbicoiMUbsr5V2z9p8ITGNE8N mlh2z+BucfqYOQ8jmPtmBnIG+M9MJ+bGUmWq39uQilc2tFUbxuFv4Ip5b/8m3/D0PYGJ PAt3O58rF0GStckk5qNhijHOMap480BnDP8wSYsCwor7iHV11HXENAeyvZnz5JjzFWb3 3HRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HorXMGomBqWQaw4vkFKD5HGCDwnXOaZWPfVzErLmErg=; b=f11Tos1AHK0VYv0EAeC1SALFd9EHTM2P4Vn/7JM2BRpztZjvy5eaRpRV/nsegHxkto z31T0ITrqa+8edLOzDfSqEjg6w8q6qSQWJEzcg41P2wYcgcBHPid68J3ZLeaPiE+WD/A WXpP+0kaiRjarJA0XrDSZgby+gbiWpOtZ/q2KjVDQWmEDcz4BA8joLkDR10iMPgTJNW3 QzrMb9cd58kS/yLYeqgqpA+7DvI1FrIbf3x7pr36cvOirkqd91VBAdEIlLpuV72SXPeX Uq0bJj3nO7bHEUcpUFbJ0mEdRmYV4gJm9rkK/QBixXpHBvOYXkdlNsMHTQleQ58GdHiB 4Vbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TRqqvh47; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e8-20020a17090301c800b00153be5f394esi25507637plh.529.2022.03.30.20.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 20:28:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TRqqvh47; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D1A1311BCC2; Wed, 30 Mar 2022 19:54:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347936AbiC3MIA (ORCPT + 99 others); Wed, 30 Mar 2022 08:08:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344385AbiC3LxF (ORCPT ); Wed, 30 Mar 2022 07:53:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC69261980; Wed, 30 Mar 2022 04:48:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C1239B81C28; Wed, 30 Mar 2022 11:48:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D51E6C36AE2; Wed, 30 Mar 2022 11:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640926; bh=ADEi5SU0fkm1OasEUzfXS5XLxdWFJrLpnS+LEgj9ZRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TRqqvh47KSe9ZurI5qCNfWK8cOnhuLasFuNj+0hJcovf2xvCltj1I5f9ycsnbnJ0C RDjTT7hpz81icI3wKIhYLzIBbY/FyRr7W+wCLJUX8RKSfjrn0Czq6aog08KN8PZ2Cc s3ZywOpZUpW47KssGSWTkIRxo5/nNmLEedEnnHQF70KSwSaGag3V27kbL5zBmwgSoP F4LURRSYlKcapDS+qIG9RbJgNbWAG/a0kxJ6DkzWKZU2YI0l3Vrmg2K9xweER7kKK/ jNC7Q/HB6cpyc2Q7YMeQLqZaJxwJ+nvPDChQi3vwQ22/dw6vWBNH7tyqttniiJZqGP GmBdAan9UPyIw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mirela Rabulea , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 09/59] media: imx-jpeg: Prevent decoding NV12M jpegs into single-planar buffers Date: Wed, 30 Mar 2022 07:47:41 -0400 Message-Id: <20220330114831.1670235-9-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114831.1670235-1-sashal@kernel.org> References: <20220330114831.1670235-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mirela Rabulea [ Upstream commit 417591a766b3c040c346044541ff949c0b2bb7b2 ] If the application queues an NV12M jpeg as output buffer, but then queues a single planar capture buffer, the kernel will crash with "Unable to handle kernel NULL pointer dereference" in mxc_jpeg_addrs, prevent this by finishing the job with error. Signed-off-by: Mirela Rabulea Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c index 4ca96cf9def7..b249c1bbfac8 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -947,6 +947,12 @@ static void mxc_jpeg_device_run(void *priv) v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true); jpeg_src_buf = vb2_to_mxc_buf(&src_buf->vb2_buf); + if (q_data_cap->fmt->colplanes != dst_buf->vb2_buf.num_planes) { + dev_err(dev, "Capture format %s has %d planes, but capture buffer has %d planes\n", + q_data_cap->fmt->name, q_data_cap->fmt->colplanes, + dst_buf->vb2_buf.num_planes); + jpeg_src_buf->jpeg_parse_error = true; + } if (jpeg_src_buf->jpeg_parse_error) { jpeg->slot_data[ctx->slot].used = false; v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); -- 2.34.1