Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp576612rwi; Thu, 27 Oct 2022 05:15:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Z1yp+SgEngcehzuTF+hn+AcyNy/ttoGexD5qXn9kg2yAmOBcon1P2c5sQzTJ30srFgX4j X-Received: by 2002:a17:907:a057:b0:7ac:8e6a:8cd7 with SMTP id gz23-20020a170907a05700b007ac8e6a8cd7mr11838013ejc.678.1666872939818; Thu, 27 Oct 2022 05:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666872939; cv=none; d=google.com; s=arc-20160816; b=xots/VUWUEx440NR3DE7DPB0HcgZZFfbsRSlz0ORYU3yJv8WguKsPDtwXxDoyQPlwX EmBRHJqoHTymvZ7SMdh04cNJ3kWN2xFw9nYqDjRdpbC2YqEeoHSL2ChvMtpBIByx5YL3 RafiH2nJpZu4jndzBZ9WKQAGdZptNmAoebAIWBjVcxyQHcVKHXNzl88ARg6uavfrFML9 2gHNas97e45fZGYOhzDXest7C2LakyoiXU5sWJdTy1EuzkpUhOWl90huue9k+BigCV98 VIxkzyQIPcS/uOJNKudzRigoyqntv7vjdgS6HPUaCTNchiCJsmDnTljTR0S/mwfPgc9a IQWg== 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 :message-id:date:subject:cc:to:from; bh=2rIbp2eDKl6sTu3dYz+JTvjfZ1g0zpi0QmSZa/uI6ZM=; b=ElFQxdTbQcrL4eO6tsOVHQnXtBlrG6xG06LEcBD4z6UpuYci+yNkaN2rsD1r3+Oc0o mcxWzSLqOHwYye7mGDlj+oQQGbE9UXQpUAc+JwR5yeObOK+WKqj9ECi3keI1IT6jPLlG Oh8CQx86aFrNI7uzvwPRDGUGomvKi3H5g9aVw5In/YaEpAVaCCv4DpEKsRPvHRcldPTi pgwJjPfY2jCPArkwLQgP2XoO7Ohmg/9eLSJE5msOwRXAEjHhS1pT4jELPqbmxKSFH2mk kjX/5gJa4XE2ocRpX/EZqRgb3pl0zNqmEWh9Gllxutg35kP4dJUdQujNCt+UOc0vbn+D 92Bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp4-20020a1709073e0400b0078d2784552fsi1400257ejc.684.2022.10.27.05.15.13; Thu, 27 Oct 2022 05:15:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235377AbiJ0Lu2 (ORCPT + 99 others); Thu, 27 Oct 2022 07:50:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234111AbiJ0Lu0 (ORCPT ); Thu, 27 Oct 2022 07:50:26 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6368A63353; Thu, 27 Oct 2022 04:50:24 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MykQ000pQzmVVQ; Thu, 27 Oct 2022 19:45:27 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 27 Oct 2022 19:50:22 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 27 Oct 2022 19:50:22 +0800 From: Liu Shixin To: Hans Verkuil , Mauro Carvalho Chehab CC: , , Liu Shixin Subject: [PATCH] media: vivid: fix compose size exceed boundary Date: Thu, 27 Oct 2022 20:38:55 +0800 Message-ID: <20221027123855.1054059-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 syzkaller found a bug: BUG: unable to handle page fault for address: ffffc9000a3b1000 #PF: supervisor write access in kernel mode #PF: error_code(0x0002) - not-present page PGD 100000067 P4D 100000067 PUD 10015f067 PMD 1121ca067 PTE 0 Oops: 0002 [#1] PREEMPT SMP CPU: 0 PID: 23489 Comm: vivid-000-vid-c Not tainted 6.1.0-rc1+ #512 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:memcpy_erms+0x6/0x10 [...] Call Trace: ? tpg_fill_plane_buffer+0x856/0x15b0 vivid_fillbuff+0x8ac/0x1110 vivid_thread_vid_cap_tick+0x361/0xc90 vivid_thread_vid_cap+0x21a/0x3a0 kthread+0x143/0x180 ret_from_fork+0x1f/0x30 This is because we forget to check boundary after adjust compose->height int V4L2_SEL_TGT_CROP case. Add v4l2_rect_map_inside() to fix this problem for this case. Fixes: ef834f7836ec ("vivid: add the video capture and output parts") Signed-off-by: Liu Shixin --- drivers/media/test-drivers/vivid/vivid-vid-cap.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/test-drivers/vivid/vivid-vid-cap.c b/drivers/media/test-drivers/vivid/vivid-vid-cap.c index 86b158eeb2d8..b0cee26b9089 100644 --- a/drivers/media/test-drivers/vivid/vivid-vid-cap.c +++ b/drivers/media/test-drivers/vivid/vivid-vid-cap.c @@ -957,6 +957,7 @@ int vivid_vid_cap_s_selection(struct file *file, void *fh, struct v4l2_selection if (dev->has_compose_cap) { v4l2_rect_set_min_size(compose, &min_rect); v4l2_rect_set_max_size(compose, &max_rect); + v4l2_rect_map_inside(compose, &fmt); } dev->fmt_cap_rect = fmt; tpg_s_buf_height(&dev->tpg, fmt.height); -- 2.25.1