Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp876901pxb; Wed, 6 Apr 2022 02:57:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0jeN7mX1J8xUrckz31z9dYexXdSanRgjtwRdwoGaZG35kr83RiUpjAko2cV0Vfbp57FAg X-Received: by 2002:a17:90a:b28c:b0:1ca:a055:12ac with SMTP id c12-20020a17090ab28c00b001caa05512acmr9013815pjr.215.1649239043992; Wed, 06 Apr 2022 02:57:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649239043; cv=none; d=google.com; s=arc-20160816; b=u4DxbGt5o6fZG3eSr/a4CUsPsApa7OTGvN3PI8CHpfbhmztM+Iko8ROR3RDJKPl7wb TJXpWsmC5CnGBvwRkzD8i3lOiESjhyT6A8hks2PNYzRoXKSx4I7HjxVFl91FkxPTIyiG OsSil9PsElQjR1kDVqIXjDtXRQWr2z3N7ra+LZXr7DbfDNPb03/8VPxH+CQZx6L00cB4 lMrWqvKqGM8bFjsC2Ukeu3tUjWrzuYuU0+0XKoJGo9vm5yvxP0PAz+iw6luy7z/KUZbZ DjrS0zPtjJh3oehx9mcGrkag6pMjoXesryZ2amZWM3b9YOhE26MKVNvMj1H5xfYLZJDF 3H/w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=5LmZ18+IYDWcxG9+hs2GviNJpZKL83sGGJoP2wiIydY=; b=FAxJccYFvPm2QZndcf67gPKcN2r50JaJEAf1f8ymAmSFENQmORaPcXlsy63UL8epEU i/o9/COFIbdCsh02DyLjDPqwtUhlwse2KU94qd3DqRfuCB/ImM+uK/X3MTIjcu+Aw+S3 CoU0vPUlYMi5JVay8A7CC9XfNUGTHP1mIAYslS8tnht/+n1XUGjerawT7iSyQj1w+n+p 5NNTzSNb+mY0o53AqJubg/Po861b50AbIxkcWE4PcKnT5dRzxzml+6KqG5kfavB53wex 0T0TK9uSRyBQDtP5Mk5KbTwb94Xnv8n1xW/fiOzaaCPJsgzZBmO5np1/me9c2EqhZ1Aj wM4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MJk6nW7C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h17-20020a056a001a5100b004fa3a8e005dsi16599712pfv.276.2022.04.06.02.57.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 02:57:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MJk6nW7C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1EA4F22A293; Wed, 6 Apr 2022 01:10:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575007AbiDEXCS (ORCPT + 99 others); Tue, 5 Apr 2022 19:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352180AbiDEKEA (ORCPT ); Tue, 5 Apr 2022 06:04:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F9C6B0A7B; Tue, 5 Apr 2022 02:52:55 -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 125A5B818F6; Tue, 5 Apr 2022 09:52:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F73AC385A1; Tue, 5 Apr 2022 09:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152372; bh=CphQbbV0n6/aEe+zcIVsjiSJeqm4aIXll6oPKqDuX9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJk6nW7CV9x6sNay5TpLCC8wmcgEdJUuU5lfPBci9skJ5JNMPuf2Vdm6KPitef5KP fvL6ZtFjYA7D9tKYvC/thDzVHOyuKkrMWpgRa5lIg0iRiMO6mIi/m5kXqGgFzn1aS6 Lz2n23c3m8IAotVZXtsK2vMugrENNSok3Va0Msl8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ming Qian , Mirela Rabulea , Hans Verkuil , Sasha Levin Subject: [PATCH 5.15 754/913] media: imx-jpeg: fix a bug of accessing array out of bounds Date: Tue, 5 Apr 2022 09:30:16 +0200 Message-Id: <20220405070402.434108696@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 637d73f5f4a2..37905547466b 100644 --- a/drivers/media/platform/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/imx-jpeg/mxc-jpeg.c @@ -932,7 +932,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