From patchwork Mon Apr 9 21:06:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 10332009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B2ED36020F for ; Mon, 9 Apr 2018 21:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A64F328923 for ; Mon, 9 Apr 2018 21:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AD3228BEC; Mon, 9 Apr 2018 21:07:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id ADE8728923 for ; Mon, 9 Apr 2018 21:07:09 +0000 (UTC) Received: (qmail 30160 invoked by uid 550); 9 Apr 2018 21:07:08 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 30135 invoked from network); 9 Apr 2018 21:07:07 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JabFw4XiOs7FstGNqpfRhCpveZoXSN450e4MjJLUX78=; b=pAQM7oTG5zB8rLd4FRmBxaHSYOkf4TLDTCaHtnfZdlygIOFSbhrZWUFiZgDQGHWeNE wRACQmUdBU5PjX/QvIUs1JhdVwUIDWUlCXmuZN77X+oIgMTS7dnHVXu8qEReh8YxSfLf TW2Xg9k6XDQ6pFJZpBfEXn/FCXFtnrfuB2BoDzEcDhI/0m7SsauZiboZnMV/6qOtXJgJ 4T3RcU0eQkR/T80KhzBUA9pQAPl+ZQMJ/TS/Cdq9NT/KZeMHcsoLHIS+V0q31+Jfmrw6 jVGMr0Xv0QYFW2Tdu8eyEhwdr/sCVb6zw+3n+t3CItEoop6H1qUuNhm9gZ8WnHFcgVTc Ndhw== X-Gm-Message-State: AElRT7FKjUx1V5CYHomvfn73X0uBRJ1FpsuY+8mkQJvtxvN+DTwtage1 Mg47jDeB0bC2CKAuOHYBx/Kmkw== X-Google-Smtp-Source: AIpwx487YaYyDj7Bd8YK6j4Xa+i5d3tPZCIOIGunPUBOki/5VQh/XkxWmqt7C6N9Ws37LlWjZLPbBA== X-Received: by 10.101.98.90 with SMTP id q26mr26745555pgv.113.1523308015462; Mon, 09 Apr 2018 14:06:55 -0700 (PDT) From: Laura Abbott To: Patrik Jakobsson Cc: Laura Abbott , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, Kees Cook Subject: [PATCH] drm/gma500: Remove VLA Date: Mon, 9 Apr 2018 14:06:47 -0700 Message-Id: <20180409210647.3718-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 X-Virus-Scanned: ClamAV using ClamSMTP There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Switch to a reasonable upper bound for the VLAs in the gma500 driver. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Laura Abbott Reviewed-by: Kees Cook --- This was a little hard to figure out but I think 32 should be a comfortable upper bound based on all the structures I saw. Of course I can't test it. --- drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c index 84507912be84..3d4fa9f6b94c 100644 --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c @@ -429,13 +429,20 @@ static const char *cmd_status_names[] = { "Scaling not supported" }; +#define MAX_ARG_LEN 32 + static bool psb_intel_sdvo_write_cmd(struct psb_intel_sdvo *psb_intel_sdvo, u8 cmd, const void *args, int args_len) { - u8 buf[args_len*2 + 2], status; - struct i2c_msg msgs[args_len + 3]; + u8 buf[MAX_ARG_LEN*2 + 2], status; + struct i2c_msg msgs[MAX_ARG_LEN + 3]; int i, ret; + if (args_len > MAX_ARG_LEN) { + DRM_ERROR("Need to increase arg length\n"); + return false; + } + psb_intel_sdvo_debug_write(psb_intel_sdvo, cmd, args, args_len); for (i = 0; i < args_len; i++) {