Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp1750815imd; Sun, 4 Nov 2018 08:42:52 -0800 (PST) X-Google-Smtp-Source: AJdET5dqeuCNvqdzApqUDViqc6kbHBLVp6dOGte+jThXSThmnZuxEI6rQgivYo3oA+BSY9REZuki X-Received: by 2002:a63:ef47:: with SMTP id c7mr17537640pgk.386.1541349772541; Sun, 04 Nov 2018 08:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541349772; cv=none; d=google.com; s=arc-20160816; b=ejpwcpqV2WB5AW9CZH5FY1NbZknIwskh+nrYcK+bgwMcp6ayaFzrxMtmbSng0a4Lci iURZA6bHVwO+Cr+xuaOzt2kUfd/+0JbM7j4Zg6JHBV2S5PrqHUFLCjUh9R4I0TCeTTjA dIyBHnShV1u3qDhn3HTVXeTuGOr1qUM1RnrQCMBNWY0Xc/iXsq0GpCGBAvxE1TOoqaOu Wj00M9tMgl2pA0MaKsnSpanXoLe5Yi6hCLBIm1MdSvz9+d76cZaCdG1v70NViItDfjMv PwmjMUKOlC/ssPLRSPyoumF3j4CNSJiYnwnRlNWqaM1oNEuQOgAuXiLH87VZ7SAzZVm6 ZBbg== 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 :dkim-signature; bh=jARXeZJp5qP7dOhf6T/Pc+WoCM4YnZkLLP7pm2cSN2M=; b=wX14TTHD2tm7hAvYMLUTTjQkVt+KVxLiYJqOFWZjPYxghL1iRF2v5uIpoyEmzdxMd0 N/QUWeeBYEnJ/027jEGZ2PLmt215O80kAjteOiaDbSe9lkQyzY3muGR7UWpvBBObJrcX 8gz7N4Ia3SslSs+OS36lWUJ6l9dMmMneAGvjQQMLss1WMxNbfD4f4dPS6l8JDQybCg/O y61S2ZpOGsNCsL2dQ29teXseJilzKIOTzjbz8UuynpYsUO/i9xpU2VhG4N5xFHQ94ksX 0AoHJMjAlnhVmjhOXVaKvq1d7ykqrXfTW73PfK4C3Iy4VOBVYTLrJHs05IdLttTl8l3U 4srQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iEKtlIAJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u91-v6si30800618plb.180.2018.11.04.08.42.37; Sun, 04 Nov 2018 08:42:52 -0800 (PST) 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=pass header.i=@kernel.org header.s=default header.b=iEKtlIAJ; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731143AbeKDXId (ORCPT + 99 others); Sun, 4 Nov 2018 18:08:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:47306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729652AbeKDXIc (ORCPT ); Sun, 4 Nov 2018 18:08:32 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (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 DD39C204FD; Sun, 4 Nov 2018 13:53:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541339608; bh=Epzgz9r88xp5A2BHFVWE3DXRPqA8Ihl5VjdNLUz6VmI=; h=From:To:Cc:Subject:Date:From; b=iEKtlIAJAH/MarZ4ebcHvs2ar51UUdOzSXHf1eV9+xCKO775p+bd0BqYF17IHvp82 QatkMb9H9j4J2JZBvjRvpE4yhhkWfR5uitOolxD2taFbeDSGqIkDisq51yHp6ujhD8 f3Ffw11NV2NWFXH3XmLWe1Aj+gusrhUjH3MR/JdE= 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 Subject: [PATCH AUTOSEL 4.14 01/30] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size Date: Sun, 4 Nov 2018 08:52:56 -0500 Message-Id: <20181104135325.88524-1-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 527ae727d547..d7901f1691a8 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1630,6 +1630,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.17.1