Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2212425pxb; Wed, 30 Mar 2022 19:30:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9mjs7rD7dDN7IxamcG+W7X9iV/ERZNVpfYX2OyA0uzWD/cOjVuaonTKC9F/ZD9W1jJGMH X-Received: by 2002:a05:6a00:288c:b0:4fa:8c08:aca9 with SMTP id ch12-20020a056a00288c00b004fa8c08aca9mr2947539pfb.62.1648693817841; Wed, 30 Mar 2022 19:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648693817; cv=none; d=google.com; s=arc-20160816; b=sU1bPwchckzEkuJLUV615Tmvq1/tLfvxTKBJlvwQDruJvPQv1l4zFLPK0rKWFp8dbB CDfQoSRiQtYgmd89LrMzjeYDue9VDp6PsBPKswCpXUdDu48Jzce7vu/grBSktHcxvUck +Sd/trRrc+T0R7AwkLH+TYKdTEkCbmpa4qw6roMDNIWeuClISO+8RPGrcN0hE+SmOqI+ bGqgH6jGKVCvnvTnJnIFYg5kmPIayQQngjsTqFirGyVLRWSI21ZJQcCFTHHuC4AAWKfL SvOMuzouO48Sa2zlP/7yvcpqBS9pvPFcf7BejnWH1FwyaPGr5MOa7Nh+jTrzI0lCUbEj uqsw== 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=11TQYift3OKqi+dVgHjdqwKZOs+zoa8nUQh8obZhJ9M=; b=YIsTCP00LWpEcBQ65W3GL5ajFHQPYw0T+/bpHeo+fAzO9cIC+z0cX3K/Xy5v3v2LeL tV3ZSwqAjX49Jd6TOMG4Cdo1tA19HjEhpOfmXA1vZ7xqrAKnuLCWS+OnM9Gs7PJWG5Oh TvbikpXAz/tqz9uHI8Xm52hOrdR9/Fjfs+nBfEV4t1ZerplMQLui9vwDL39+rY0d0dUH VQ8qpdHrd95sVbCN76GzUO/UTcgWJHcNFbZBHXLC5SYvMo3qQplqmsf8SoolPVKyLBeA NA37tn5qiyYCTdJjBDgY24cApmOZ7cXYyMWJyjigQPRFHNVLXmlWympEXg3CZNEbTKB6 XopA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lzxyshau; 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 j1-20020a632301000000b003816cefccacsi22644705pgj.22.2022.03.30.19.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 19:30:17 -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=lzxyshau; 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 3E4A26C93E; Wed, 30 Mar 2022 19:28:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344604AbiC3MBK (ORCPT + 99 others); Wed, 30 Mar 2022 08:01:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344768AbiC3Lxd (ORCPT ); Wed, 30 Mar 2022 07:53:33 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA21126C2D8; Wed, 30 Mar 2022 04:49:36 -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 A30C2B81C25; Wed, 30 Mar 2022 11:49:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83FA5C340EE; Wed, 30 Mar 2022 11:49:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640969; bh=14VW2dm/D52DxBIO4T4GRlDqW5MH7hZuDbtQnnwcWvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lzxyshauhoRBosIVvy8ymINBe2ZatLmS2cFjJqGCdOb4MK4QiG2elwkTuHBAuDfxQ 3uHErzNwNg+hiFx7zM7SVRIi9cY0EW6pZDw8AyWPijpts9QqwbdLZA/j2FB91V1lQu YD9/xoufT/Y0NP7fdfJzGyATMXBakcM2pEagaTN2tPfMEKVHypEMVH29HV6LUcibQe /A8/O8qlPFE1hfEK9j34M/BDIRW/4KJzAVczGLi+e4kRWlQcGlHta05pGdxo4lUiJD +drZilpN/gwMZYNeRQQA3uhTAjYh0SCXBtZpDLNDx70V3EbnH25oe/iXIJ2OIyHBT/ sKyTLuv6siwZQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ming Qian , Mirela Rabulea , Hans Verkuil , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 37/59] media: imx-jpeg: fix a bug of accessing array out of bounds Date: Wed, 30 Mar 2022 07:48:09 -0400 Message-Id: <20220330114831.1670235-37-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: Ming Qian [ Upstream commit 97558d170a1236280407e8d29a7d095d2c2ed554 ] When error occurs in parsing jpeg, the slot isn't acquired yet, it may be the default value MXC_MAX_SLOTS. If the driver access the slot using the incorrect slot number, it will access array out of bounds. The result is the driver will change num_domains, which follows slot_data in struct mxc_jpeg_dev. Then the driver won't detach the pm domain at rmmod, which will lead to kernel panic when trying to insmod again. Signed-off-by: Ming Qian Reviewed-by: Mirela Rabulea Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin --- drivers/media/platform/imx-jpeg/mxc-jpeg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/media/platform/imx-jpeg/mxc-jpeg.c b/drivers/media/platform/imx-jpeg/mxc-jpeg.c index b249c1bbfac8..83a2b4d13bad 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -954,7 +954,6 @@ static void mxc_jpeg_device_run(void *priv) 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); v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); -- 2.34.1