From patchwork Wed Oct 3 11:04:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 978200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tYj0ajNz"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="Z6K5+n++"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42QCq84r31z9s8J for ; Wed, 3 Oct 2018 21:05:24 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=+UQTMLMfMvxK9/xDxo8xLNBUYZxnGlyY11o6BUIOpdc=; b=tYj 0ajNzABPI2hU8qQ+XKMjhNLx6iHFURPqSjl3TjsRUPwl0M/fUO6BahxLO3uQxLYFnSQ4+ga/GHGkD LCtS2UAniPzv/lU6l4+Se28H8o7rvLU+4fDrZxutUfngyM/YkbHFNV5CEDElBqLyszrnQXKaJmD9s gXiV6oO+DhXLSFlXT98tHSJMXkKon+V/GS2K480bLWqkjMu25g/PvH1CBv0K4+CXxeq2Vr1OItyjg m17gtzjXhMe9bQg1mJOAL0bRsyGZqdHG1k5nqnbQZ8sRao4qy9cGuDiia/YxXQ4LAdH+7tRfo5h0v EJonpiJpMkSDiDnnMOH3BfY71EVKksQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7ey2-000556-G2; Wed, 03 Oct 2018 11:05:22 +0000 Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g7exz-0003qF-8x for linux-snps-arc@lists.infradead.org; Wed, 03 Oct 2018 11:05:21 +0000 Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2F97A10C03B3; Wed, 3 Oct 2018 04:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1538564706; bh=qQ8L0Z+7eV9UKazbeWPkZFzZ765OnKszjk9JjmN1DVA=; h=From:To:Cc:Subject:Date:From; b=Z6K5+n++g4GB2Rhbc8qMWOQHVtivMF8SQfAN1jfLwpTI+gP4om3K66AZunC2kV3z2 89fBvSqG+5XaEXLr+ZrdGDvV0vBd49CM6IRztALLmp4uSNtkYhu2tTtV+m40WkcE+e trfaZDzM5An+HUc+a80mB0W2DaHc5okaNcD/KEeMe1cANcDkPPTldM2NW819GMBM6g ATfUUdweO5NNqNm9hF86ozeRxqA6dmJvYaVY2rF9sddaR6heq0NRIZ8Thxj0RuKZjH kryB3bRroCCmy74ZllZLHVNqIOBV+A8jSD9MiySAjpX4hQ67o+RmAGarEp+m0YhEL6 5IgghwvKbYQ+g== Received: from paltsev-e7480.internal.synopsys.com (paltsev-e7480.internal.synopsys.com [10.121.3.38]) by mailhost.synopsys.com (Postfix) with ESMTP id A031C53A4; Wed, 3 Oct 2018 04:05:00 -0700 (PDT) From: Eugeniy Paltsev To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm: fb-helper: Validate requested pixel format against bpp Date: Wed, 3 Oct 2018 14:04:57 +0300 Message-Id: <20181003110457.9318-1-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181003_040519_367660_0AE0A906 X-CRM114-Status: UNSURE ( 6.54 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , Gustavo Padovan , Alexey Brodkin , Maarten Lankhorst , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Eugeniy Paltsev , linux-snps-arc@lists.infradead.org, Sean Paul MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Validate requested pixel format against bits_per_pixel to reject invalid formats with subcomponents length sum is greater than requested bits_per_pixel. weston 5.0.0 with fbdev backend tries to set up an ARGB x8r8g8b8 pixel format without bits_per_pixel updating. So it can request x8r8g8b8 with 16 bpp which is obviously incorrect and should be rejected. Cc: stable@vger.kernel.org Signed-off-by: Eugeniy Paltsev --- drivers/gpu/drm/drm_fb_helper.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 16ec93b75dbf..4f39da07f053 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1610,6 +1610,13 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var, return -EINVAL; } + if ((var->green.length + var->blue.length + var->red.length + + var->transp.length) > var->bits_per_pixel) { + DRM_DEBUG("fb requested pixel format can't fit in %d bpp\n", + var->bits_per_pixel); + return -EINVAL; + } + switch (var->bits_per_pixel) { case 16: depth = (var->green.length == 6) ? 16 : 15;