From patchwork Fri Oct 28 05:10:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Miguel Almeida X-Patchwork-Id: 12079 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp627481wru; Thu, 27 Oct 2022 22:15:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM749PYqf/+NNCminSGtviVitGKBjrxnEcOP6GC4SGfPE4bRlHRI+ODg3eJ66zGmr84WKi+2 X-Received: by 2002:a17:907:d26:b0:78e:20c6:9f77 with SMTP id gn38-20020a1709070d2600b0078e20c69f77mr44355875ejc.243.1666934122568; Thu, 27 Oct 2022 22:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666934122; cv=none; d=google.com; s=arc-20160816; b=lNSAT0jGUduCN3K9X+x7bekKolNmPdg3sWqDUSbRUcFXBLu+MAvrZkvjcmWIHGp5WL /vW0PDCg62vim9ZLq9kWex2J3AUa/x9ExbY+xyiNvuHALT5nA3XbmCMmwA/j1X36fFQ3 L18P5KJ9v9IRc5Hi4NotFfqQML6ZaEdKA740Hr6rUgDe5p7mqd/l6BrW9jz0o4U1kETX dAZ4KYAKZbFNZJrWlDb07GOWZ8vxllQeGx3mTqvlhFfxi6TglbNKTw/5IVpvMulAWFRl tWLJZQ2kyNCtLH5QNfOVn9iqv8GolfieRoBvlTfcbEiN9gfF71/5yoq2azx3i/v2oH02 f4zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=EW5mS+GWU1SupYaIIjSXlUc0IhtqJK+50Uo45NdbWBY=; b=Ls3p91eT/ExyYVHtPLlJpL6oEXtos8Us1jwBlc3uDYllCwzD4E9M+R0i4tFcMS3aua 09Dc0OSuKXwSlXgrQYb3SAoe3FPyRB2NvqoBkPu64/oiFiMjPFOMTfY+M7UcVO2PJlr9 KuPfRjtgnoTOIMFVEzm/ZXMfzmLsMmebIAq77Ok9mF5iCCZLvBMi/cPT9VKdBqqhd28Q +4HtyYOQmoQxPtil+f0aVUXDe6W7Ka30OtROFMQt7S6dEsOjOB5OrVo6uVHc/4zwSCKY g2vhLwbd4Z7U77Bo0rDxt1QsKcpgavQpX9I7WFzOzXCSug+DFYdaa2dkmcS0LgjBIwfB TvuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=q6yImUxF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lr2-20020a170906fb8200b0073d9f16e5b3si3022962ejb.258.2022.10.27.22.14.59; Thu, 27 Oct 2022 22:15:22 -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=@gmail.com header.s=20210112 header.b=q6yImUxF; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229861AbiJ1FLX (ORCPT + 99 others); Fri, 28 Oct 2022 01:11:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229828AbiJ1FLB (ORCPT ); Fri, 28 Oct 2022 01:11:01 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8FB9DAC46; Thu, 27 Oct 2022 22:10:59 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id u8-20020a17090a5e4800b002106dcdd4a0so8851290pji.1; Thu, 27 Oct 2022 22:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=EW5mS+GWU1SupYaIIjSXlUc0IhtqJK+50Uo45NdbWBY=; b=q6yImUxFLTMfanG+izGED95xKf3LufN3J34sg6wfjnz9NMfpaYj8F4MEKJ7vWziSNY 37S4Gra4Kr3oQNfnmI7g6yZIwJyrIj3kgEXO5xxhpMKXRde+8/x8VdNxmtEyPPwlnFad Qi+G6D00gt+jSvM4/n2MeS2L2HLch255epOJ2r/83DrmquuGt2UTgZW+6ma/nLnHX0KO Vgjr14CKLyOenoWatMLS4VBRmwz8GpabUezC+w/LZgxkQKeaj/py+3bo6nlvDW2aIp97 ZNZ1zkT9kcQEy/DSvXKWzTAV73ZFeSvRR48bPpY/7C5UlAtlkJ2KIBqFYwKJDUJVu6OH KhMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=EW5mS+GWU1SupYaIIjSXlUc0IhtqJK+50Uo45NdbWBY=; b=YBN+Ti9Qc7duuAXwa9A2fXV/WdFJE1nOw7Au3BTrPM4OBHkfR/pSok5Nn0osrsJllr CLx+bIoKODlaA5vcH9YrNmN+DBqH6a3UdiYzpMNJuF9vIvoXJ+FNGNXTuEA/Z/oX0l02 LT6hngTTKZxjYgy2lnM2XxhVesXYzqLoDjNfWpCPqxcI7niLfbiIgbVy/cjFBrnYy3sP J3FVwAcyxnnVcq3T5oC8PpAy6OH4yGfiLl+hU8b55DiQJNuXW5LnqiHOCVl7zTFc82hS iEWY0+EoteMMegiyZVRKEBH1jVToKzvOUYS0hlKaZd3mnrBAxxeY4Wz7q1Fb3NKRB/W9 1M2g== X-Gm-Message-State: ACrzQf38B+huRaAogahorRTgODVchbjZ5DtLr0jta+z3EEvhrB4HUatO baYDLM/7IVODHSgZLNpuq/4= X-Received: by 2002:a17:902:ef43:b0:186:99be:2ee9 with SMTP id e3-20020a170902ef4300b0018699be2ee9mr12142176plx.148.1666933859072; Thu, 27 Oct 2022 22:10:59 -0700 (PDT) Received: from mail.google.com (122-58-209-93-fibre.sparkbb.co.nz. [122.58.209.93]) by smtp.gmail.com with ESMTPSA id 5-20020a170902e9c500b0018691ce1696sm2075367plk.131.2022.10.27.22.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 22:10:58 -0700 (PDT) Date: Fri, 28 Oct 2022 18:10:49 +1300 From: Paulo Miguel Almeida To: Alex Deucher , Christian =?utf-8?b?S8O2bmln?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Hans de Goede , Grigory Vasilyev , Paulo Miguel Almeida , Claudio Suarez , Slark Xiao , Rongguang Wei , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] [next] drm/amdgpu: Replace one-element array with flexible-array member Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747907114642745212?= X-GMAIL-MSGID: =?utf-8?q?1747907114642745212?= One-element arrays are deprecated, and we are replacing them with flexible array members instead. So, replace one-element array with flexible-array member in struct _ATOM_FAKE_EDID_PATCH_RECORD and refactor the rest of the code accordingly. This helps with the ongoing efforts to tighten the FORTIFY_SOURCE routines on memcpy() and help us make progress towards globally enabling -fstrict-flex-arrays=3 [1]. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/238 Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101836 [1] Signed-off-by: Paulo Miguel Almeida --- drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 10 +++++++--- drivers/gpu/drm/amd/include/atombios.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c index 6be9ac2b9c5b..6b5abf1249db 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c @@ -2079,10 +2079,14 @@ amdgpu_atombios_encoder_get_lcd_info(struct amdgpu_encoder *encoder) } else kfree(edid); } + + record += struct_size(fake_edid_record, + ucFakeEDIDString, + fake_edid_record->ucFakeEDIDLength); + } else { + /* empty fake edid record must be 3 bytes long */ + record += sizeof(ATOM_FAKE_EDID_PATCH_RECORD) + 1; } - record += fake_edid_record->ucFakeEDIDLength ? - fake_edid_record->ucFakeEDIDLength + 2 : - sizeof(ATOM_FAKE_EDID_PATCH_RECORD); break; case LCD_PANEL_RESOLUTION_RECORD_TYPE: panel_res_record = (ATOM_PANEL_RESOLUTION_PATCH_RECORD *)record; diff --git a/drivers/gpu/drm/amd/include/atombios.h b/drivers/gpu/drm/amd/include/atombios.h index 15943bc21bc5..b5b1d073f8e2 100644 --- a/drivers/gpu/drm/amd/include/atombios.h +++ b/drivers/gpu/drm/amd/include/atombios.h @@ -4107,7 +4107,7 @@ typedef struct _ATOM_FAKE_EDID_PATCH_RECORD { UCHAR ucRecordType; UCHAR ucFakeEDIDLength; // = 128 means EDID length is 128 bytes, otherwise the EDID length = ucFakeEDIDLength*128 - UCHAR ucFakeEDIDString[1]; // This actually has ucFakeEdidLength elements. + UCHAR ucFakeEDIDString[]; // This actually has ucFakeEdidLength elements. } ATOM_FAKE_EDID_PATCH_RECORD; typedef struct _ATOM_PANEL_RESOLUTION_PATCH_RECORD