Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3707880pxf; Mon, 29 Mar 2021 09:14:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvmgKvOPYzWEwpKHSk+fknbKMYBkX0tBSh4moBjo0xaYolmJid5u+vdbeMfAFJ4TrZi8gb X-Received: by 2002:a17:906:aac5:: with SMTP id kt5mr29851508ejb.548.1617034480874; Mon, 29 Mar 2021 09:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617034480; cv=none; d=google.com; s=arc-20160816; b=WMYN0SivPpBVYqo5inCm2eRuDq8DqTFbaj5jO8DSYlDcIZIhlzNnXnGbfS6BT190FI N8eQ3Jhy/FpWnxqv+uW7fkW9NyQ/x6PA6SYmbuE5wx8VhjL6VjxqmvSpc76rJ6+onBp/ mQorsvbdk2qYGGmtax16pkBXNUhkY1OlHlp8IldSoYTkVKO+GGCYdOsgOPnM1jnlcNnk C9a8b4V3hTsxZBKatwbVJCRndKwxlxHt2SMmbot34pX0bbSIZeoCv4KcyAgxYVsGedND 8u0yf4Dofg0rlv2W5wId6sIG7xJQPy7mECoO3Aur3zsHXInny0qwI9oo773fdEQcDTTF 8l/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :dlp-version:dlp-reaction:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=L2vRNOrXo3CDuZ4tzcLAJ0YzrXhx2gPHszsAo6ixezQ=; b=p6uqQzJ0PmfFatNVnu+dT6Q2vBB4bBTshdmOOYbyVCn7KAf27jnTF2M2mbU7ldYAhF iFzCBXq9XlCpnTLF548XGpiu0daS18XEtIsfiR6ROZ4o3YGaR4qOMtFSMpB9atn51Y5V YkjU+0yTjkc7vW9d3XLl25NFdA7N2D2gXh4YFVIhD1NylTmZ3I8x/Yah7WQYwQ5rERRD FlmfDNWA3uNhQWXWXqv+klWxm3AMOBKVOw7H8BIyjp4rR4HjTibm6mxbB5jz8YnEh4gb ZUYzUX+/67wD1r1pmU28sZ7ofBmVMQ5TuK+lJfAFMUeGq0gQMBDUAGQQh37Tkw9IuOCr DqYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id be2si13317847edb.153.2021.03.29.09.14.18; Mon, 29 Mar 2021 09:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229479AbhC2QMr convert rfc822-to-8bit (ORCPT + 99 others); Mon, 29 Mar 2021 12:12:47 -0400 Received: from mga11.intel.com ([192.55.52.93]:52406 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230362AbhC2QMV (ORCPT ); Mon, 29 Mar 2021 12:12:21 -0400 IronPort-SDR: BDhejDPbmdXwwlp3p2IQOWnQR69O2wwfhPzF/W4NojeH7cNnWsRXN5f7CT1LCT0Qb77Uhwney0 xqxZxyhnDdKg== X-IronPort-AV: E=McAfee;i="6000,8403,9938"; a="188311718" X-IronPort-AV: E=Sophos;i="5.81,288,1610438400"; d="scan'208";a="188311718" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2021 09:12:19 -0700 IronPort-SDR: Ywc2bagZ1nzzoME6LaH3jnzZ1I16yUvRE+5CK+GulRa/bf8ymgaHUvA4Kie3og30AEuRfYQOSc StATGDkHWnAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,288,1610438400"; d="scan'208";a="454618452" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga001.jf.intel.com with ESMTP; 29 Mar 2021 09:12:18 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 29 Mar 2021 09:12:17 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 29 Mar 2021 09:12:16 -0700 Received: from fmsmsx610.amr.corp.intel.com ([10.18.126.90]) by fmsmsx610.amr.corp.intel.com ([10.18.126.90]) with mapi id 15.01.2106.013; Mon, 29 Mar 2021 09:12:16 -0700 From: "Luck, Tony" To: Yang Li CC: "bp@alien8.de" , "tglx@linutronix.de" , "mingo@redhat.com" , "x86@kernel.org" , "hpa@zytor.com" , "linux-edac@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] x86/mce/dev-mcelog: Fix potential memory access error Thread-Topic: [PATCH] x86/mce/dev-mcelog: Fix potential memory access error Thread-Index: AQHXJIDSM+kFcRvHZ0aVR9xYGcvpeqqbIiLg Date: Mon, 29 Mar 2021 16:12:16 +0000 Message-ID: <745eaeb668bc43deb8eb7db7a3342691@intel.com> References: <1617011360-102531-1-git-send-email-yang.lee@linux.alibaba.com> In-Reply-To: <1617011360-102531-1-git-send-email-yang.lee@linux.alibaba.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.5.1.3 x-originating-ip: [10.1.200.100] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org - set_bit(MCE_OVERFLOW, (unsigned long *)&mcelog->flags); + mcelog->flags |= BIT(MCE_OVERFLOW); set_bit() is an atomic operation because it might race with the code to get and clear this bit: do { flags = mcelog->flags; } while (cmpxchg(&mcelog->flags, flags, 0) != flags); Originally this was needed because mcelog could be called from #MC context. That's all changed now and the machine check notifier chain routines are called in a kernel thread. So some other locking (mutex?) could be used to protect access to mcelog->flags. -Tony