Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753039AbdGFXwI (ORCPT ); Thu, 6 Jul 2017 19:52:08 -0400 Received: from mga11.intel.com ([192.55.52.93]:61003 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752882AbdGFXwH (ORCPT ); Thu, 6 Jul 2017 19:52:07 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,319,1496127600"; d="scan'208";a="989808450" Date: Thu, 6 Jul 2017 16:53:40 -0700 (PDT) From: Shivappa Vikas X-X-Sender: vikas@vshiva-Udesk To: Thomas Gleixner cc: Vikas Shivappa , x86@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org, ravi.v.shankar@intel.com, vikas.shivappa@intel.com, tony.luck@intel.com, fenghua.yu@intel.com, andi.kleen@intel.com Subject: Re: [PATCH 21/21] x86/intel_rdt/mbm: Handle counter overflow In-Reply-To: Message-ID: References: <1498503368-20173-1-git-send-email-vikas.shivappa@linux.intel.com> <1498503368-20173-22-git-send-email-vikas.shivappa@linux.intel.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 943 Lines: 37 On Sun, 2 Jul 2017, Thomas Gleixner wrote: > On Mon, 26 Jun 2017, Vikas Shivappa wrote: >> +static void mbm_update(struct rdt_domain *d, int rmid) >> +{ >> + struct rmid_read rr; >> + >> + rr.first = false; >> + rr.d = d; >> + >> + if (is_mbm_total_enabled()) { >> + rr.evtid = QOS_L3_MBM_TOTAL_EVENT_ID; >> + __mon_event_count(rmid, &rr); > > This is broken as it is not protected against a concurrent read from user > space which comes in via a smp function call. The read from user also has the rdtgroup_mutex. Thanks, Vikas > > This means both the internal state and __rmid_read() are unprotected. > > I'm not sure whether it's enough to disable interrupts around > __mon_event_count(), but that's the minimal protection required. It's > definitely good enough for __rmid_read(), but it might not be sufficient > for protecting domain->mbm_[local|total]. I leave the exercise of figuring > that out to you. > > Thanks, > > tglx >