Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp807790pxb; Wed, 6 Oct 2021 16:08:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwG95OwX1oa2bOSJGl06WxQL1JZJ3KKD9RjgcIraIXyJ3dZUt0DH4EcLBWATvJkCOW7Ay6F X-Received: by 2002:a17:902:eed3:b0:13e:c933:8c19 with SMTP id h19-20020a170902eed300b0013ec9338c19mr724937plb.27.1633561722951; Wed, 06 Oct 2021 16:08:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633561722; cv=none; d=google.com; s=arc-20160816; b=FheZ7j5la9VDQtpiXPcE4dP7cUadcw3Gf28/57Gy6v8CYUx0J+GKrqyvu3zR5MD67u 1aNv8uGWs/Pni0HHQ+WtjG4AR6A/q8asbOaXIoxxDijb7fhYcPjVh+Tz1MNLpi4m+Uy5 eZ3rySlc2opZTCsFNiszrp4/FxtRimtF6cNPveac40G1DWXIwy3SdRfe36vlkAxdOnNP hoWipqF7mw2BLq3HGlyQm+FII/5D0ahidmE8/IhQP+2ONtSA0Pl/S12tWH1Oib8temWt OXb2yMOaVol7sEdhtfnSbskMvVObt9Jm/MLtZ0bsPsSTA2sNGo6sc45kN1X8K83qohtM 4ung== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0zHlqbM/V9rTwgHvsb8Dbb94yyyYi9tLFBKzngo35Yw=; b=re4O8BG52moDW9kJp8/iSSOzeAvHiwFLYv3HEhhIRa8rnGjwirxByzwf/3aO5S+3Ok yXu9Pil4YEeIPYZ/hzi9OrwCzR5dFJnZVFho/hul3ldojl1SIcxJ6OsACVKrzGRvnpVJ WmaW5105or2JnduZpbDOQ3K/llXcOhmt91UGeeHLvU7vRjbQJKarzcuUm9osmVyD7P3p IMN4MIbfrM2gWgwGB6D1Aw0UvKz+4cZn34RRrBxrkyrhwy5AuosQYfImqpu3hDgDcygB L31dVgRJl/tvafJLFXJWDZEnEIZXVMwNmbYit/kJuTHtb3RC/5pjkT8WmzH8J9NOWJvY is8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id t13si2772690plg.155.2021.10.06.16.08.29; Wed, 06 Oct 2021 16:08:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231223AbhJFXC0 (ORCPT + 99 others); Wed, 6 Oct 2021 19:02:26 -0400 Received: from mga11.intel.com ([192.55.52.93]:6249 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbhJFXCZ (ORCPT ); Wed, 6 Oct 2021 19:02:25 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10129"; a="223515489" X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="223515489" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2021 16:00:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,352,1624345200"; d="scan'208";a="624046966" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.171]) by fmsmga001.fm.intel.com with SMTP; 06 Oct 2021 16:00:10 -0700 Received: by stinkbox (sSMTP sendmail emulation); Thu, 07 Oct 2021 02:00:09 +0300 Date: Thu, 7 Oct 2021 02:00:09 +0300 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Doug Anderson Cc: dri-devel , "Siqueira, Rodrigo" , "Zuo, Jerry" , alexander.deucher@amd.com, "Wentland, Harry" , Kuogee Hsieh , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , LKML Subject: Re: [PATCH v2] drm/edid: In connector_bad_edid() cap num_of_ext by num_blocks read Message-ID: References: <20211005192905.v2.1.Ib059f9c23c2611cb5a9d760e7d0a700c1295928d@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Patchwork-Hint: comment Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 06, 2021 at 03:45:07PM -0700, Doug Anderson wrote: > Hi, > > On Tue, Oct 5, 2021 at 7:29 PM Douglas Anderson wrote: > > > > In commit e11f5bd8228f ("drm: Add support for DP 1.4 Compliance edid > > corruption test") the function connector_bad_edid() started assuming > > that the memory for the EDID passed to it was big enough to hold > > `edid[0x7e] + 1` blocks of data (1 extra for the base block). It > > completely ignored the fact that the function was passed `num_blocks` > > which indicated how much memory had been allocated for the EDID. > > > > Let's fix this by adding a bounds check. > > > > This is important for handling the case where there's an error in the > > first block of the EDID. In that case we will call > > connector_bad_edid() without having re-allocated memory based on > > `edid[0x7e]`. > > > > Fixes: e11f5bd8228f ("drm: Add support for DP 1.4 Compliance edid corruption test") > > Reported-by: Ville Syrj?l? > > Signed-off-by: Douglas Anderson > > Reviewed-by: Ville Syrj?l? > > --- > > This problem report came up in the context of a patch I sent out [1] > > and this is my attempt at a fix. The problem predates my patch, > > though. I don't personally know anything about DP compliance testing > > and what should be happening here, nor do I apparently have any > > hardware that actually reports a bad EDID. Thus this is just compile > > tested. I'm hoping that someone here can test this and make sure it > > seems OK to them. > > > > Changes in v2: > > - Added a comment/changed math to help make it easier to grok. > > > > drivers/gpu/drm/drm_edid.c | 15 ++++++++++++--- > > 1 file changed, 12 insertions(+), 3 deletions(-) > > Pushed this to drm-misc-fixes since the commit it fixes is fairly old. > > fdc21c35aaa1 drm/edid: In connector_bad_edid() cap num_of_ext by num_blocks read BTW seems kasan caught this for us [1]. I didn't notice we had a bug open about it until now. Just Chris Wilson mentioned it to me in passing quite a while ago, and I totally forgot about it until I saw your other patch poking around the same code. [1] https://gitlab.freedesktop.org/drm/intel/-/issues/4106 -- Ville Syrj?l? Intel