Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp793838pxb; Wed, 6 Oct 2021 15:47:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzofWyiKQc1hioHfja0dZxxiy2ywpQfqEhVhRkKleb4bcKC6Muk82mcbpMRcPu+tC8KICEA X-Received: by 2002:a17:906:1f49:: with SMTP id d9mr1193662ejk.150.1633560459768; Wed, 06 Oct 2021 15:47:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633560459; cv=none; d=google.com; s=arc-20160816; b=fD6EGxGtL+4A1E+mNfDvq2dz+O+bzwQj8OvnDOLuLzL7+bvZLnpfl4WiEBudzn8E0w h1hHSBfRVm7Uv0KgQF6FC+FdSudjT05v0XhAcmsbLDiqnqS+BIDim4Dj514tBRRlkG9r 6rNXi9PhNt1P4RuMuot0csxoGrg8/8tm7BJvX3NPuvqCW6EAfKMBcbZ87u7n2nsqFFQ9 qttL3F9uzwqlMTyhzsbx5GiNcoqzygWHuqHwRuRsRLRUQYF9Ia8onxz9zxOb2QTfCIxm BFKea0FDPOQQBFHeVYQhyK6qrcT3xHBI9JEOmxWksdyqq6UcGE6fPQUQdsMQNicU2sxX LIFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=U8M1dbFOi9vkEKSXXtpgGgRcXsxEcCDZd9Id5Kn3KAI=; b=QFgf6KGyzTNhteWkoiSMlNLzhWYWiEppAwdr0hGtCHnXHFdLXJeMuUUUC2eqOGBKGk 6Le7d+RWQwydAZanKiJedJUkjvEheU1U2G4w36ouNSfnfTrmrbDC/ZRT8v7MK+RsaEJM MGBF41tztnee+0bZ1iinfFX936RZeI3IrkcfocL3crk5tchzfjOx6OUYERPAYKNNWL4b hSoNoTYiaPyGVQJjWxX4J1dxCN/pCarnLQ3sqrR+7xs56RZh3vl8OpppElpJScNYBIuM RpRqXbv6pggpiNHrStdNmj3uVGDbGWgBzPRe0eHLBn5moyzamhpclGTXxxZe0k7dt4RZ oWFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Uhk8XSdY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gx23si2361093ejb.531.2021.10.06.15.47.14; Wed, 06 Oct 2021 15:47:39 -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; dkim=pass header.i=@chromium.org header.s=google header.b=Uhk8XSdY; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231597AbhJFWrP (ORCPT + 99 others); Wed, 6 Oct 2021 18:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbhJFWrP (ORCPT ); Wed, 6 Oct 2021 18:47:15 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B68EC061746 for ; Wed, 6 Oct 2021 15:45:22 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id y197so4577838iof.11 for ; Wed, 06 Oct 2021 15:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=U8M1dbFOi9vkEKSXXtpgGgRcXsxEcCDZd9Id5Kn3KAI=; b=Uhk8XSdYNn5h631zIYLqXzX59plnecs521+YuO/NTKZH6E/AX58IiUEAjOq3QynJxs dMvFokV/kZuzna/vkHp59E0MLrFlUruxIdNrCMYk9kEVpFHYcivMVwa9wDxXyO34OquZ fOtMiNcvQKkSNxhyUkPoOtLnics+MqHxA7y2o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=U8M1dbFOi9vkEKSXXtpgGgRcXsxEcCDZd9Id5Kn3KAI=; b=RHxAQT9BAQUqCl2gxos78ijM8qC4D/YiY5ImHRl7FkYCXnDxa7a5Dapgpp1Nag3+9e FL84KneW/2UH1zmiRjo5SAKxoQV0hV242e3dkDQTRrTBwLBk8w9pcL1radFvDW8fLiHN LefnhQQT7rcpGX/8RZIY/BmhMZPo2WVst9PEOC0tEu7qNoqbPQ62TrKfccm7eviG8fe7 e2V9O4B7dD5R328w2BlXF+uKAvTVgc0NJMxO+8/aWESEP4vIj3METZEPd7mYwj3Roqyg gP1jCGei2ELC11saExZ4y0Rgt+taiddasTesOBeb8Y7dF/QizL3YLeXx9KeNFwBOuJ0T jsPQ== X-Gm-Message-State: AOAM533poTek/BfEforkcYqm9iLk/RxITtEhkpBfKRqWw3c2oR1cIBHe JaofTgObafgFg+0Ks3lNAhRk1l2sApNU1g== X-Received: by 2002:a5e:d612:: with SMTP id w18mr724537iom.196.1633560321682; Wed, 06 Oct 2021 15:45:21 -0700 (PDT) Received: from mail-il1-f172.google.com (mail-il1-f172.google.com. [209.85.166.172]) by smtp.gmail.com with ESMTPSA id k4sm12803085ilc.10.2021.10.06.15.45.19 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Oct 2021 15:45:20 -0700 (PDT) Received: by mail-il1-f172.google.com with SMTP id r9so4446130ile.5 for ; Wed, 06 Oct 2021 15:45:19 -0700 (PDT) X-Received: by 2002:a05:6e02:1847:: with SMTP id b7mr591808ilv.180.1633560319430; Wed, 06 Oct 2021 15:45:19 -0700 (PDT) MIME-Version: 1.0 References: <20211005192905.v2.1.Ib059f9c23c2611cb5a9d760e7d0a700c1295928d@changeid> In-Reply-To: <20211005192905.v2.1.Ib059f9c23c2611cb5a9d760e7d0a700c1295928d@changeid> From: Doug Anderson Date: Wed, 6 Oct 2021 15:45:07 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] drm/edid: In connector_bad_edid() cap num_of_ext by num_blocks read To: dri-devel Cc: "Siqueira, Rodrigo" , "Zuo, Jerry" , alexander.deucher@amd.com, "Wentland, Harry" , Kuogee Hsieh , =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , LKML Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Tue, Oct 5, 2021 at 7:29 PM Douglas Anderson wro= te: > > 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 corrupt= ion test") > Reported-by: Ville Syrj=C3=A4l=C3=A4 > Signed-off-by: Douglas Anderson > Reviewed-by: Ville Syrj=C3=A4l=C3=A4 > --- > 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 -Doug