Received: by 10.223.185.116 with SMTP id b49csp69747wrg; Fri, 2 Mar 2018 13:50:23 -0800 (PST) X-Google-Smtp-Source: AG47ELu1eQuQ2rq43qF2ytxH7oleak80yBT0ucPrGRrCw4makV/zMQ8s6wUJoEJWDaBjqN/rpwah X-Received: by 10.99.116.70 with SMTP id e6mr5611557pgn.256.1520027423033; Fri, 02 Mar 2018 13:50:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520027422; cv=none; d=google.com; s=arc-20160816; b=M5n4yivEyAk2mTl+lCJGASJAQ0b4uGI9TMkbluY+v20EZYGBcVGxXXpM7Su+8OaMUi lzNhyOLWdUmYQ/Y3uZGtC+QPT5O/qURoUbY57qTNRMqBFjnpyYU7amHI/hyZKJ9gaZAX aV/A6fo/tXZJvgdv7Wpn4PfvP9QsKczOHrmYilYj9LmjuSpLFg8RSB12gWSCe1M4lklL X4xNyFZKfF+FPswuY3tIaRw0WOZlN5Mvgb3RgN9Lss2z9MzLZybUKYAGty6YHpnt1adz in7KIgTQ6QvOPSfCiDLG3CGgjKycbBeUGBf+5nsPy7GNqDkzIUuK2ptc7UY9N3o/nKVC YfkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=P5C8hLkYRiC6MwFPp1AZiOsifMW2DtEoqsQsG4zW2bU=; b=TdGB340rc8szrxH+6PJ2R27s8IlJFvtHjES8/BGrQ4kqUXKzGBwAk5DQ+WIfvINX/x UYpBxzo+7/c2Wwe7cOiX+o7VYqf3LL8lU3G6/yOt7LMhPmTcczM72f6up0NN6+6PxjQM H19tVSMU/+7QBeAvJ30EKU1KMoYs3rKckOo7UjlL5NpkzHsKhlsCaiFPzZAQPCa9044D lNKumHAFr8oa2tx5oumkVmB/B9gddGlOXZLqOMhC4P4/AGr5gLEw+x0GILjWmLd20u5q zu/tI4qrP22kke0uA0BQbB895ohhKspLxLKKYRT2B5tahAQBUzZUN29u9JiVVYcrjhNC t8lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FVOBWWx5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n6si4466359pgc.801.2018.03.02.13.50.07; Fri, 02 Mar 2018 13:50:22 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FVOBWWx5; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932815AbeCBU35 (ORCPT + 99 others); Fri, 2 Mar 2018 15:29:57 -0500 Received: from mail-yb0-f193.google.com ([209.85.213.193]:42369 "EHLO mail-yb0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932546AbeCBU34 (ORCPT ); Fri, 2 Mar 2018 15:29:56 -0500 Received: by mail-yb0-f193.google.com with SMTP id i13-v6so3787666ybl.9; Fri, 02 Mar 2018 12:29:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=P5C8hLkYRiC6MwFPp1AZiOsifMW2DtEoqsQsG4zW2bU=; b=FVOBWWx5gBM5ZStVnSD54T5KuDoAsmzJm0GmVImEADzq+Onode+cMzSrgSxTgYTfTA kSF1d3GodC6LGIQKx/kDREVUs6gUny8gS2rhQ/cYk0NXmY0aNNgMdzoTVgLXTkjix/En C/9TnM70feKm7HDojNmEWON/gjHuZisPjyv8xgqF2dqTb90O281+pcHJIsUWzbfJxJGj WrRtBHDlBoSA1upW0TJBoA8AELMW1YhTnwhhjiJCMQDRoOXv5uaziiyJOvcxFbDxRTbR UGUFOIPAXv4OMppBGU8aygRfQwCKSLYCud9A9saNxQSVqsLTXJIWDa/XFKByA5airbqt oP/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=P5C8hLkYRiC6MwFPp1AZiOsifMW2DtEoqsQsG4zW2bU=; b=dN9jkKeNHe/4aDVoef1dRC45zqoW01YCTAIAqJd1WchNLxMYfqPZGJ+h46Tg8EYz7v LjbqnoFPvpyd26iQtrZwv4PR7tf/sTB98X/M7RVi0kpGQx34EbhMhfDXDphwx4M4mhth qNIueNfQUQKdz+xCv/OBljNNM16BPAfH2YSIyEb2AADgRq+Dbyt0us5mJ7KOpnlSGZYD 66Uj8kvZTmBwqlg/1655Rw9OQCjzNGayVR3QIz4k5sfvnueWbUF9w1Wtx4Cf+9yQs7Pi 89ZlE/ZCxGturC/V4QaOGnvnBmcf1WLmDrW8ZOwbdnO5vqMPyloX6AFbuyBLqBS/Q3o9 FDrQ== X-Gm-Message-State: APf1xPA1Gp+2lHFEh726w6GVSlZXchEWQIc7gwVrtAb9te7/5I8QcZA/ p9QSz4uH1eSufBeU6tfW+kqwYCMMHm8h6CdfvY8= X-Received: by 2002:a25:8b0b:: with SMTP id i11-v6mr4625122ybl.213.1520022595151; Fri, 02 Mar 2018 12:29:55 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a25:b98d:0:0:0:0:0 with HTTP; Fri, 2 Mar 2018 12:29:54 -0800 (PST) In-Reply-To: <20180302121433.GC7406@pd.tnic> References: <20180228203131.3176-1-kkamagui@gmail.com> <20180302121433.GC7406@pd.tnic> From: Seunghun Han Date: Sat, 3 Mar 2018 05:29:54 +0900 Message-ID: Subject: Re: [PATCH V2] x86: mce: fix kernel panic when check_interval is changed To: Borislav Petkov Cc: Tony Luck , linux-edac@vger.kernel.org, Linux Kernel Mailing List , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Borislav. Thank you for your good advice. According to your advice, I will make and send PATCH v3. Best regards. Seunghun. 2018-03-02 21:14 GMT+09:00 Borislav Petkov : > 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.