Received: by 10.223.164.202 with SMTP id h10csp313699wrb; Wed, 8 Nov 2017 17:13:36 -0800 (PST) X-Google-Smtp-Source: ABhQp+T/UIjDjB6dnPJEtBcOm38wHBbCxecx3JeIwtTKx7g8OWc+YC3xcKS75giStRkBMXyiS4o1 X-Received: by 10.99.102.69 with SMTP id a66mr2191679pgc.346.1510190015986; Wed, 08 Nov 2017 17:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510190015; cv=none; d=google.com; s=arc-20160816; b=qkQskfjuU1P0yhP7jAF8P2zZOwFTJ38bi82hUViQb63GUEwb246hJA6eE/eWcn0h06 7NAdD6aV4P9O/7fuV9CFKW7jzmd2uifs28FdHgdunWVNORr9c7DymC2O1uDJtW6pmay8 yTOUj4x4cRajT9z2TmD3hJ8PtbRHglCxaKjS6vmnAwDp/0SMxydxAqFsWt6YAu/LJZRf SrE+VJ+GY0X5W71CJvmtJesQoG2PKvP0GUTMlYBkq5lWeVixfjky2tO/78w79Sg0q+AO OYHm3NV4FzzgbJz6sOduEvn9wraNxIylRbCi0ZY5ZjIyrDvl7p5KW3TATFS9Aym/whSI L+vQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=5vEPoYsFuJgnBZijYOrwAAQQGPWGrNu6vQZIgX18DiU=; b=jRq7OuoAmkXnR/DQA2/DvTxgq+hOMsMT6PhWGpEYM1liPD8uLYIMN0mi7wuWZqyJjx uMcClxSZtAqczkphnMN4lWw3233fUKb/+jx2kJW6Ir2Uhj37AmuN0o+62FBX/93baJZL DRN6CX+H60g1C89p+f2Kc13wMV5FVJYN7WMR9fDditb7CZ/Jro3bNTqFrTOKGAbmdFSW XyXfDc6vifu/D1wKdTlghuZgids5s4aRhKLeqqCyKWWEclRBe512oU+areSgFcwHmA9q x/fjk9GDwKJ+UXuk7jegbSAt9Ce2WHjAjT1cfb2shW41kgho9tQp7iYrwmMm+WmpJWvk pxPQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w185si4627492pgd.176.2017.11.08.17.13.24; Wed, 08 Nov 2017 17:13:35 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753296AbdKIBMb (ORCPT + 85 others); Wed, 8 Nov 2017 20:12:31 -0500 Received: from mga07.intel.com ([134.134.136.100]:44107 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752750AbdKIBMT (ORCPT ); Wed, 8 Nov 2017 20:12:19 -0500 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga105.jf.intel.com with ESMTP; 08 Nov 2017 17:12:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,367,1505804400"; d="scan'208";a="174028897" Received: from kemi-desktop.sh.intel.com (HELO [10.239.13.3]) ([10.239.13.3]) by fmsmga006.fm.intel.com with ESMTP; 08 Nov 2017 17:11:57 -0800 Subject: Re: mm, vmstat: Make sure mutex is a global static To: Kees Cook , Andrew Morton , Jesper Dangaard Brouer Cc: Dave Hansen , Ying Huang , Vlastimil Babka , Michal Hocko , linux-kernel@vger.kernel.org References: <20171107213809.GA4314@beast> From: kemi Message-ID: <21613176-f893-d54b-b72a-f1d13c6bc2a7@intel.com> Date: Thu, 9 Nov 2017 09:10:16 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171107213809.GA4314@beast> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017年11月08日 05:38, Kees Cook wrote: > The mutex in sysctl_vm_numa_stat_handler() needs to be a global static, not > a stack variable, otherwise it doesn't serve any purpose. Also, reading the > file with CONFIG_LOCKDEP=y will complain: > It's my mistake. Kees, thanks for catching it. > [ 63.258593] INFO: trying to register non-static key. > [ 63.259113] the code is fine but needs lockdep annotation. > [ 63.259596] turning off the locking correctness validator. > [ 63.260073] CPU: 1 PID: 4102 Comm: perl Not tainted 4.14.0-rc8-next-20171107+ #419 > [ 63.260769] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014 > [ 63.261570] Call Trace: > [ 63.261783] dump_stack+0x5f/0x86 > [ 63.262062] register_lock_class+0xe4/0x550 > [ 63.262408] ? __lock_acquire+0x308/0x1170 > [ 63.262746] __lock_acquire+0x7e/0x1170 > [ 63.263063] lock_acquire+0x9d/0x1d0 > [ 63.263363] ? sysctl_vm_numa_stat_handler+0x8f/0x2d0 > [ 63.263777] ? sysctl_vm_numa_stat_handler+0x8f/0x2d0 > [ 63.264192] __mutex_lock+0xb8/0x9a0 > [ 63.264488] ? sysctl_vm_numa_stat_handler+0x8f/0x2d0 > [ 63.264942] ? sysctl_vm_numa_stat_handler+0x8f/0x2d0 > [ 63.265398] ? sysctl_vm_numa_stat_handler+0x8f/0x2d0 > [ 63.265840] sysctl_vm_numa_stat_handler+0x8f/0x2d0 > [ 63.266270] proc_sys_call_handler+0xe3/0x100 > [ 63.266655] __vfs_read+0x33/0x1b0 > [ 63.266957] vfs_read+0xa6/0x150 > [ 63.267244] SyS_read+0x55/0xc0 > [ 63.267525] do_syscall_64+0x56/0x140 > [ 63.267850] entry_SYSCALL64_slow_path+0x25/0x25 > > Fixes: 920d5f77d1a25 ("mm, sysctl: make NUMA stats configurable") > Cc: Jesper Dangaard Brouer > Cc: Dave Hansen > Cc: Ying Huang > Cc: Vlastimil Babka > Cc: Michal Hocko > Signed-off-by: Kees Cook > --- > mm/vmstat.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/vmstat.c b/mm/vmstat.c > index e0593434fd58..40b2db6db6b1 100644 > --- a/mm/vmstat.c > +++ b/mm/vmstat.c > @@ -72,11 +72,12 @@ static void invalid_numa_statistics(void) > zero_global_numa_counters(); > } > > +static DEFINE_MUTEX(vm_numa_stat_lock); > + > int sysctl_vm_numa_stat_handler(struct ctl_table *table, int write, > void __user *buffer, size_t *length, loff_t *ppos) > { > int ret, oldval; > - DEFINE_MUTEX(vm_numa_stat_lock); > > mutex_lock(&vm_numa_stat_lock); > if (write) > From 1583511871298310858@xxx Wed Nov 08 15:23:21 +0000 2017 X-GM-THRID: 1583464692798994006 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread