Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp395113rwb; Thu, 11 Aug 2022 03:37:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4n+daOx7AoQfp0SbO5az9LlX4NaEjOGSPsK0q66TLtlTevvmGJlANhFmMYna1KzqZx4qmD X-Received: by 2002:a17:907:2809:b0:730:a723:9ddf with SMTP id eb9-20020a170907280900b00730a7239ddfmr23534656ejc.42.1660214241101; Thu, 11 Aug 2022 03:37:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660214241; cv=none; d=google.com; s=arc-20160816; b=T+K3jKMu9ZEKIDAORG9C/utLItCb3c8Dn31Q/01KBlvLIjwYU9k4s+uSTY3gLVeFIU rWSUvvh3+7N24fg2e/qdRfmUuPXAuNQgAVwtPdA9kPygE71WfE//2d1/2XwfHGyupOCE 8KY8lfJORSJ7P4kj9A1SxNxF+iUoAq5IwY3gYfCH0K5rpsUxTY2K1iTqg+eohF9Db2W1 kjAxRnrMEbgwTX+Wi4/v/tE8URSneUNSYODXYUuDtv1b2Ae7ZrjsVTTEDD7acxpczsB1 sPTeXze9HsByqlkHjhXrph+SXopBzTsj0gQjRZFmZmMI5TTcXjXV/Aqf/xIH6tEMmRMu vX4Q== 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=X0IXGJCKD4GSk26eeyR7RfAHnavaBBu00pXrz1MeHcw=; b=fhjtEXbEVB1bJhifKb4KUNIkTxpzgJw9DEjURhw/xJEoYoSBBufRmWmQkjYoyZi9QS g1LCVzeyvnG1hz8K4fEQDVFi6jHkZHWfxbIuEjoWpvgZVw6kEBE9sJXMUKz3NwiGaV/5 tQMT6YXri42YXqSxNTgvdKon9IeHu9Ru2cJgb1f5/5xro6HbZI9t31bIyhxo9QOwmC7v eC7nEqyDpWQwlnmuln7P8D0XTbOGdA0qEgGYl7TK8TSjR0hkiopOMeZi5c/2fdY9TMs3 WEkSfiUydGubtyH8Na6RlpwvAkqspKIWf96JgLYZQg27XpE2DW5lJQotJ76Zo4MDuIBE 8F/g== 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=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb38-20020a1709071ca600b007309eacb2f9si8469065ejc.468.2022.08.11.03.36.55; Thu, 11 Aug 2022 03:37:21 -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=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234511AbiHKKX3 (ORCPT + 99 others); Thu, 11 Aug 2022 06:23:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbiHKKX0 (ORCPT ); Thu, 11 Aug 2022 06:23:26 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 495FE255BA for ; Thu, 11 Aug 2022 03:23:24 -0700 (PDT) Received: from localhost.localdomain (unknown [83.149.199.65]) by mail.ispras.ru (Postfix) with ESMTPS id 855AE40D403E; Thu, 11 Aug 2022 10:23:19 +0000 (UTC) From: Andrey Strachuk To: Maarten Lankhorst Cc: Andrey Strachuk , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Geert Uytterhoeven , Helge Deller , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var() Date: Thu, 11 Aug 2022 13:23:04 +0300 Message-Id: <20220811102304.70769-1-strochuk@ispras.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Add virtual screen size check to drm_fb_helper_check_var() in order to validate userspace input. Found by Linux Verification Center (linuxtesting.org) with syzkaller. Signed-off-by: Andrey Strachuk Fixes: 6c11df58fd1a ("fbmem: Check virtual screen sizes in fb_set_var()") --- drivers/gpu/drm/drm_fb_helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 2d4cee6a10ff..d21fe89358af 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1355,6 +1355,16 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var, (drm_format_info_block_height(fb->format, 0) > 1)) return -EINVAL; + /* verify that virtual resolution >= physical resolution */ + if (var->xres_virtual < var->xres || + var->yres_virtual < var->yres) { + drm_dbg_kms(dev, "requested virtual screen size that is " + "below the physical size(%ux%u vs. %ux%u)\n", + var->xres_virtual, var->yres_virtual, + var->xres, var->yres); + return -EINVAL; + } + /* * Changes struct fb_var_screeninfo are currently not pushed back * to KMS, hence fail if different settings are requested. -- 2.25.1