Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2151314iof; Tue, 7 Jun 2022 21:28:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzwB50kx2NfFgeNx+b5o9pq6MEHNF1KNCKBDkg/NryIwBGqUjt0xas5R2iyKfxrZXKW0hK X-Received: by 2002:a63:4722:0:b0:3fb:94a7:9986 with SMTP id u34-20020a634722000000b003fb94a79986mr28330423pga.531.1654662500902; Tue, 07 Jun 2022 21:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662500; cv=none; d=google.com; s=arc-20160816; b=cvJjg9MMn+wxu5LWd5jR5AsPF9kLNpX2wrgF9h+bZ/7jxKY37tmkiroCCqFCCylCOd P7dAcBY3mFvpq5sL7gj7qRsD9NnY9i3UflYluchdv8o+wOA9adJwvBve+ZsZuvYHoprO wuaZ8oicv9mRH6wF7xhk8CFdo0LM+GZvFZF/5k4Tgg1w+9WEJnH94Cx+6umPUZrb8jpV LTwprh8Ai2VRdcFboPP7ERMpHkTf/y2IYQWAqBRJwQJxiXSKKfjzRXoF/y1ZBDAFyxGT 2X8GA0oXDYyws6+7XQcxgb3MjIm2cr4DrM0S+D3c3jTqzSNI0KdKXBs7rRd0hQbBntyW HZfw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cS3CUup4h4yQOFBhQDKQ+hIbaAATeR7fhKIBbo6VPDA=; b=zOTVp3o1rZiLneDjI5jB9CIRPYntkaVglXKbc6gFaxH5lK6pIBmYF+xuXrZrARKwkp 6pX7vfaugibC4cOBizMaoCPD9xVJ9sJR3N+CPlppgPGWgu8CYwTnXv5R0ubymLEwzrZA GdVrMU4UNDw+aFxqO/bzv0kyXEcfRTbT142P/JCVAHVS9ortOPsdu/hnaM+l31g5gl0J lwlkgO8WwQnAZjMJCldrUk1FoyzRNle0XzGSFKPdNc8ZncJe+FC4Ttcqq7GxZ3K5D56A oicP+N/A2i2SakXidva3wajEjEvftmuKXR2gJpn1rACv5VgHbFKEdw14xA3eu6PpIbPV mb7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AaXYjq6W; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v191-20020a6389c8000000b003fd0c575824si22356085pgd.110.2022.06.07.21.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:28:20 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AaXYjq6W; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 528CD245F82; Tue, 7 Jun 2022 20:57:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344932AbiFGRef (ORCPT + 99 others); Tue, 7 Jun 2022 13:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346918AbiFGRZe (ORCPT ); Tue, 7 Jun 2022 13:25:34 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65F50110AF2; Tue, 7 Jun 2022 10:23:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 08F49B8220C; Tue, 7 Jun 2022 17:23:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6DF1FC385A5; Tue, 7 Jun 2022 17:23:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622616; bh=7IEAY8SM+tkQYSYabyBmub0Oob3YVAUdvsbXtYkCut4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AaXYjq6WdGcOywHhRI18ivJIj16NNADxg12ZHUJuQjd5GHBtsrJEVY+hXHISljTAP kUWvtwgKeMMyy3k4Qn9WkJMvvZPV+CwimXd/qtqXhnkY9KUv+xKAiIxgVHFhOHciIe 8ae4I96k1RO6rnsbVR0vjhTpP29h7vmTOsJCYoOg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Jani Nikula , Sasha Levin Subject: [PATCH 5.10 124/452] drm/edid: fix invalid EDID extension block filtering Date: Tue, 7 Jun 2022 18:59:41 +0200 Message-Id: <20220607164912.253781209@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Jani Nikula [ Upstream commit 3aefc722ff52076407203b6af9713de567993adf ] The invalid EDID block filtering uses the number of valid EDID extensions instead of all EDID extensions for looping the extensions in the copy. This is fine, by coincidence, if all the invalid blocks are at the end of the EDID. However, it's completely broken if there are invalid extensions in the middle; the invalid blocks are included and valid blocks are excluded. Fix it by modifying the base block after, not before, the copy. Fixes: 14544d0937bf ("drm/edid: Only print the bad edid when aborting") Reported-by: Ville Syrjälä Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20220330170426.349248-1-jani.nikula@intel.com Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_edid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 862e173d3431..4334e466b4e0 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1995,9 +1995,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, connector_bad_edid(connector, edid, edid[0x7e] + 1); - edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions; - edid[0x7e] = valid_extensions; - new = kmalloc_array(valid_extensions + 1, EDID_LENGTH, GFP_KERNEL); if (!new) @@ -2014,6 +2011,9 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, base += EDID_LENGTH; } + new[EDID_LENGTH - 1] += new[0x7e] - valid_extensions; + new[0x7e] = valid_extensions; + kfree(edid); edid = new; } -- 2.35.1