Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2766657imm; Wed, 3 Oct 2018 08:52:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV62xUaoeumDUjgcsR7zGxPR1fEZp78gkv1kMQopd5H4Zv1ObhLeZK2W+vf+zIgfc5JtDpjFy X-Received: by 2002:a63:608c:: with SMTP id u134-v6mr1911204pgb.266.1538581960363; Wed, 03 Oct 2018 08:52:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538581960; cv=none; d=google.com; s=arc-20160816; b=BNt255dRZ2BCq3ZsfyDOHO5A5AqqFaWkjazYqGCkz6glNodO6oQ0mR5Zp91j80UjSH CNR9Emy8IrHOVgIPV/MB8jYjsph3oXYDXPrUeOUdMq3M5wvrfqjV1ocW7SF2zUkh5gZH Fs5Iwzi7teSKgSm3dfvUV/+yZ2juPkdGf70YKDazOINtgNfp1DfZl7n4FSYwu+la7UJF YJ9b4+FDyob+A/L5sxudyCQe7qEVZvNTyMSDJSU/hTaGPocUbn4dtF3sFqAih7XyAhxt u1wRz5e1uIuAzPRwthpxTh3iGYjDvh9E71zrstQvNWR0jcM1375ApxUY0Auk5T0/PWsg bNSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=yDnGScFRXMfdt5zpMQ22zcxToehENNJc1IxxpzVmrrI=; b=nJJFQrvstHWyy54Cqc/TFMbBJFWpvvByEj7EcGig9Fj9Oom3p2h6Cq5Oo2Tn+nLTXc S1nA1awOTC/Mg8NWJ1YPv2vdBJGCnALQJ+KfE42puH8DnxKElBZR7sAAk26E7eTul0iK nedNi3fE4E4bMe8iCKyvLUMfhHi45TmOi4ciaHOVhSyNeeN0U3y8ykde84t7ErZ08ryV q9BHikvuaisY+7HN+XUMqYyfaNx50gBUYjZlEwPmsLiN6R58rZyaLpfAAH5wUPnSVOHV U29XT9HLwqUzmesyvA5yhGSQwuKyUk9oQP9fdo1iN2haW4yxZKLomnUlYtYweggJCoM9 GCpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si1974016plh.33.2018.10.03.08.52.25; Wed, 03 Oct 2018 08:52:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727546AbeJCWka (ORCPT + 99 others); Wed, 3 Oct 2018 18:40:30 -0400 Received: from mga09.intel.com ([134.134.136.24]:14596 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbeJCWka (ORCPT ); Wed, 3 Oct 2018 18:40:30 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2018 08:51:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,336,1534834800"; d="scan'208";a="91856341" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.174]) by fmsmga002.fm.intel.com with SMTP; 03 Oct 2018 08:51:24 -0700 Received: by stinkbox (sSMTP sendmail emulation); Wed, 03 Oct 2018 18:51:23 +0300 Date: Wed, 3 Oct 2018 18:51:23 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Daniel Vetter Cc: Eugeniy Paltsev , Linux Kernel Mailing List , Alexey Brodkin , linux-snps-arc@lists.infradead.org, stable , dri-devel , Sean Paul , Dave Airlie Subject: Re: [PATCH] drm: fb-helper: Validate requested pixel format against bpp Message-ID: <20181003155123.GJ9144@intel.com> References: <20181003110457.9318-1-Eugeniy.Paltsev@synopsys.com> <20181003123047.GK9144@intel.com> <1538577004.11140.5.camel@synopsys.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 03, 2018 at 05:29:34PM +0200, Daniel Vetter wrote: > On Wed, Oct 3, 2018 at 4:30 PM Eugeniy Paltsev > wrote: > > > > On Wed, 2018-10-03 at 15:30 +0300, Ville Syrj?l? wrote: > > > On Wed, Oct 03, 2018 at 01:36:00PM +0200, Daniel Vetter wrote: > > > > On Wed, Oct 3, 2018 at 1:05 PM Eugeniy Paltsev > > > > wrote: > > > > > > > > > > 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 > > > > > > > > drm fbdev emulation doesn't support changing the pixel format at all. > > > > I think we should reject all such request, not just the invalid ones. > > > > Can you pls respin? > > > > > > FYI I once posted a patch to tighten up the fb-helper pixel format > > > stuff: > > > https://patchwork.freedesktop.org/patch/203189/ > > > > > > Hi Daniel, > > > > will you take Ville's patch or should I create the new one which is only related > > to new pixel format validation in drm_fb_helper_check_var() ? > > Ville's patch isn't the bugfix we're looking for, but a draft version > of what adding proper format support in drm's fbdev emulation could > look like. With lots&lots of open questions. Actually it does pretty much what you seem to be asking for. Ie. reject any attempt to change the pixel format. Not really sure how to do it much more minimally. Hmm. Oh there is a more minimal way actually. I mistakenly remembered that fbdev clobbers info->var already before check_var(), but actually it only does that before set_par(). So I guess all we really need is to compare the fb_bitfields/bits_per_pixel/etc. between info->var and the passed in var. > Not anywhere near ready > for merging, and definitely not stable backport material. > > So yes, still want the minimal bugfix. > -Daniel > > > > > > > > > Thanks, Daniel > > > > > > > > > --- > > > > > 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; > > > > > -- > > > > > 2.14.4 > > > > > > > > > > _______________________________________________ > > > > > dri-devel mailing list > > > > > dri-devel@lists.freedesktop.org > > > > > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_dri-2Ddevel&d=DwIDAw&c=DPL6_X_6JkXFx7AXWqB0tg&r=ZlJN > > > > > 1MriPUTkBKCrPSx67GmaplEUGcAEk9yPtCLdUXI&m=f12ZyEESIeavtqCUKutiZ9F6xtRFC2UUvdqnM4ywBx8&s=CPS8taMiYbIgXo-fxhqErOJXvO6PMTzmr-BNnGJIoy0&e= > > > > > > > > > > > > > > > > -- > > > > Daniel Vetter > > > > Software Engineer, Intel Corporation > > > > +41 (0) 79 365 57 48 - https://urldefense.proofpoint.com/v2/url?u=http-3A__blog.ffwll.ch&d=DwIDAw&c=DPL6_X_6JkXFx7AXWqB0tg&r=ZlJN1MriPUTkBKCrPSx67 > > > > GmaplEUGcAEk9yPtCLdUXI&m=f12ZyEESIeavtqCUKutiZ9F6xtRFC2UUvdqnM4ywBx8&s=Vt8OX9s9ljSK6GDgbnwsF-Yd35fbBUfe8SBV2jPnVaQ&e= > > > > _______________________________________________ > > > > dri-devel mailing list > > > > dri-devel@lists.freedesktop.org > > > > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop.org_mailman_listinfo_dri-2Ddevel&d=DwIDAw&c=DPL6_X_6JkXFx7AXWqB0tg&r=ZlJN1M > > > > riPUTkBKCrPSx67GmaplEUGcAEk9yPtCLdUXI&m=f12ZyEESIeavtqCUKutiZ9F6xtRFC2UUvdqnM4ywBx8&s=CPS8taMiYbIgXo-fxhqErOJXvO6PMTzmr-BNnGJIoy0&e= > > > > > > > > -- > > Eugeniy Paltsev > > > > -- > Daniel Vetter > Software Engineer, Intel Corporation > +41 (0) 79 365 57 48 - http://blog.ffwll.ch -- Ville Syrj?l? Intel