Received: by 10.192.165.156 with SMTP id m28csp237366imm; Tue, 10 Apr 2018 20:38:56 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+8uWTaS4PhUIlSO/mwwh9aYnwltcfCzReJge0oC1MV5HM4nzRmZMmA1O0FX4A5bV8B/7OC X-Received: by 2002:a17:902:32a2:: with SMTP id z31-v6mr3254965plb.41.1523417936856; Tue, 10 Apr 2018 20:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523417936; cv=none; d=google.com; s=arc-20160816; b=M4LE0UFG8ElSlLYZPP3Qy6DrlIzsSRfnRvQgb/tNwK1YmUcCZYRqyBTeRy0ZN4TDEw uqCCDt8r0ld4YPpkXQ0QqO9p5DqugmUlVgLhfgM19KjE31eFDm4IDxxPTHoAftIgboxy TbBB1C0ae/phjoxfYqi4JzYPFBFhRPO/ddiioLzTY4ep3xnDuD4tUzc72yyGvoajapjk rwVLDCvyVMukE1nCZCBvHoGYZWgL7MqGp+dx8UPcf66G0DVZsyBchT4Ejvp/AsvXu9KP FnQGbSiVhE4vmK4M0Uj+YUp1ad2Y8xSUl8/ppVHf6PWM009tMW3F1mnDZ4gJTUzsvUII TL1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UVltaXvPEpAzzp4frEzWsci/0CLoGCfuso2MDjy8rzk=; b=lFnXTephiH0Pmrf/XmDlqG0Wrp/UnqZmaCkEtTtQkp63nZPDOqbiU02OvYexEPodf1 LEvgVRSj31tWNgOFucHGAZy/H5P7e4tcVQQnCGWS1cFPtbfDlZd6FoUdjnLmhTcDF9uL zjnTZlmQx1ab1XXuF0CA1ZZJf7RN41IRQAvbhikyVp3RIyKohwJ5/0DfJyg7+DnO1B+p tKOrGinrJbi6M5OdjrXlLY6AVFkY3dtkUDfjPhUOxYw+epoQrzngI/JjorOaAlRUZ4Ff sg392jc9zhWcO9XsDuY7HH2efidJV8FhVvtRNFmS1ay5SNrmVonv27J6fXSfZ5sTgi4c bziw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g67si170215pfk.90.2018.04.10.20.38.20; Tue, 10 Apr 2018 20:38:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753148AbeDKBEm (ORCPT + 99 others); Tue, 10 Apr 2018 21:04:42 -0400 Received: from mail-pl0-f68.google.com ([209.85.160.68]:44517 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751970AbeDKBEk (ORCPT ); Tue, 10 Apr 2018 21:04:40 -0400 Received: by mail-pl0-f68.google.com with SMTP id b6-v6so118435pla.11 for ; Tue, 10 Apr 2018 18:04:40 -0700 (PDT) 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=UVltaXvPEpAzzp4frEzWsci/0CLoGCfuso2MDjy8rzk=; b=bFjWq5KvFzxqh51IhOuoVYpIS0VjRkC0+Z2+z6BpsSaY2v9XctTgrio1sLv8110u76 19/aezWjVuh69XZR28PN6OsfWkKcOY+EfFhFfrMD31o/xXNn7eYuEWZ21YJi1DK0UoQJ edepXRsZCvMDFNLP5WBMyK56fpzlh2e34z3VXHam3MLS64E2qQeOXsiB70fAP+HFfcGX tKFZ8odIoy7X3LtPwocq/Al8aM4QEor4SwgoNzgYLAe5i+HjnJbgPq4neUPg5edkOJMg 0BJ39woPVX2qancl0dRtKycaZGBYB4WNVZdWCxZdjjxGkk72ayzHBSP9vKA8/8joFTu0 ylmw== X-Gm-Message-State: ALQs6tB/myIyYanvp0Yb+fflbWSCP1td9hZd1bG3r3Oe+TOKKcZ6Pt77 16Mm33jysyPJPes8hU/g1vbUnw== X-Received: by 2002:a17:902:bd4a:: with SMTP id b10-v6mr2660721plx.271.1523408680241; Tue, 10 Apr 2018 18:04:40 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc:4eb2:6dae:ab32:e5b0]) by smtp.gmail.com with ESMTPSA id g9sm8265455pgo.22.2018.04.10.18.04.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 10 Apr 2018 18:04:39 -0700 (PDT) From: Laura Abbott To: Karsten Keil , "David S. Miller" Cc: Laura Abbott , Kees Cook , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCHv2] mISDN: Remove VLAs Date: Tue, 10 Apr 2018 18:04:29 -0700 Message-Id: <20180411010429.18074-1-labbott@redhat.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There's an ongoing effort to remove VLAs[1] from the kernel to eventually turn on -Wvla. Remove the VLAs from the mISDN code by switching to using kstrdup in one place and using an upper bound in another. Signed-off-by: Laura Abbott --- v2: Switch to a tighter upper bound so we are allocating a more reasonable amount on the stack (300). This is based on previous checks against this value. --- drivers/isdn/mISDN/dsp_hwec.c | 8 +++++--- drivers/isdn/mISDN/l1oip_core.c | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/isdn/mISDN/dsp_hwec.c b/drivers/isdn/mISDN/dsp_hwec.c index a6e87076acc2..5336bbdbfdc5 100644 --- a/drivers/isdn/mISDN/dsp_hwec.c +++ b/drivers/isdn/mISDN/dsp_hwec.c @@ -68,12 +68,12 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg) goto _do; { - char _dup[len + 1]; char *dup, *tok, *name, *val; int tmp; - strcpy(_dup, arg); - dup = _dup; + dup = kstrdup(arg, GFP_ATOMIC); + if (!dup) + return; while ((tok = strsep(&dup, ","))) { if (!strlen(tok)) @@ -89,6 +89,8 @@ void dsp_hwec_enable(struct dsp *dsp, const char *arg) deftaps = tmp; } } + + kfree(dup); } _do: diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c index 21d50e4cc5e1..b05022f94f18 100644 --- a/drivers/isdn/mISDN/l1oip_core.c +++ b/drivers/isdn/mISDN/l1oip_core.c @@ -279,7 +279,7 @@ l1oip_socket_send(struct l1oip *hc, u8 localcodec, u8 channel, u32 chanmask, u16 timebase, u8 *buf, int len) { u8 *p; - u8 frame[len + 32]; + u8 frame[MAX_DFRAME_LEN_L1 + 32]; struct socket *socket = NULL; if (debug & DEBUG_L1OIP_MSG) @@ -902,7 +902,11 @@ handle_dmsg(struct mISDNchannel *ch, struct sk_buff *skb) p = skb->data; l = skb->len; while (l) { - ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME; + /* + * This is technically bounded by L1OIP_MAX_PERFRAME but + * MAX_DFRAME_LEN_L1 < L1OIP_MAX_PERFRAME + */ + ll = (l < MAX_DFRAME_LEN_L1) ? l : MAX_DFRAME_LEN_L1; l1oip_socket_send(hc, 0, dch->slot, 0, hc->chan[dch->slot].tx_counter++, p, ll); p += ll; @@ -1140,7 +1144,11 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) p = skb->data; l = skb->len; while (l) { - ll = (l < L1OIP_MAX_PERFRAME) ? l : L1OIP_MAX_PERFRAME; + /* + * This is technically bounded by L1OIP_MAX_PERFRAME but + * MAX_DFRAME_LEN_L1 < L1OIP_MAX_PERFRAME + */ + ll = (l < MAX_DFRAME_LEN_L1) ? l : MAX_DFRAME_LEN_L1; l1oip_socket_send(hc, hc->codec, bch->slot, 0, hc->chan[bch->slot].tx_counter, p, ll); hc->chan[bch->slot].tx_counter += ll; -- 2.14.3