From patchwork Mon Oct 1 14:31:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 10622233 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 CF00015A7 for ; Mon, 1 Oct 2018 14:31:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1907287F3 for ; Mon, 1 Oct 2018 14:31:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A58B929437; Mon, 1 Oct 2018 14:31:48 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL 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 48D3C287F3 for ; Mon, 1 Oct 2018 14:31:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C1CE6B0003; Mon, 1 Oct 2018 10:31:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 372BF6B0005; Mon, 1 Oct 2018 10:31:47 -0400 (EDT) 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 262366B0006; Mon, 1 Oct 2018 10:31:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id EB03F6B0003 for ; Mon, 1 Oct 2018 10:31:46 -0400 (EDT) Received: by mail-qk1-f199.google.com with SMTP id v198-v6so9602473qka.16 for ; Mon, 01 Oct 2018 07:31:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:message-id:mime-version :subject:from:to:cc; bh=lo30T+L0jKOEUuumNZUlyrTjSMT4efbRQ6bhsYSjJ7M=; b=WJS1KzsUE77vrHNEDBVu8bNpU+vJBYkR6RareQ4nGXJWp1KXrT64W0Y7OBA6jGvXck 8tLp5tVW2p/FbVsHpK/SW5qg8GVjAL/09MnuhFOV8CuM69Niz2Pc0bnE+rtVKvZgl22r jDBxnReR7AzhYto0lN2ZflqJym0Vh3v3EjehcWpToQ/aQtLZQshLn95SAc78fEHkrU+G gwnhzEo1znWsvzxxjaq3kLU0aoszL2WF6OkkuEgX05lyJPUQ4iyue8VbKVrkyE5ozSym 97p7nFMTBgkJRLF7hU/zVYMRBwXPMpnpFnAmQpgsvkNJRAPNlSvmC+Jn2826s9se8cwu miKw== X-Gm-Message-State: ABuFfoipucLYpQgZI92QJIYXxH0IWErtyHZQtGs6jYvM3gVkPTFzB8dv bX8nTyxIkQgUyVFBlAATueZ4zVRC/cHw3Ec1GdZ2C9mNqiFgqb/g+arKq6UGaMGhX1IrdMSb/fn ufriIHgvP/dV5v4G0GE8FhXlyB8Pv3bkilFoKai8SixM6MZ7nPu73NVRFIrv99y/gt8PaWmU0ml t1IqeJP2UgHL8AS+Gr+idcpmbuRjjRkoedEfLKzyVhC466I6+y3miyUqndQSHPh1dk2YJRbK/3s kfqdHEDnbXzxIx7h2l3SqRFYwxv4sepEPSkBEoGYFM2wD+iPWAnpJ+Lytg1n1uwrexUe9Lt22X8 G3ZSAZMcQbpXKBKrTOECSRld+F8oPS9zO6WPevfxVkTu5Jg453dSMDQbuH21Mb1LokwcULTetYP I X-Received: by 2002:aed:2647:: with SMTP id z65-v6mr8400298qtc.301.1538404306700; Mon, 01 Oct 2018 07:31:46 -0700 (PDT) X-Received: by 2002:aed:2647:: with SMTP id z65-v6mr8400263qtc.301.1538404306188; Mon, 01 Oct 2018 07:31:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538404306; cv=none; d=google.com; s=arc-20160816; b=TrQVeHtEGxc04lh7uKEguB6fXGodPegauxBLWnGLc10MobkbgNfbDqNL/6styv5Ufx 4eMi0TBx9u/2xwyxj8gtbJ+ikopJnYKfNam87Taqf2NdP3LJUbXlKdOJNSqaK9LRCsfD NDw45Iw0oBowtxkFtSoqgVhHPgSivs183MRRysm7Rp4F5fJAQ+FYIHxMWyQxe+ThbsoX 2KEXF+P0h6I5djq79Bfo5Q6ilX8YSEKBa6qsMRLd3aWxG2R4gY9v1C8GJSXr5CExz3iQ Y8Ib+sbYO8+eEl2opCWqx4h/uo5NlIWPVkTAXe7YD1/vzLgy9Ywuz1q89zv0pyFfDsMC cpVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:mime-version:message-id:date:dkim-signature; bh=lo30T+L0jKOEUuumNZUlyrTjSMT4efbRQ6bhsYSjJ7M=; b=x+JZ4IItCMbHt7tQlvOI+hoRRtpAoPKXZThfSmAO5PeT90CZeH2JWKT3CicU4g2PVT 3WV9h3LFcnBpoN3C6VAzb1DOJk8nBYDw8sssAMA4AtZRX4a0PwFGoz6vh+KuHtJo8Blp AOkJE02t0cpoiqBBNMycMNY8beA9X93sYhMcmI5qSInGlMZvff0Wc6OpgghtetXhNlrS MrzHGixVLMbyLHglDDPmy1RqSbJ30fNSktYjBsaTYQGfxNFPCmlvTNazUXREghrF+Rx6 DgJ5BSbyQO9kiPp4EXoI0tdqo/46QNlyuHC0i7bg62GmpRMn+1q8aE0HtMAbVvSdDnQP gtxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xb+1AOvQ; spf=pass (google.com: domain of 30s-ywwukcnwh8llfemmejc.amkjglsv-kkit8ai.mpe@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=30S-yWwUKCNwH8LLFEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--jannh.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id p9-v6sor7931528qtq.153.2018.10.01.07.31.46 for (Google Transport Security); Mon, 01 Oct 2018 07:31:46 -0700 (PDT) Received-SPF: pass (google.com: domain of 30s-ywwukcnwh8llfemmejc.amkjglsv-kkit8ai.mpe@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Xb+1AOvQ; spf=pass (google.com: domain of 30s-ywwukcnwh8llfemmejc.amkjglsv-kkit8ai.mpe@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=30S-yWwUKCNwH8LLFEMMEJC.AMKJGLSV-KKIT8AI.MPE@flex--jannh.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=lo30T+L0jKOEUuumNZUlyrTjSMT4efbRQ6bhsYSjJ7M=; b=Xb+1AOvQQpBKaygW2Du8kfFjRhPyKjJ8wuLVdnZC8pIl9dTO+9MP1PZ8qYBqnUlYP2 ANmlrSHuQimdFzle5kiDxWq7XEDo2NhXgQNqNSBMC+Nm2eXB2mx9JsBuGuug2gB61pKq NvsLHdyic65F+KbzKpV2/jkFK/eD3x1IUngxFlB+G9ke/9fiVH9ETCRfoWrH8sY3fKa3 cJeQSJk2KzWGeojyD3WnZqQvLF4m6FAnyFNFfkW5MEFfNRoY6axYj57L6ed89kjmamdX nEjW5dzlQ/HyeZ6hv9hSi3lAm6SEShiRSaMdm1lfYRXSvfmv1GJ5hSX34zogj1brtmjg NMpg== X-Google-Smtp-Source: ACcGV62XKdsU04hKi1IeWYEnaxMg9RS0p+NhwRUivFkyIWrJLKjes7E+Ws1B0zcKyU63V3usnJtKHKp0aA== X-Received: by 2002:ac8:1969:: with SMTP id g38-v6mr8488895qtk.40.1538404305793; Mon, 01 Oct 2018 07:31:45 -0700 (PDT) Date: Mon, 1 Oct 2018 16:31:36 +0200 Message-Id: <20181001143138.95119-1-jannh@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH v2 1/3] mm/vmstat: fix outdated vmstat_text From: Jann Horn To: Andrew Morton , linux-mm@kvack.org, jannh@google.com Cc: Davidlohr Bueso , Oleg Nesterov , Linus Torvalds , Christoph Lameter , Roman Gushchin , Kemi Wang , Kees Cook , Andy Lutomirski , Ingo Molnar 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 commit 7a9cdebdcc17 ("mm: get rid of vmacache_flush_all() entirely") removed the VMACACHE_FULL_FLUSHES statistics, but didn't remove the corresponding entry in vmstat_text. This causes an out-of-bounds access in vmstat_show(). Luckily this only affects kernels with CONFIG_DEBUG_VM_VMACACHE=y, which is probably very rare. Fixes: 7a9cdebdcc17 ("mm: get rid of vmacache_flush_all() entirely") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn Reviewed-by: Kees Cook Acked-by: Michal Hocko --- mm/vmstat.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mm/vmstat.c b/mm/vmstat.c index 8ba0870ecddd..4cea7b8f519d 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1283,7 +1283,6 @@ const char * const vmstat_text[] = { #ifdef CONFIG_DEBUG_VM_VMACACHE "vmacache_find_calls", "vmacache_find_hits", - "vmacache_full_flushes", #endif #ifdef CONFIG_SWAP "swap_ra", From patchwork Mon Oct 1 14:31:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 10622235 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 C0CEC1515 for ; Mon, 1 Oct 2018 14:31:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4196287F3 for ; Mon, 1 Oct 2018 14:31:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9778B29437; Mon, 1 Oct 2018 14:31:53 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL 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 339C5287F3 for ; Mon, 1 Oct 2018 14:31:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC38E6B0006; Mon, 1 Oct 2018 10:31:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C72C86B0007; Mon, 1 Oct 2018 10:31:51 -0400 (EDT) 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 B64DD6B0008; Mon, 1 Oct 2018 10:31:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f200.google.com (mail-it1-f200.google.com [209.85.166.200]) by kanga.kvack.org (Postfix) with ESMTP id 884336B0006 for ; Mon, 1 Oct 2018 10:31:51 -0400 (EDT) Received: by mail-it1-f200.google.com with SMTP id e9-v6so11262900itf.2 for ; Mon, 01 Oct 2018 07:31:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=T+vNiyeRevufR7J96mq+kMFO60t4fXRXaUYkEz8okrE=; b=iH81qG9tCFDKXftJNk94rleWZqZj34JSNjK+epmyIraIMzdWvn8NCzF1uwQuiIxKd2 hpoQN5MMzCB7ZIx1ml/xVMQc3zcKlH7fPFn8+sIU24y8BocLMHqfPORKCqR0zL/XVlyU HgNVPNzV+lkI4l/eIpodrniOcpf/IGBCl7BlxNpJe1TYCi2VykAzTMVCxGIl/3KXDoxP jozRpgu1QRGHZl219c/kxOLRdQfX15/HjkkIqnn5llcTtewtPVz6Jb086DSThJvpod06 TNQJPW6jmgbnG1d2HzZf7wYvnlgwYpL5qt7ybZ90jg5olWBXksXCDw0X0Jvz/LjrmLu3 wHxA== X-Gm-Message-State: ABuFfojvjjQcUKvTLa/ANwL5PLN3IpTYgt5+6ZAjbioRBWjrVn1t+NK3 IDZvqYkyTXPYCT8mGHl3zYzw3YSEyNUmawyUycEMkTbKlQ/4APCTOoECIpOXtIv0DX+fWCUV4In JPsQZ/SKCgonlQ6n8JERCzYxh/bqjICbNeZklRFnxhlt9KvOwSDugUGcjhiEkm/J1Fa32Irz+SR btp8Crjw1C3BUKRR97ce3eN0w4DrELhFZTtMO4BNZ/MxxGTmAOh/KaGp8jANOjYvNPeChf0hT7E 3WrfvG1VYHYxV47FHZsk2H+2FdvH0becw0lC0wKhs+wrotqukg3jO4vmpxNCUPn0I4fZEbbhkSt CyX7l8h5Ot9iywXN1rxXX+aGaICNRZ0s37ENDOGacp/9uJYrDSjeTyBV4Nc4gH00kOGhOBSTQJO K X-Received: by 2002:a02:3c01:: with SMTP id m1-v6mr8467980jaa.77.1538404311286; Mon, 01 Oct 2018 07:31:51 -0700 (PDT) X-Received: by 2002:a02:3c01:: with SMTP id m1-v6mr8467923jaa.77.1538404310488; Mon, 01 Oct 2018 07:31:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538404310; cv=none; d=google.com; s=arc-20160816; b=Qfu/rUIvBgDVF7DoGfqVlUKIFjmkpUhMiPcaMcp+APvWwfcvu/b6VZERFj23+boRdx oeNhfSh3598f1LimZwFeEAUStNYu130Zp7iuHjl8CyEXz0Ehwe+wGcA1j+tB8kQ1Gdft CkcZfHUxDrcUgPY+KBBSOKcU5MNBx5eXzgunllN5tZXdxxJMj4A8g2ENT06MoQ11E3nD RO+xPcN180+vbxwJrL92mhXm3+WhxV0SD9Ey5Qk11A0SV/7nfvteAABck5W4tkGGKc5O ZWfTY0HZbT9qyaB5A4+PD3UCMtlUqyMRDD9W2rgg+fL3qRLQB/W6lET/e4XcymT4cOuv IDQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=T+vNiyeRevufR7J96mq+kMFO60t4fXRXaUYkEz8okrE=; b=ppinA7CeiVTppVQH9ZCi8PEXl+otigMJfKxJLHe7MakuSo9QhSbP0MnTIR3jeaK7T/ AEDX1j2h3D50Wv+ot6LYE2jCfxP9im/JLht8Yk+Zpg/aCSrN6R+BYCwZRIDqfqv3hpWs 6k/Mnr9CcraZdZXThgb4cAmMB5YhVMKDjsETM7PZWvWsvPjRnEe1NTc+L4qbRUep47yW nMpQsyPTwFvW0VZAJEPmqgfvBouWVCpHwdLNjDLj4wHioQkiAtb7OV8i7OimmGRH31+s yuOPeXQgd23w32vX2odxn+AOhXwkieAoLEYCwW0lK3GiJ2mCJJRBby3nMZR/gWDR+zr4 OhXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fDPBxBzM; spf=pass (google.com: domain of 31i-ywwukcoemdqqkjrrjoh.frpolqxa-ppnydfn.ruj@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=31i-yWwUKCOEMDQQKJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--jannh.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id n67-v6sor2823144ith.51.2018.10.01.07.31.50 for (Google Transport Security); Mon, 01 Oct 2018 07:31:50 -0700 (PDT) Received-SPF: pass (google.com: domain of 31i-ywwukcoemdqqkjrrjoh.frpolqxa-ppnydfn.ruj@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fDPBxBzM; spf=pass (google.com: domain of 31i-ywwukcoemdqqkjrrjoh.frpolqxa-ppnydfn.ruj@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=31i-yWwUKCOEMDQQKJRRJOH.FRPOLQXa-PPNYDFN.RUJ@flex--jannh.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=T+vNiyeRevufR7J96mq+kMFO60t4fXRXaUYkEz8okrE=; b=fDPBxBzMxhaIalI0K0LqQdZYhtlABOiCTcPlz0lQ7xrWFwp7D2vsjCpveNBIJlEs4k NPep0Pf7YkFRF1xrhS5YTszhd8POnRuSAkC/SXOHT0BvGJBTGmJQbkjlaEiRT5XZ9Xk9 D2e9FALT6KkWqYoO+o3aoR2mRUGOsam3yGTgDwUE5ZgMc9obnyHhLiOmBCAat5dDKP3B sFxANq2kjx3gbyv6AYh0cKMn4gY41I7TmpfOaEtNGwrQvp7WGfj78EiD5c+2B+4uRgw/ IHacK+isgg8/F8irnjitNhAdJJGbxAF6UFxh3bsTuz2dhe0Rs1uTE9GPi2FTszyvFkVE EWfA== X-Google-Smtp-Source: ACcGV62aloHQHmtVw8uIrSmOwiG1hp2f7Sx2op66c6HPxuo+4gcS8xrUekQOY7TBHdocGDKbfr9VQolv+w== X-Received: by 2002:a24:400b:: with SMTP id n11-v6mr11257645ita.4.1538404310178; Mon, 01 Oct 2018 07:31:50 -0700 (PDT) Date: Mon, 1 Oct 2018 16:31:37 +0200 In-Reply-To: <20181001143138.95119-1-jannh@google.com> Message-Id: <20181001143138.95119-2-jannh@google.com> Mime-Version: 1.0 References: <20181001143138.95119-1-jannh@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH v2 2/3] mm/vmstat: skip NR_TLB_REMOTE_FLUSH* properly From: Jann Horn To: Andrew Morton , linux-mm@kvack.org, jannh@google.com Cc: Davidlohr Bueso , Oleg Nesterov , Linus Torvalds , Christoph Lameter , Roman Gushchin , Kemi Wang , Kees Cook , Andy Lutomirski , Ingo Molnar 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 commit 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED available even on UP") made the availability of the NR_TLB_REMOTE_FLUSH* counters inside the kernel unconditional to reduce #ifdef soup, but (either to avoid showing dummy zero counters to userspace, or because that code was missed) didn't update the vmstat_array, meaning that all following counters would be shown with incorrect values. This only affects kernel builds with CONFIG_VM_EVENT_COUNTERS=y && CONFIG_DEBUG_TLBFLUSH=y && CONFIG_SMP=n. Fixes: 5dd0b16cdaff ("mm/vmstat: Make NR_TLB_REMOTE_FLUSH_RECEIVED available even on UP") Cc: stable@vger.kernel.org Signed-off-by: Jann Horn Reviewed-by: Kees Cook Acked-by: Michal Hocko --- mm/vmstat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/vmstat.c b/mm/vmstat.c index 4cea7b8f519d..7878da76abf2 100644 --- a/mm/vmstat.c +++ b/mm/vmstat.c @@ -1275,6 +1275,9 @@ const char * const vmstat_text[] = { #ifdef CONFIG_SMP "nr_tlb_remote_flush", "nr_tlb_remote_flush_received", +#else + "", /* nr_tlb_remote_flush */ + "", /* nr_tlb_remote_flush_received */ #endif /* CONFIG_SMP */ "nr_tlb_local_flush_all", "nr_tlb_local_flush_one", From patchwork Mon Oct 1 14:31:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jann Horn X-Patchwork-Id: 10622239 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 9DDB41515 for ; Mon, 1 Oct 2018 14:31:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80B5A287F3 for ; Mon, 1 Oct 2018 14:31:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 74C7429437; Mon, 1 Oct 2018 14:31:58 +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=-10.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, USER_IN_DEF_DKIM_WL 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 03ABB29494 for ; Mon, 1 Oct 2018 14:31:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E06E6B0007; Mon, 1 Oct 2018 10:31:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 790DF6B0008; Mon, 1 Oct 2018 10:31:56 -0400 (EDT) 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 67F426B000A; Mon, 1 Oct 2018 10:31:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-vk1-f198.google.com (mail-vk1-f198.google.com [209.85.221.198]) by kanga.kvack.org (Postfix) with ESMTP id 3402C6B0007 for ; Mon, 1 Oct 2018 10:31:56 -0400 (EDT) Received: by mail-vk1-f198.google.com with SMTP id h81-v6so3725963vke.13 for ; Mon, 01 Oct 2018 07:31:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:in-reply-to:message-id :mime-version:references:subject:from:to:cc; bh=2hvtGSKHdeKtzaEluK19bI6gl1/nLVlUjXULRBajuLA=; b=VCCFrJ2WI2dS1YUGn8JVy2/UoglHP7MuUV7RU5gUag/RoqEN0EnrSWz0Bpn/ikmwiq dM1bABtb3COWJ/x2iz39vsXumiNvNLsC06hU9kqUXCmvRyu+1khwPIhbn5OoulRbl+7Z kXMwUBpDASClAcSdwbtPO6vVRe/FR8gP3eOXadmqL2fA2Ig1AcIKGXncwa4U0OL3jnOL cXzHhZ9kWpVFZpa4QRm6EBBfPc77Bgvo0IGS//kSM4r8L6fTJU3cV4KNaea81ERxE/Rx 4E6LalxPMDcCHsRCze7NMH6ZBs+LTdf7UaGKXfZ/MV5Pk0iJNdfsisfXS7FiAlatd2mq CQsg== X-Gm-Message-State: ABuFfoj7BP1T4iABBOcoMMyv09hTcSYnbNbAUEhO6Y6g+CPGsMolGQJ8 ybvXZUWqlpqJ+4Iy5Ok3Ho2uTz39HVW4GcxfkqsliQQp/eInU8zUslg9qScWgy7l4MWKestiRpN 1Hy7df3ZWlhrr7C2lXYKFc1L8UnCCg/jX4m0QtvfZ4PgkIi6b3zFdfUh8EaARcrnZjOI+UxWZX1 FLJrleheahXBQG14Dy2UeqED0zKpZr81/ixQuY2c6VKufGYWEvT3zPnGr1bScwr23jsNqUuNdLY gSKPuD0QnKaSB3vN3khJh5dMpRYowljRjicsHKy+8rMXh6nWgK4PMsbSDRghtf/cI56y/BX7WEG 0JaccSLzcviKC/u58Gxy6snyQxjqrP//z4i2nsHWCxHpWiVfRBOefyBm2wMpmZsL24LM8/FeHeX L X-Received: by 2002:a67:f809:: with SMTP id l9-v6mr819516vso.200.1538404315789; Mon, 01 Oct 2018 07:31:55 -0700 (PDT) X-Received: by 2002:a67:f809:: with SMTP id l9-v6mr819485vso.200.1538404315007; Mon, 01 Oct 2018 07:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538404314; cv=none; d=google.com; s=arc-20160816; b=HILG9LkdaAhDb6K19ipyb9ZwsDSnLaGeyYl49p1AzYigEhUX7zpt0WaDne2QP2UYv7 UPHmJUUpCC79vb7X+vGui4B4czM3z/wdWlIiuch6lGPidDjk/7EW/FAgfWbixyGuRTja KZJ2GhaYm/kJRzb2JYXcVrRlduZVzO1bg2154K1b1shgCFhSD31QgCWxe8EvhV83Re8g zpWIuqu7rAyAo9Rf/mfB2BpyguzcVvriIYoLZ89q9Jr1smIoWupBbDEG2ceVdHgSYJaP iVCXTiubd/t35FU4PxnCvUattcVL0rlxk/j4O6QcVVWltfDffCvWZ1kNy3d1KVS9DMxV GrMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:dkim-signature; bh=2hvtGSKHdeKtzaEluK19bI6gl1/nLVlUjXULRBajuLA=; b=vooWVEux2B7C5hRzTMIoS4PMf9JGgZtrc6knCy/x1kM9dosfnFRt2GlH2zCYfpBBKd vWGhnYszwE7QzJzISWqDHNTKdd2/vwPSlJK82XMJBg3WsbYsNy1SyIk89XkaMe9mGkNa V3TmkKSpbBtSR7/Z57sFnGI2ukQ5fQ9CSZBtSPzNJoAqFCXHYBQqEqrmvJsUHk5C5T1o BbnK8lBWl7PuoSvrH6zKCEdEiCsc4OfKXT3brbS5FKpB3/Ij7QOX2N2RcaVxU7UnzUjd LJ6lZyl9DIhgC6pUXkGkpyMzatL1sj0z8P+UhbeaWxX3Ukk2Jo9zcdiA3NzxbSsjouuk 7/Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WtHMkr5w; spf=pass (google.com: domain of 32i-ywwukcouqhuuonvvnsl.jvtspube-ttrchjr.vyn@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=32i-yWwUKCOUQHUUONVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--jannh.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from mail-sor-f73.google.com (mail-sor-f73.google.com. [209.85.220.73]) by mx.google.com with SMTPS id j126-v6sor276438vkf.17.2018.10.01.07.31.54 for (Google Transport Security); Mon, 01 Oct 2018 07:31:54 -0700 (PDT) Received-SPF: pass (google.com: domain of 32i-ywwukcouqhuuonvvnsl.jvtspube-ttrchjr.vyn@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) client-ip=209.85.220.73; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WtHMkr5w; spf=pass (google.com: domain of 32i-ywwukcouqhuuonvvnsl.jvtspube-ttrchjr.vyn@flex--jannh.bounces.google.com designates 209.85.220.73 as permitted sender) smtp.mailfrom=32i-yWwUKCOUQHUUONVVNSL.JVTSPUbe-TTRcHJR.VYN@flex--jannh.bounces.google.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=2hvtGSKHdeKtzaEluK19bI6gl1/nLVlUjXULRBajuLA=; b=WtHMkr5wiotVjm4EuJFrYgtdhEzgxnfAtIJhFGY9GtpLKjNhhH7SerElSPCQ5cbF32 E2aTKTOcgFWRIZ2oUv/+nQvlVddiJz7Wq25QAz0xS6qJcFqnnAInhoirC3WMXVKQ8X46 AUAnaoxN1Cgp6hSSOxkXiDEx2kROV1AvTXxeiYnrdDy5U3CBLRG0/wU0rcjib5iOls6l yUCI9ORtxKJ5UyyQ3plw8vngOkCXPTBn+CbQBR2U/1rBpwefqfnZLattvMpGiwYMsawO yWEMKgNvuVhlqbp+Y2hwC/BXPkAUF7oV6QENGQW3WvD9DFcZjRkCxg7nYV8Te+O0nSyi jBjg== X-Google-Smtp-Source: ACcGV6326NGtTg6+3muyaKUIBc3nXKsxG4Odz6EzbXoFZeOZM/92Vs93BYyT6J0Lg1uGZ+JI+uyTv9JyMg== X-Received: by 2002:a1f:b915:: with SMTP id j21-v6mr10294147vkf.13.1538404314735; Mon, 01 Oct 2018 07:31:54 -0700 (PDT) Date: Mon, 1 Oct 2018 16:31:38 +0200 In-Reply-To: <20181001143138.95119-1-jannh@google.com> Message-Id: <20181001143138.95119-3-jannh@google.com> Mime-Version: 1.0 References: <20181001143138.95119-1-jannh@google.com> X-Mailer: git-send-email 2.19.0.605.g01d371f741-goog Subject: [PATCH v2 3/3] mm/vmstat: assert that vmstat_text is in sync with stat_items_size From: Jann Horn To: Andrew Morton , linux-mm@kvack.org, jannh@google.com Cc: Davidlohr Bueso , Oleg Nesterov , Linus Torvalds , Christoph Lameter , Roman Gushchin , Kemi Wang , Kees Cook , Andy Lutomirski , Ingo Molnar 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 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 Acked-by: Michal Hocko Acked-by: Roman Gushchin --- 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)