From patchwork Tue Nov 13 05:52:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10679631 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E78B713B5 for ; Tue, 13 Nov 2018 05:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D52882A1B7 for ; Tue, 13 Nov 2018 05:53:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C90DF2A264; Tue, 13 Nov 2018 05:53:06 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5348C2A3B8 for ; Tue, 13 Nov 2018 05:53:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C7C06B0298; Tue, 13 Nov 2018 00:53:04 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 59C816B029A; Tue, 13 Nov 2018 00:53:04 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48C656B029B; Tue, 13 Nov 2018 00:53:04 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 06C0B6B0298 for ; Tue, 13 Nov 2018 00:53:04 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id s22so7362940pgv.8 for ; Mon, 12 Nov 2018 21:53:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=43H+vSwoPdZ3Ca6RR2vTlJkeEWlKWubdnl2xI/rhar8=; b=DuH+jgKL3Jv2dQUkFDRpREZMB/erGi9wta8BciuzXIUHVQah5d1zomLOL/2/bpbPcM 1y/qiRzp2UwXti0OIoCq2nz/Q/QwmKWJSX4NejeXk2n1N6NPYa+Bc/Oiay4qMcwFijdK GzU7FzEgD9tOVOLb1Vh1LnyGjNok4Ap+EW9NDI1VMUavjM//fqUYfdBvKITbpu7NrNqp /YI6TQ74iSlZcdWqCzY3IXIfgHg3muXvvwc45ypBm7DIDXXALCRwyn2oC9cW6TtcCcoO KYdjVBALwAoALhED20u0Xf3gRe5iIxp7GJk3oCCDxo8odr9We9pFGdl96BT9EJ+we7oD Ek0A== X-Gm-Message-State: AGRZ1gLOIqo40RGYXP579yFp+kU4abcloJKvjchL8t7+O1oMasYtyQO0 NspByMR2+3SHzUJavGQjQSpm5YtnhKQdrvIzDlKXIl7W1HNMUkevB6jXsIganFvFQoHtCTqTuo1 edsCG8nJ1SNcVYsj5W2/EgcTmJM/hKkyrJC671sLhlCqQ2VKHIZGRm8jmjdqp5eIw1w== X-Received: by 2002:a63:801:: with SMTP id 1mr3470837pgi.275.1542088383709; Mon, 12 Nov 2018 21:53:03 -0800 (PST) X-Google-Smtp-Source: AJdET5fRd1WlvEHV2uYCPaJ7GzPShLqTYClgUjKkBs49kwTN0EGAhoFPDMkMzE4Rc9KVAst+sflp X-Received: by 2002:a63:801:: with SMTP id 1mr3470813pgi.275.1542088383165; Mon, 12 Nov 2018 21:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542088383; cv=none; d=google.com; s=arc-20160816; b=T1cAhKQ5VSj+QQ6QMaU6Pzh1n7neTqZ2RPB91iv1Gr00Hg6kORRJrAj5SKd+Ugkr+/ whQuUGmDU2KJ5U5VRsM2yndD1wZtSuGEZnrqtHTGWjVJy3QunMANkyPJPhgVt/X0Le7M s717uhM3JNUepZ/JS/I4p9R7ti7z9t+LPUU2+4tW0zaVbZeG9nAs8CRNfRSDWP1Vp2f2 PVMrUjTaxxJEo+tNhwW+K/97y0e8t6wiV2rEZHnL8NRzX30CS8DGntzikv2bFKOToEFG TYCJU2yzXWumaM4yfZaQNhcBY9rF4wUEICqEVOE7b4D84mqWrVczIdcrsLz7VhiwPslM JKzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=43H+vSwoPdZ3Ca6RR2vTlJkeEWlKWubdnl2xI/rhar8=; b=zfTj++qs6knJ7Rn/lxpzdBJFisZX95EF4ZiC/c/Bww6L1Hgp4u1L1ALc/seYoLyrlC Vev7r8uNQCQaIBuOiP62mcqzPofzTUw1YFxb8DQzKhKM679VcucEYUyHPqawSR/WWfHr bEk8iG3tnlffdVhesC/POTHgCgOx0/MqwlOlozgkwqVlvybOqypf9f03/yEb0Eq9RPyq Zz6kiR5yYthIKyAhuAS2rqHpFg10hWUfIA28Xbac3T2d8L9N5UaLGB56Er9kppr/9jwg nv+sU+LK7X5MrokuAH2+yjf/5ENKg6mN5s9F4Re3gVjMK7FhzBALRdV3AJgc66quZNlL 9A7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wENKVCZx; spf=pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sashal@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id d12-v6si19483428plr.92.2018.11.12.21.53.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 21:53:03 -0800 (PST) Received-SPF: pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wENKVCZx; spf=pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sashal@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A3CA622507; Tue, 13 Nov 2018 05:53:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542088382; bh=weim4VNF/C0H5P3/9xMGZYWf+JMRIgw+BbVRuoAmgXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wENKVCZxHQOv0nBNj9pncQ3qPQblUEs24IYK7LdX79xIqm/sbYVSMMM6NyzJIyOoY NGObJ2orZK1Ta4oyFHtNdGZzMX+5vlgTRb2jp/ESSXRFCL8Lue+x0YjJFt4t31TaGq tjrW5QbIXwbB7W1ny5xI/a2LrXoomolCkmMRnjaY= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jann Horn , Davidlohr Bueso , Oleg Nesterov , Christoph Lameter , Kemi Wang , Andy Lutomirski , Ingo Molnar , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 3.18 8/9] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size Date: Tue, 13 Nov 2018 00:52:51 -0500 Message-Id: <20181113055252.79406-8-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113055252.79406-1-sashal@kernel.org> References: <20181113055252.79406-1-sashal@kernel.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Jann Horn [ Upstream commit f0ecf25a093fc0589f0a6bc4c1ea068bbb67d220 ] 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(). Link: http://lkml.kernel.org/r/20181001143138.95119-3-jannh@google.com Signed-off-by: Jann Horn Reviewed-by: Kees Cook Reviewed-by: Andrew Morton Acked-by: Roman Gushchin Acked-by: Michal Hocko Cc: Davidlohr Bueso Cc: Oleg Nesterov Cc: Christoph Lameter Cc: Kemi Wang Cc: Andy Lutomirski Cc: Ingo Molnar Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/vmstat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4590aa42b6cd..792374f7088f 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1189,6 +1189,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)