From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0530C433EF for ; Thu, 9 Dec 2021 23:41:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234517AbhLIXpC (ORCPT ); Thu, 9 Dec 2021 18:45:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234497AbhLIXpC (ORCPT ); Thu, 9 Dec 2021 18:45:02 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31063C061746 for ; Thu, 9 Dec 2021 15:41:28 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id gt5so5622090pjb.1 for ; Thu, 09 Dec 2021 15:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=r5IxUk7IoRTtrl9b80LUZD9vVdZvTnVgPepWlX6Ohsg=; b=jdweGnXL6ND3BiYR6OrJRdg5Np7KCGmUX0f6pWmIZofXaOe97M4P6exXy9VtmzFCIx 98frCoSGt4fnj1kVXOYDRhRccWPuK0L10zo03sxW2Kic2fIoxAYQ3fFXW9fWADAswkgK UG/ty3h235tjYAvc3RVKU0nlEccy7zoJpzcGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=r5IxUk7IoRTtrl9b80LUZD9vVdZvTnVgPepWlX6Ohsg=; b=NaNaJMLfc6xMq87Na5Qx46+SMmLnS6EeJBLrWVpv1xSBOzQJwQSP2IsL4zpXqwFf5A s5md69usLNXwYLGPawrI7pZgNYjVohWoecjLqUd9lRx7zBgIzj3utGsazEqwdTVxKiMD YaFtH/03IzY1y+cPppXlEsw9NMkIPI1hNsOmJztNN/FOB27k0Dtz9/mJyt6tyEgx7nze 3jonybEzUejmo4pG6Uyj6Zvbv3vbh5quiFQj2znT21wfRl8oLGntbro+vTXzNZ4mkyUZ fxY5TCVEFWUyGHBmN30JzcWFVljNqjaP2fC/MdE/VDkkBCeZsZtJgY9UgxJm7W3IlzPo GiNg== X-Gm-Message-State: AOAM531Lgbpab2sVPZSNolNiV8qOFXLrNzoVbhOtovryQvE9k/o9Z+8N zPh1Ik5lygyG3fBwXdGaCe8kGA== X-Google-Smtp-Source: ABdhPJzyk4sf1WNPIubTmnLyaDj9YqUyzvUL41XvKfsOUs2io7OX0emxdLtUfl9UQJ01SI14m51qjw== X-Received: by 2002:a17:90b:3ecd:: with SMTP id rm13mr19136275pjb.157.1639093287759; Thu, 09 Dec 2021 15:41:27 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id mu4sm11720860pjb.8.2021.12.09.15.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 15:41:27 -0800 (PST) Date: Thu, 9 Dec 2021 15:41:26 -0800 From: Kees Cook To: Harry Wentland Cc: Jani Nikula , David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-hardening@vger.kernel.org, Thomas Zimmermann , Thierry Reding Subject: Re: [PATCH] drm/dp: Actually read Adjust Request Post Cursor2 register Message-ID: <202112091539.6B349AC@keescook> References: <20211203084354.3105253-1-keescook@chromium.org> <87o85r4a4f.fsf@intel.com> <202112082220.81ECDC63D@keescook> <2b7d760c-9ab8-b607-efc6-1ed276d67668@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b7d760c-9ab8-b607-efc6-1ed276d67668@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Thu, Dec 09, 2021 at 05:20:45PM -0500, Harry Wentland wrote: > > > On 2021-12-09 01:23, Kees Cook wrote: > > On Wed, Dec 08, 2021 at 01:19:28PM +0200, Jani Nikula wrote: > >> On Fri, 03 Dec 2021, Kees Cook wrote: > >>> The link_status array was not large enough to read the Adjust Request > >>> Post Cursor2 register. Adjust the size to include it. Found with a > >>> -Warray-bounds build: > >>> > >>> drivers/gpu/drm/drm_dp_helper.c: In function 'drm_dp_get_adjust_request_post_cursor': > >>> drivers/gpu/drm/drm_dp_helper.c:59:27: error: array subscript 10 is outside array bounds of 'const u8[6]' {aka 'const unsigned char[6]'} [-Werror=array-bounds] > >>> 59 | return link_status[r - DP_LANE0_1_STATUS]; > >>> | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ > >>> drivers/gpu/drm/drm_dp_helper.c:147:51: note: while referencing 'link_status' > >>> 147 | u8 drm_dp_get_adjust_request_post_cursor(const u8 link_status[DP_LINK_STATUS_SIZE], > >>> | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >>> > >>> Fixes: 79465e0ffeb9 ("drm/dp: Add helper to get post-cursor adjustments") > >>> Signed-off-by: Kees Cook > >> > >> Using DP_ADJUST_REQUEST_POST_CURSOR2 has been deprecated since DP 1.3 > >> published in 2014, and Tegra is the only user of > >> drm_dp_get_adjust_request_post_cursor(). > > > > I see POST_CURSOR2 is used here too: > > > > drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c > > > > Looks like we read and parse that in the admgpu driver without > using drm_dp_get_adjust_request_post_cursor. Right, and probably that could be switched to use it, but I'm not sure what the impact of the larger link_status read is. > > I don't have a strong feeling but I liked your original > patch a bit better. I'm not sure what it means when part > of a spec is deprecated. Once a spec is written display > vendors might implement it. We should make sure that > displays like that are always handled in a sane manner. Jani, Dave, any guidance here? I'm fine with whatever, but the current code is for sure broken. ;) -Kees -- Kees Cook From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5BF68C433EF for ; Thu, 9 Dec 2021 23:41:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 370C988894; Thu, 9 Dec 2021 23:41:29 +0000 (UTC) Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 29A9F10E125 for ; Thu, 9 Dec 2021 23:41:28 +0000 (UTC) Received: by mail-pl1-x62e.google.com with SMTP id p18so5053603plf.13 for ; Thu, 09 Dec 2021 15:41:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=r5IxUk7IoRTtrl9b80LUZD9vVdZvTnVgPepWlX6Ohsg=; b=jdweGnXL6ND3BiYR6OrJRdg5Np7KCGmUX0f6pWmIZofXaOe97M4P6exXy9VtmzFCIx 98frCoSGt4fnj1kVXOYDRhRccWPuK0L10zo03sxW2Kic2fIoxAYQ3fFXW9fWADAswkgK UG/ty3h235tjYAvc3RVKU0nlEccy7zoJpzcGE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=r5IxUk7IoRTtrl9b80LUZD9vVdZvTnVgPepWlX6Ohsg=; b=jmpuJDliWtJqxJTMsTx20+toQAqbVnv8bx8cOqQUyhOWmmL5KYLfsvTfjh4UgwGeyC Uj7p4rDWTcj7FOvPOzx5n4PlgTXG2XeVveXnBQCBXPFeVLIe78ve6y4WC/dVeNHtcDqr KmgAOidX/mjyDa3rcgH82ebB6dk39ooJcd+Rl1gYXcTZMB6QHQi6HS/O30tdiFh2EL2q T6/RG/IusLodC43uYt/P2KNYtwzk4Km374cXRzokGUc29keCUrnsZoIS6F/hDX1KT10g oZIVHqNR5ZT0TpJRjIO7TIJnAIDBNA+OhCWcGo4wc8gK9N4M1I1LSE/VBOOlO7afloRk oThQ== X-Gm-Message-State: AOAM533ii5J2l2HcgZkKjM3adr1LpGAnyLS6pxnzQpGmGu40PorkC9Dm XU0+G+kS4kChbbsgrDydga9KRw== X-Google-Smtp-Source: ABdhPJzyk4sf1WNPIubTmnLyaDj9YqUyzvUL41XvKfsOUs2io7OX0emxdLtUfl9UQJ01SI14m51qjw== X-Received: by 2002:a17:90b:3ecd:: with SMTP id rm13mr19136275pjb.157.1639093287759; Thu, 09 Dec 2021 15:41:27 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id mu4sm11720860pjb.8.2021.12.09.15.41.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 15:41:27 -0800 (PST) Date: Thu, 9 Dec 2021 15:41:26 -0800 From: Kees Cook To: Harry Wentland Subject: Re: [PATCH] drm/dp: Actually read Adjust Request Post Cursor2 register Message-ID: <202112091539.6B349AC@keescook> References: <20211203084354.3105253-1-keescook@chromium.org> <87o85r4a4f.fsf@intel.com> <202112082220.81ECDC63D@keescook> <2b7d760c-9ab8-b607-efc6-1ed276d67668@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2b7d760c-9ab8-b607-efc6-1ed276d67668@amd.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , Thierry Reding , linux-hardening@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, Dec 09, 2021 at 05:20:45PM -0500, Harry Wentland wrote: > > > On 2021-12-09 01:23, Kees Cook wrote: > > On Wed, Dec 08, 2021 at 01:19:28PM +0200, Jani Nikula wrote: > >> On Fri, 03 Dec 2021, Kees Cook wrote: > >>> The link_status array was not large enough to read the Adjust Request > >>> Post Cursor2 register. Adjust the size to include it. Found with a > >>> -Warray-bounds build: > >>> > >>> drivers/gpu/drm/drm_dp_helper.c: In function 'drm_dp_get_adjust_request_post_cursor': > >>> drivers/gpu/drm/drm_dp_helper.c:59:27: error: array subscript 10 is outside array bounds of 'const u8[6]' {aka 'const unsigned char[6]'} [-Werror=array-bounds] > >>> 59 | return link_status[r - DP_LANE0_1_STATUS]; > >>> | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ > >>> drivers/gpu/drm/drm_dp_helper.c:147:51: note: while referencing 'link_status' > >>> 147 | u8 drm_dp_get_adjust_request_post_cursor(const u8 link_status[DP_LINK_STATUS_SIZE], > >>> | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > >>> > >>> Fixes: 79465e0ffeb9 ("drm/dp: Add helper to get post-cursor adjustments") > >>> Signed-off-by: Kees Cook > >> > >> Using DP_ADJUST_REQUEST_POST_CURSOR2 has been deprecated since DP 1.3 > >> published in 2014, and Tegra is the only user of > >> drm_dp_get_adjust_request_post_cursor(). > > > > I see POST_CURSOR2 is used here too: > > > > drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c > > > > Looks like we read and parse that in the admgpu driver without > using drm_dp_get_adjust_request_post_cursor. Right, and probably that could be switched to use it, but I'm not sure what the impact of the larger link_status read is. > > I don't have a strong feeling but I liked your original > patch a bit better. I'm not sure what it means when part > of a spec is deprecated. Once a spec is written display > vendors might implement it. We should make sure that > displays like that are always handled in a sane manner. Jani, Dave, any guidance here? I'm fine with whatever, but the current code is for sure broken. ;) -Kees -- Kees Cook