Received: by 10.223.185.116 with SMTP id b49csp8747872wrg; Fri, 2 Mar 2018 07:17:32 -0800 (PST) X-Google-Smtp-Source: AG47ELuUz0l6+jBaz9tJxlAnVUzgPEbzWpBaxRAGcb5Oh5YdHU/YjL+7lVaRTxHzD092I6hz01W+ X-Received: by 10.98.246.16 with SMTP id x16mr4582025pfh.81.1520003852128; Fri, 02 Mar 2018 07:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520003852; cv=none; d=google.com; s=arc-20160816; b=I2xT2EXw/+lzcxj9Xnm7tZmiWdRsXtt3oMemiRSNUUKwrHMXJB37/+/G4IKtVXJtfI vjt0iCjhDasNPHIYwzudkZAebPAfxAeqC59kAUe2c0oqHLM9riZKm+f8d3A1cw6tlROo dyMUk1veRhh8RrH5H620b/Nj4RnwbDBiUgGKRxKjYpzyTvGDGfxLJI8OYNtIV0/t1eNc lc85R/U+k5khrcU0BbM/ikTpD3FzUtWlK8qX34Rp4LKq6v1e5ZUpv4J7uVifl+yP/iCX 6LleiftpKefkXwFTRHaCoWTAQ/9MMwiZgt+3BlfraCCUJ88LLN8fDIcgxENdeUIcI4T+ qM6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=9UYW1Pi1zXP5Jdvc1FaCyICkEGDcXdP31MlL+svF1mE=; b=scO1wDW2hbXFtSsSy6dyV1FB2JRdFBJIsNtTFhVpp0pDYY+30X742CYT8lGrHHHnzN JRUMRnbC/REPvASm7OAIkL55nq5FdTUA6Ycrt/Kgu8R0PsTIa9xWl1rgiTZ9oTSW7bRY EL9fbsMrfEvVuyJRYovQn49+8t9L1f4TU3dfEUj1y4ABrZ64+qeQBefiOARZ7cUGJfL0 hu0PMynSQswlQ+VoYx+m+e85MXviIm3Pwq92KT/6J1oojcHO4EccfYfkhHPYkHynVq6n 5u4WMo9WYqbnbD3+dfxBQlBsm5Is7NC57miZSTwXfSmzV1ZEDN0Lu6zwrWnBv0u2uUCn WQmQ== 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 f19-v6si4879377plr.641.2018.03.02.07.17.16; Fri, 02 Mar 2018 07:17:32 -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 S1427384AbeCBMOo (ORCPT + 99 others); Fri, 2 Mar 2018 07:14:44 -0500 Received: from mail.skyhub.de ([5.9.137.197]:35620 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423184AbeCBMOj (ORCPT ); Fri, 2 Mar 2018 07:14:39 -0500 X-Virus-Scanned: Nedap ESD1 at mail.skyhub.de Received: from mail.skyhub.de ([127.0.0.1]) by localhost (blast.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id UevynL73MZt6; Fri, 2 Mar 2018 13:14:38 +0100 (CET) Received: from pd.tnic (p200300EC2BCAEE0019BE56079607C538.dip0.t-ipconnect.de [IPv6:2003:ec:2bca:ee00:19be:5607:9607:c538]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 289A31EC045C; Fri, 2 Mar 2018 13:14:38 +0100 (CET) Date: Fri, 2 Mar 2018 13:14:33 +0100 From: Borislav Petkov To: Seunghun Han Cc: Tony Luck , linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman Subject: Re: [PATCH V2] x86: mce: fix kernel panic when check_interval is changed Message-ID: <20180302121433.GC7406@pd.tnic> References: <20180228203131.3176-1-kkamagui@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20180228203131.3176-1-kkamagui@gmail.com> User-Agent: Mutt/1.9.3 (2018-01-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 01, 2018 at 05:31:31AM +0900, Seunghun Han wrote: > Changes since v1: add mce_sysfs_mutex according to review result. Ok, we're getting there. > arch/x86/kernel/cpu/mcheck/mce.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c > index 706584681a4c..bee0795a3b8c 100644 > --- a/arch/x86/kernel/cpu/mcheck/mce.c > +++ b/arch/x86/kernel/cpu/mcheck/mce.c > @@ -55,6 +55,7 @@ > #include "mce-internal.h" > > static DEFINE_MUTEX(mce_log_mutex); > +static DEFINE_MUTEX(mce_sysfs_mutex); > > #define CREATE_TRACE_POINTS > #include > @@ -2045,8 +2046,11 @@ static void mce_enable_ce(void *all) > return; > cmci_reenable(); > cmci_recheck(); > - if (all) > + if (all) { > + mutex_lock(&mce_sysfs_mutex); > __mcheck_cpu_init_timer(); > + mutex_unlock(&mce_sysfs_mutex); > + } Instead of chasing all the places which need to grab the mutex, I was thinking of grabbing it in all those functions which modify MCA behavior non-trivially from sysfs. And those are: store_int_with_restart() set_ignore_ce() set_cmci_disabled() And you've done that already for store_int_with_restart() and I think doing the same in the other two will address the issue nicely and in the simplest way possible. All those sysfs operations should be synchronized anyway. Please reflect that in your commit message too. The aspect about DOS is not really important because you need to be root to write those so if you have root, there are gazillion ways to shoot yourself in the foot already. > static struct bus_type mce_subsys = { > @@ -2132,8 +2136,14 @@ static ssize_t store_int_with_restart(struct device *s, > struct device_attribute *attr, > const char *buf, size_t size) > { > + unsigned long old_check_interval = check_interval; > ssize_t ret = device_store_int(s, attr, buf, size); > + > + if (check_interval == old_check_interval) > + return ret; <---- newline here. > + mutex_lock(&mce_sysfs_mutex); > mce_restart(); > + mutex_unlock(&mce_sysfs_mutex); <---- newline here. > return ret; > } > > -- > 2.16.2 Thx. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.