From patchwork Tue Nov 13 05:51:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10679613 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 9302D13BB for ; Tue, 13 Nov 2018 05:52:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81C252A318 for ; Tue, 13 Nov 2018 05:52:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FFC92A3A1; Tue, 13 Nov 2018 05:52:21 +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 0826D2A318 for ; Tue, 13 Nov 2018 05:52:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48F456B028B; Tue, 13 Nov 2018 00:52:19 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 467396B028C; Tue, 13 Nov 2018 00:52:19 -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 357896B028D; Tue, 13 Nov 2018 00:52:19 -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 E7E916B028B for ; Tue, 13 Nov 2018 00:52:18 -0500 (EST) Received: by mail-pg1-f198.google.com with SMTP id y8so7366752pgq.12 for ; Mon, 12 Nov 2018 21:52:18 -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=jARXeZJp5qP7dOhf6T/Pc+WoCM4YnZkLLP7pm2cSN2M=; b=bMfnYdvRaYUKld+CCIzUtaeeliSrEKm9TJuJ6eGkkj9/zz6S1Ab6st3Qk7340ckQCr ofH9KwMQJMCJ82Kuq5U9kgsn2QroWvaMnkaZsx8i6mnxVZR4CGSs3F30W2VkPpk2kUns 5a5tt02nj+vHrus67tt6dtbKNA0CyOFfkYwNz+vHinGOr0HbH/EEVSngwU6/NkVGk764 L9cOOmMOcBIwT4QQJRdVwxCFxkDoS9o67+dX7hbxbQWVp/joVAWyVEP4kcUbbwleAwah vvbdi05ctclGAt6QqPvECEXk3VriuH0rSuEolpeMR4btHRe1aHQDyIQBYI+xbjxmx7uT y0Ow== X-Gm-Message-State: AGRZ1gK26UvX3BQDBXDtezxuL1olFxXdZ5HS+JA79CvL5DIuWludCDEC VE5hnVXuBF4GiqPZ/WYvV7zp/K4lLf/iLc1yP0oSFJnTRSt5FEWdY2MaKr3B0VXNf2+nz1H3gN9 iM3rDAc65LoH6XQXle8ZTD5KmvDnNaClF0cmx6JYxF4mcioYiLhBDTEPFl9JgbiqwUg== X-Received: by 2002:a17:902:aa4b:: with SMTP id c11-v6mr3495855plr.303.1542088338630; Mon, 12 Nov 2018 21:52:18 -0800 (PST) X-Google-Smtp-Source: AJdET5f3o51d4v26eysK02xTylU5kzoWdi/n2HXaOJ6zRO+Rv/mIVyBGc8bRhHfzR88XL55W73ny X-Received: by 2002:a17:902:aa4b:: with SMTP id c11-v6mr3495840plr.303.1542088338083; Mon, 12 Nov 2018 21:52:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542088338; cv=none; d=google.com; s=arc-20160816; b=dc6nBodsZhwt2HKdvtNf0i1kWzNhDb2knkjF+iTM2Wl0gGXd6Y9LNpgA3BlsD+FB/1 d33eEjFtu1xBWeYZ04daMnj2SABvqQYevGeQlzSzSMu7y12XB2cYNHVCYJsnadL1VJTi /79q+V5NgUdrNk4nzqIPxtZAH3tUPy7rk+VLcSat8s6VaUlt7nTJlBvy7V5SMnKONllU iibCRONdbi9qOJ++xac64ex4faorOjE+2rI5xKpZjO6A6R09eDgLIt7Fu/HvOD4E3z40 VbzVcTZ8SS6BBetsphebIO7OXFiw3dlfYtttAoNXe2pygBmWuRGzre3ICosruk+2ESI9 6rTA== 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=jARXeZJp5qP7dOhf6T/Pc+WoCM4YnZkLLP7pm2cSN2M=; b=QEnOZlhfYsvQdrn53pMEYqIBICKP+eSlilUTu0jjZZSxvyd3ahOKeTHGV3yQq9OJk7 D4F9ZA1D6jpoCqdoKz4Nkc2bz6r/XdbrPd6dF15kENuprsEvoV8XtDWndgWyqFM4umM4 PS0bXV2t8AjDerlSvUxMJf4T/PbpUbtBPdh3dCDiOoEjAPirTOsayBMZfQuRqrz048oL rcDabL4jEmKGI2E+KHBeQeLkk23oZwCqxLKk0Da2j8JCqxYw4DUrQZFnfaJgKnfhOxOu E8l8aVG1353Ys5wYXFpwx6gcGo307j+upwPgjXrp3Fy77vIePqtSxnxBgxNmoc6lqcn4 ky3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nXvhkx0J; 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 f1-v6si17328649pgv.468.2018.11.12.21.52.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 21:52:18 -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=nXvhkx0J; 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 86CBA2245E; Tue, 13 Nov 2018 05:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542088337; bh=Epzgz9r88xp5A2BHFVWE3DXRPqA8Ihl5VjdNLUz6VmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nXvhkx0JBpHQ6gO95XyWrxChHILNGe3hZ9mhOKPZujs60Taj3Z/sznUL2m8VanSP5 cQ/CuFFCovp0biRV/AJ999RXz6rbKu1zEGcA/3JCL+wp77VsZjz/aDFUxPMC2IlJpi XGGh88UMN6W3mgU/ksXa3MdWIhGnAbock9MuPND4= 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 4.14 23/26] mm/vmstat.c: assert that vmstat_text is in sync with stat_items_size Date: Tue, 13 Nov 2018 00:51:47 -0500 Message-Id: <20181113055150.78773-23-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113055150.78773-1-sashal@kernel.org> References: <20181113055150.78773-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 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)