Received: by 10.192.165.148 with SMTP id m20csp85867imm; Thu, 26 Apr 2018 16:33:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoYTHsUzpl6a3a8nEpVxAzE8HSscXo2DrHx6t0NC51ch67PZ80ryXwvURYP44d1QjC156Ah X-Received: by 2002:a17:902:bf4b:: with SMTP id u11-v6mr72315pls.30.1524785605538; Thu, 26 Apr 2018 16:33:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524785605; cv=none; d=google.com; s=arc-20160816; b=RoAKhswSI9XNI/bWc/Gqv6ojbiSzRcth8kns5bTUym/Q+rPwDR4jnnaDG2YYf9y32p ggUJ2F5CYXSIkZAB4GFDIzqeTvcrOAl+I+Y81Lp1MqzZ8bc7FUsGzUHMU5HbRX0G4lS/ Nt+fWxsyAUJrVuZ2e1yJxBnFzoWv7nixQ28XHhTH2nU1c40K3jt0F5y97uVDQeTu+Erv WeR+wnpJxS1198kjJWaektXWZK0E4NEeaJtQ/uOJ+2/SRuAQxZ3hx9Cm2p5OCzK5WHOA fAoP07MGbXkLdjIKygv7CQ95ObQYt6C3PYhKSu4rA/ZNYLl/t7+F9f92kxh1q4nenJgC 9RmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=p0vTP4ISuRgdsl0g+J05CRSyfL1ENpsBorgeERf26l4=; b=eymCn5P2cAHKOQMDoO1YbPYWajNp7W2a/ucHsZNlQj54xSLeF7nfO7XNjGZ4vrM79P e+NVLKK5SBh/xZPehuqAstkd27E0p3/hP+AI1C8Krbs381RkxZRnaQSct4dIz7TLV3E3 A/Xzg5RH2XTTtIeRIDL/C4neN6p1/05KSgf/DcuUsx9q09EDHGHgBmPimYE8UGx2Bd5O hnCfDAWisGkQIQUnt7SZs2Cwk3dsBJ9+dH6zPH0tkEGtGFVOnQkRgvY6wgbMqGAaBTNv bMjlkCqcOv1VzzsPEYnjWQwyt3Di3HcA9SPToxJ7rx4P4/P8lZdGDFXcxcRkmVbC3lcH 9WDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=fjActD7q; dkim=fail header.i=@chromium.org header.s=google header.b=APE3AqXK; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z7-v6si10845pgv.228.2018.04.26.16.33.11; Thu, 26 Apr 2018 16:33:25 -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; dkim=fail header.i=@google.com header.s=20161025 header.b=fjActD7q; dkim=fail header.i=@chromium.org header.s=google header.b=APE3AqXK; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932170AbeDZXby (ORCPT + 99 others); Thu, 26 Apr 2018 19:31:54 -0400 Received: from mail-vk0-f67.google.com ([209.85.213.67]:34935 "EHLO mail-vk0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753763AbeDZXbw (ORCPT ); Thu, 26 Apr 2018 19:31:52 -0400 Received: by mail-vk0-f67.google.com with SMTP id h134-v6so43757vke.2 for ; Thu, 26 Apr 2018 16:31:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=p0vTP4ISuRgdsl0g+J05CRSyfL1ENpsBorgeERf26l4=; b=fjActD7qC4hO036v6UfAF8PXd3aRo70GfHmga0LPmHCib7080sp5nRDK/Sbc0JV/VR GuYw/SLgEXdrFtj1LYkA9g4PIOJXgsY9ujpZa9f6uh+x1PX0J29ujz5CgJd9D/hwWTLC 7mpJXKNYCgR5c+vnN++Q50O+MvGuSaTo8EIQlihnxhVdlngxrnQAiVOgsR/D0oea3VVv yMKbYxUCZLYK0ZO6LLWt0SZC83LQ0PJPAnN1hsVyEu95jhTe1ve+bxUrIpfOkAfDHYtv QLZsvvH/cv2MqGm4jkjoSUipPHsshV9wJfNEOxIYPKhtzm4pwaQyiCAQOEfZDlVuQO3z Q6lw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=p0vTP4ISuRgdsl0g+J05CRSyfL1ENpsBorgeERf26l4=; b=APE3AqXKH0vbL/QoGmhRKBNPh2TDok7/5HGMenDliJAR0vcwYOWTg4ORPdDP+O6G98 BUc350JUHPiBV15VcXFXDVCbj5zwvnEpMMa9TfuF7ylcvlVVym3MW27HBSlo1DaiG4PU pnqgF//AeojvIXlMsiGW0oo/jylwy6l3EBxiY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=p0vTP4ISuRgdsl0g+J05CRSyfL1ENpsBorgeERf26l4=; b=trZ6upbrMVvF7cir39sgYzdJ1yr6LTPUBIerf5o/+/UZFWqpPww087HHUQT1d9CSyU T/6p9jBH1RztiKCI3dCwVAsCAN71IHUlY5A2XdH1QSwvQtyh52XlRJfEH7WJaksdKXWl Z/sGUiPSHjNcKYSLYsQLtukAB6LEAhEKTS9d3aLu9wDKaC8hfqTDb24nUF3+HffHntUl u2s1ma9lF/cuhHQk+m8TjN9IQU1umhRA4+PPXlpGsACOOoCYG0lVaMaIUMgaLLimPE1v i9gaORZcHRM6L0+ZMiUFJg+cRECykcvRWMnYSYfh9S27VDZLgsgE8U4aEBAFCIkpk78a 4c6w== X-Gm-Message-State: ALQs6tAQ4NfvUMg97r3WjE6rE0JAK5n6a6DLhIEZeqdx6pIPEeRrVU6f 0gyXeM4b8H3hUi+IC1N8lQpchmf8Ik4EW8ntGjhequvO X-Received: by 2002:a1f:a8d5:: with SMTP id r204-v6mr44741vke.84.1524785511222; Thu, 26 Apr 2018 16:31:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.164.81 with HTTP; Thu, 26 Apr 2018 16:31:50 -0700 (PDT) In-Reply-To: <20180411044315.GA46144@beast> References: <20180411044315.GA46144@beast> From: Kees Cook Date: Thu, 26 Apr 2018 16:31:50 -0700 X-Google-Sender-Auth: Ygh3f9ZHoZRUO3BArPtm7p4JSJA Message-ID: Subject: Re: [PATCH] dm/raid1: Remove VLA usage To: Alasdair Kergon Cc: Mike Snitzer , LKML , dm-devel@redhat.com, Tycho Andersen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 10, 2018 at 9:43 PM, Kees Cook wrote: > On the quest to remove all VLAs from the kernel[1], this avoids VLAs > in dm-raid1.c by just using the maximum size for the stack arrays. > The nr_mirrors value was already capped at 9, so this makes it a trivial > adjustment to the array sizes. > > [1] https://lkml.org/lkml/2018/3/7/621 > > Signed-off-by: Kees Cook Friendly ping... can someone take this, or should this go via another tree? Thanks! -Kees > --- > drivers/md/dm-raid1.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c > index 580c49cc8079..5903e492bb34 100644 > --- a/drivers/md/dm-raid1.c > +++ b/drivers/md/dm-raid1.c > @@ -23,6 +23,8 @@ > > #define MAX_RECOVERY 1 /* Maximum number of regions recovered in parallel. */ > > +#define MAX_NR_MIRRORS (DM_KCOPYD_MAX_REGIONS + 1) > + > #define DM_RAID1_HANDLE_ERRORS 0x01 > #define DM_RAID1_KEEP_LOG 0x02 > #define errors_handled(p) ((p)->features & DM_RAID1_HANDLE_ERRORS) > @@ -255,7 +257,7 @@ static int mirror_flush(struct dm_target *ti) > unsigned long error_bits; > > unsigned int i; > - struct dm_io_region io[ms->nr_mirrors]; > + struct dm_io_region io[MAX_NR_MIRRORS]; > struct mirror *m; > struct dm_io_request io_req = { > .bi_op = REQ_OP_WRITE, > @@ -651,7 +653,7 @@ static void write_callback(unsigned long error, void *context) > static void do_write(struct mirror_set *ms, struct bio *bio) > { > unsigned int i; > - struct dm_io_region io[ms->nr_mirrors], *dest = io; > + struct dm_io_region io[MAX_NR_MIRRORS], *dest = io; > struct mirror *m; > struct dm_io_request io_req = { > .bi_op = REQ_OP_WRITE, > @@ -1083,7 +1085,7 @@ static int mirror_ctr(struct dm_target *ti, unsigned int argc, char **argv) > argc -= args_used; > > if (!argc || sscanf(argv[0], "%u%c", &nr_mirrors, &dummy) != 1 || > - nr_mirrors < 2 || nr_mirrors > DM_KCOPYD_MAX_REGIONS + 1) { > + nr_mirrors < 2 || nr_mirrors > MAX_NR_MIRRORS) { > ti->error = "Invalid number of mirrors"; > dm_dirty_log_destroy(dl); > return -EINVAL; > @@ -1404,7 +1406,7 @@ static void mirror_status(struct dm_target *ti, status_type_t type, > int num_feature_args = 0; > struct mirror_set *ms = (struct mirror_set *) ti->private; > struct dm_dirty_log *log = dm_rh_dirty_log(ms->rh); > - char buffer[ms->nr_mirrors + 1]; > + char buffer[MAX_NR_MIRRORS + 1]; > > switch (type) { > case STATUSTYPE_INFO: > -- > 2.7.4 > > > -- > Kees Cook > Pixel Security -- Kees Cook Pixel Security