Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp5988780iob; Tue, 10 May 2022 08:04:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxnUUHCXeqtBPHG5BIjlCjMC/k0rGwjeoy6cI8XZFQULmSHYdTV+F6ecqq6OnKPxMA9F2C X-Received: by 2002:a63:5d1c:0:b0:39c:c5d7:ebbb with SMTP id r28-20020a635d1c000000b0039cc5d7ebbbmr17207696pgb.54.1652195045700; Tue, 10 May 2022 08:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652195045; cv=none; d=google.com; s=arc-20160816; b=mJdrEPO3Sc46Xr4Zd/FCNzgPPwQaU5VwaIDa3DI3gSpNJ9QLYbdJZdVTfz+6/MXZI9 FdmuIgcsDgLXHdx3LBaa+m4Aeg74rcjD0a8wA0/ObvfBy38fS0LTKjDMOmEYUQHSiZI9 sp5FkmHXHAX3eUeEiKwX/28avCFKiXrYHSS6mLeGv1Hph/l/bPIby3qq0WPDlRPrIb0k hD08LWpv47jbvW6gcfwuEzLzfSGKGpXIiyZSiSkoR4Yaggin/G5GkJQG/O6WJLfdHVoU ax7NVbGL7iEAEOzOJOneL0aWqU0CMwzNlGu2qTPhKzvfsaNO0ULj/P9uaAYZSloFqdX8 mX4w== 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=XlDGjSiDyQNeS/0N830+mbNVxSekdZbniNc6AoM6i7Q=; b=QlMVugPxxXHvVwVRNdM5hWGGLYV7Uyw468QLMCTNwJxemYeP6MoHrlVK6kF7QYx2b4 aekNViZCjVEH4JJzRIuoTRn/18+23P7wUBYsYZpOSrdhDI3Bma7c1oE+F5fnDo95EKpj UL80MFoSIS18nBUpvFkKGaSpeiIcOHCDXhmRLG6no6GME3Z9HaWijf4iNFHSaEwtQ9U/ SaDsAuSVWHtzv1FemydQOui5BGtZpyGUA71WKXqUdD9JXd7wwstx94+OBTZUl1gMVt99 sRg5/WYU9gH8Y2z3Rsoh3Y9AeFrIbN8VTYdLeuMySc3tAO2fwmfSYNA7Qc89Mx8v/Sfb PRcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ipe5EWjs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s70-20020a632c49000000b00399632a476esi17553610pgs.686.2022.05.10.08.03.50; Tue, 10 May 2022 08:04:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ipe5EWjs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245420AbiEJNwX (ORCPT + 99 others); Tue, 10 May 2022 09:52:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243513AbiEJNfy (ORCPT ); Tue, 10 May 2022 09:35:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 013A62C0D02; Tue, 10 May 2022 06:24:53 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 56259617DF; Tue, 10 May 2022 13:24:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 483BBC385A6; Tue, 10 May 2022 13:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189092; bh=tWydUitcdou5KgHaeOgMFE3O5AHjYU42pGOO4FY5kts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ipe5EWjswNBnQqba2UVYwdVvIf6prdfm/gN2nvlwjQ9uJGdweqvXWAjF93n0Plh3K GWvBJTKy4r0puN7O8zAXX6/WudFaociPBjKda/J7uy1Vo/9M59NJA4nY7pUPgtqfNY 4lST90ZGmXYanx678pl9Z5iFuHgCM5+w3hMhFSN8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harry Wentland , Alex Deucher Subject: [PATCH 5.10 10/70] drm/amd/display: Avoid reading audio pattern past AUDIO_CHANNELS_COUNT Date: Tue, 10 May 2022 15:07:29 +0200 Message-Id: <20220510130733.168973865@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130732.861729621@linuxfoundation.org> References: <20220510130732.861729621@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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: Harry Wentland commit 3dfe85fa87b2a26bdbd292b66653bba065cf9941 upstream. A faulty receiver might report an erroneous channel count. We should guard against reading beyond AUDIO_CHANNELS_COUNT as that would overflow the dpcd_pattern_period array. Signed-off-by: Harry Wentland Reviewed-by: Alex Deucher Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c @@ -2822,7 +2822,7 @@ static void dp_test_get_audio_test_data( &dpcd_pattern_type.value, sizeof(dpcd_pattern_type)); - channel_count = dpcd_test_mode.bits.channel_count + 1; + channel_count = min(dpcd_test_mode.bits.channel_count + 1, AUDIO_CHANNELS_COUNT); // read pattern periods for requested channels when sawTooth pattern is requested if (dpcd_pattern_type.value == AUDIO_TEST_PATTERN_SAWTOOTH ||