From patchwork Thu Oct 27 12:38:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shixin X-Patchwork-Id: 11751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp182195wru; Thu, 27 Oct 2022 04:53:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6x80sv1p8OoySfLkm3yvo0WXtuA25mhTbpBaNUo2wGlDKwfUhviclFemJ7pMrdo6RtE27j X-Received: by 2002:a17:907:72d6:b0:79b:8cce:112a with SMTP id du22-20020a17090772d600b0079b8cce112amr28083781ejc.118.1666871592215; Thu, 27 Oct 2022 04:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666871592; cv=none; d=google.com; s=arc-20160816; b=q1SMqrVvBZjWUYdAP882Xaq/XN0x7pUodYpGQOTXWtIxjqk7FabTQU3vFUiqqPXwvw kCdXQRPjVeQ36lCQbPAd0pu+XjctSsqx5zUnN2lnjJoexANvUiHXdUbad8HY8wjlf/ZR hv6GA1IODrCQ+boDdB64RJybln+7Nj0KV/BWX7y1IkK93xxuefNVU9nx5pVwfIZO6J7s Pm/Cml7tcLfmSIp2bFR/Xfee4r816nofQ6hQbXRaCe0sh/Wu1VCYsvOJleVg1pRHK7aE bkhVvA+GY6ZjkG0IGKSa1WAUDEjvBihzFLo1ha1GiL7uc/xHI1MkB8nt+mkz8QFLDrRk kgNg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c92-20020a509fe5000000b004587e08bc14si1181691edf.508.2022.10.27.04.52.47; Thu, 27 Oct 2022 04:53:12 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747841546766821437?= X-GMAIL-MSGID: =?utf-8?q?1747841546766821437?= 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);