From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751093AbdJVCuC (ORCPT ); Sat, 21 Oct 2017 22:50:02 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53572 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750736AbdJVCuA (ORCPT ); Sat, 21 Oct 2017 22:50:00 -0400 Date: Sat, 21 Oct 2017 19:49:55 -0700 From: "Paul E. McKenney" To: Thomas Gleixner Cc: Tvrtko Ursulin , linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Sebastian Andrzej Siewior , Boris Ostrovsky Subject: Re: [PATCH] cpu/hotplug: Reset node state after operation Reply-To: paulmck@linux.vnet.ibm.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-GCONF: 00 x-cbid: 17102202-0040-0000-0000-000003B6072E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007933; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00934615; UDB=6.00470794; IPR=6.00714881; BA=6.00005655; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017652; XFM=3.00000015; UTC=2017-10-22 02:49:57 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102202-0041-0000-0000-000007AB1134 Message-Id: <20171022024955.GA3521@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-22_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710220040 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 21, 2017 at 04:06:52PM +0200, Thomas Gleixner wrote: > The recent rework of the cpu hotplug internals changed the usage of the per > cpu state->node field, but missed to clean it up after usage. > > So subsequent hotplug operations use the stale pointer from a previous > operation and hand it into the callback functions. The callbacks then > dereference a pointer which either belongs to a different facility or > points to freed and potentially reused memory. In either case data > corruption and crashes are the obvious consequence. > > Reset the node and the last pointers in the per cpu state to NULL after the > operation which set them has completed. > > Fixes: 96abb968549c ("smp/hotplug: Allow external multi-instance rollback") > Reported-by: Tvrtko Ursulin > Signed-off-by: Thomas Gleixner This does fine with rcutorture, though it does not fix the lost (or egregiously delayed) timer problem that is still eluding me. Nevertheless, for whatever it is worth: Tested-by: Paul E. McKenney > --- > kernel/cpu.c | 5 +++++ > 1 file changed, 5 insertions(+) > > --- a/kernel/cpu.c > +++ b/kernel/cpu.c > @@ -632,6 +632,11 @@ cpuhp_invoke_ap_callback(int cpu, enum c > __cpuhp_kick_ap(st); > } > > + /* > + * Clean up the leftovers so the next hotplug operation wont use stale > + * data. > + */ > + st->node = st->last = NULL; > return ret; > } > >