From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id A0C9A6B026B for ; Mon, 1 Oct 2018 11:57:39 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id m1-v6so8171316ywd.17 for ; Mon, 01 Oct 2018 08:57:39 -0700 (PDT) Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id y186-v6sor104106ywc.360.2018.10.01.08.57.38 for (Google Transport Security); Mon, 01 Oct 2018 08:57:39 -0700 (PDT) Received: from mail-yw1-f47.google.com (mail-yw1-f47.google.com. [209.85.161.47]) by smtp.gmail.com with ESMTPSA id z130-v6sm2723965ywd.91.2018.10.01.08.57.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 01 Oct 2018 08:57:36 -0700 (PDT) Received: by mail-yw1-f47.google.com with SMTP id m129-v6so5708491ywc.1 for ; Mon, 01 Oct 2018 08:57:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20181001143138.95119-3-jannh@google.com> References: <20181001143138.95119-1-jannh@google.com> <20181001143138.95119-3-jannh@google.com> From: Kees Cook Date: Mon, 1 Oct 2018 08:57:34 -0700 Message-ID: Subject: Re: [PATCH v2 3/3] mm/vmstat: assert that vmstat_text is in sync with stat_items_size Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-mm@kvack.org List-ID: To: Jann Horn Cc: Andrew Morton , Linux-MM , Davidlohr Bueso , Oleg Nesterov , Linus Torvalds , Christoph Lameter , Roman Gushchin , Kemi Wang , Andy Lutomirski , Ingo Molnar On Mon, Oct 1, 2018 at 7:31 AM, Jann Horn wrote: > As evidenced by the previous two patches, having two gigantic arrays that > must manually be kept in sync, including ifdefs, isn't exactly robust. > To make it easier to catch such issues in the future, add a BUILD_BUG_ON(). > > Signed-off-by: Jann Horn Reviewed-by: Kees Cook -Kees > --- > mm/vmstat.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index 7878da76abf2..b678c607e490 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -1663,6 +1663,8 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos) > stat_items_size += sizeof(struct vm_event_state); > #endif > > + BUILD_BUG_ON(stat_items_size != > + ARRAY_SIZE(vmstat_text) * sizeof(unsigned long)); > v = kmalloc(stat_items_size, GFP_KERNEL); > m->private = v; > if (!v) > -- > 2.19.0.605.g01d371f741-goog > -- Kees Cook Pixel Security